{ "cells": [ { "cell_type": "markdown", "id": "arranged-tenant", "metadata": {}, "source": [ "\n", "\n", "#
From Maps to Models - Tutorials for structural geological modeling using GemPy and GemGIS
\n", "\n", "\n", "# Example 6 - Planar Dipping Layers\n", "\n", "This example will show how to convert the geological map below using ``GemGIS`` to a `GemPy` model. This example is based on digitized data. The area is 1370 m wide (W-E extent) and 1561 m high (N-S extent). The vertical model extent varies between 0 m and 800 m. The model represents planar layers dipping towards the southwest.\n", "\n", "
\n", "In this tutorial, you will learn the following:
\n", "- How to build your sixth GemPy model with input data generated through GemGIS
\n", "- Finishing the the extra model for that section
\n", "\n", "
\n", "\n", "## Your Tasks\n", "1. Georeference the map in QGIS given the dimensions above using the coordinate reference system with the EPSG code 4326\n", "2. Digitize the layer boundaries (including a `formation` column) and the topographic lines (including a `Z` column)\n", "3. Digitize so-called strike lines for the different layers. The orientations used for `GemPy` will be calculated from the strike lines.\n", "\n", "## Contents\n", "\n", "1. [Installing GemPy and GemGIS](#installing-gempy)\n", "2. [Importing Libraries](#importing-libraries)\n", "3. [Data Preparation](#data-preparation)\n", " 1. [Creating Digital Elevation Model from Contour lines](#creating-digital-elevation-model-from-contour-lines)\n", " 1. [Loading Contour Lines](#loading-contour-lines)\n", " 2. [Plotting Contour Lines](#plotting-contour-lines)\n", " 3. [Interpolating Contour Lines](#interpolating-contour-lines)\n", " 4. [Plotting the raster](#plotting-the-raster)\n", " 5. [Saving the raster to disc](#saving-the-raster-to-disc)\n", " 6. [Opening raster](#opening-raster)\n", " 2. [Processing Stratigraphic Boundaries](#processing-stratigraphic-boundaries)\n", " 1. [Opening Stratigraphic Boundaries](#opening-stratigraphic-boundaries)\n", " 2. [Plotting Stratigraphic Boundaries](#plotting-stratigraphic-boundaries)\n", " 3. [Extracting Z coordinates from Digital Elevation Model](#extracting-z-coordinates-from-digital-elevation-model)\n", " 4. [Plotting the Interface Points](#plotting-the-interface-points)\n", " 3. [Processing Orientations](#processing-orientations)\n", " 1. [Orientations from Strike Lines](#orientations-from-strike-lines)\n", " 2. [Plotting Strike Lines](#plotting-strike-lines)\n", " 2. [Loading Strike Lines](#loading-strike-lines)\n", " 3. [Plotting Strike Lines](#plotting-strike-lines)\n", " 4. [Calculate Orientations for each formation](#calculate-orientations-for-each-formation)\n", " 5. [Merging Orientations for GemPy](#merging-orientations-for-gempy)\n", " 6. [Plotting Orientations](#plotting-orientations)\n", "4. [GemPy Model calculation](#gempy-model-calculation)\n", " 1. [Creating the GemPy Model](#creating-the-gempy-model)\n", " 2. [Data Initiation](#data-initiation)\n", " 3. [Inspecting the Surfaces](#inspecting-the-surfaces)\n", " 4. [Inspecting the Input Data](#inspecting-the-input-data)\n", " 5. [Map Stack to Surfaces](#map-stack-to-surfaces)\n", " 6. [Showing the Number of Data Points](#showing-the-number-of-data-points)\n", " 7. [Loading Digital Elevation Model](#loading-digital-elevation-model)\n", " 8. [Defining Custom Section](#defining-custom-section)\n", " 6. [Plotting Input Data in 2D](#plotting-the-input-data-in-2d)\n", " 7. [Plotting Input Data in 3D](#plotting-the-input-data-in-3d)\n", " 8. [Setting the Interpolator](#setting-the-interpolator)\n", " 9. [Computing the Model](#computing-the-model)\n", "5. [Model Visualization and Post-Processing](#model-visualization-and-post-processing)\n", " 1. [Visualizing the computed model in 2D](#visualizing-the-computed-model-in-2d)\n", " 2. [Visualizing the computed model in 3D](#visualizing-the-computed-model-in-3d) \n", "\n", "\n", "\n", "Source: Powell, D. (1995): Interpretation geologischer Strukturen durch Karten - Eine praktische Anleitung mit Aufgaben und Lösungen, page 23, figure 20 B, Springer Verlag Berlin, Heidelberg, New York, ISBN: 978-3-540-58607-4." ] }, { "cell_type": "markdown", "id": "friendly-transaction", "metadata": {}, "source": [ "\n", "\n", "# Installing GemPy and GemGIS\n", "\n", "If you have not installed `GemPy` yet, please follow the [GemPy installation instructions](https://docs.gempy.org/installation.html) and the [GemGIS installation instructions](https://gemgis.readthedocs.io/en/latest/getting_started/installation.html). If you encounter any issues, feel free to open a new discussion at [GemPy Discussions](https://github.com/cgre-aachen/gempy/discussions) or [GemGIS Discussions](https://github.com/cgre-aachen/gemgis/discussions). If you encounter an error in the installation process, feel free to also open an issue at [GemPy Issues](https://github.com/cgre-aachen/gempy/issues) or [GemGIS Issues](https://github.com/cgre-aachen/gemgis/issues). There, the `GemPy` and `GemGIS` development teams will help you out. " ] }, { "cell_type": "markdown", "id": "allied-vessel", "metadata": {}, "source": [ "\n", "\n", "# Importing Libraries\n", "\n", "For this notebook, we need the `geopandas` library for the data preparation, `rasterio` for dealing with the created digital elevation model, `matplotlib` for plotting, `numpy` for some numerical calculations, `pandas` for manipulating `DataFrames` and of course the `gempy` and `gemgis` libraries. Any warnings that may appear can be ignored for now. The file path is set to load the data provided for this tutorial. " ] }, { "cell_type": "code", "execution_count": null, "id": "polar-appliance", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:55.300626Z", "start_time": "2022-04-09T06:45:55.287570Z" } }, "outputs": [], "source": [ "import geopandas as gpd\n", "import rasterio\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", "import gemgis as gg\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import gempy as gp\n", "import pyvista as pv\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": null, "id": "healthy-queens", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:55.347279Z", "start_time": "2022-04-09T06:45:55.304124Z" } }, "outputs": [], "source": [ "file_path = '../../data/example25_planar_dipping_layers/'" ] }, { "cell_type": "markdown", "id": "impressed-database", "metadata": {}, "source": [ "\n", "# Data Preparation\n", "\n", "At his point, you should have the topographic contour lines (including a `Z` column) and the layer boundaries (including a `formation` column) digitized. If not, please generate the data before continuing with this tutorial. \n", "\n", "\n", "## Creating Digital Elevation Model from Contour Lines\n", "\n", "The digital elevation model (DEM) will be created by interpolating the contour lines digitized from the georeferenced map using the `SciPy` [Radial Basis Function interpolation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.Rbf.html) wrapped in `GemGIS`. The respective function used for that is `gg.vector.interpolate_raster()`. \n", "\n", "\n", "\n", "Source: Powell, D. (1995): Interpretation geologischer Strukturen durch Karten - Eine praktische Anleitung mit Aufgaben und Lösungen, page 23, figure 20 B, Springer Verlag Berlin, Heidelberg, New York, ISBN: 978-3-540-58607-4.\n", "\n", "\n", "\n", "### Loading contour lines\n", "\n", "First, the contour lines are loaded using `GeoPandas`. Please provide here the name of your shape file containing the digitized topographic contour lines. " ] }, { "cell_type": "code", "execution_count": null, "id": "informed-tomorrow", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:55.874432Z", "start_time": "2022-04-09T06:45:55.783384Z" } }, "outputs": [], "source": [ "topo = gpd.read_file(file_path + 'topo25.shp')\n", "topo.head()" ] }, { "cell_type": "markdown", "id": "9de9c4b6", "metadata": {}, "source": [ "\n", "\n", "### Plotting the contour lines\n", "\n", "The contour lines are plotted using the built-in plotting function of `GeoPandas`. " ] }, { "cell_type": "code", "execution_count": null, "id": "491820f2", "metadata": {}, "outputs": [], "source": [ "topo.plot(column='Z', aspect=1, legend=True, cmap='gist_earth')" ] }, { "cell_type": "markdown", "id": "inclusive-florence", "metadata": {}, "source": [ "\n", "\n", "### Interpolating the contour lines\n", "\n", "The digital elevation model (DEM) will be created by interpolating the contour lines digitized from the georeferenced map using the `SciPy` [Radial Basis Function interpolation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.Rbf.html) wrapped in `GemGIS`. The respective function used for that is `gg.vector.interpolate_raster()`. \n", "\n", "There is also a [tutorial available for this task on the GemGIS Documentation page](https://gemgis.readthedocs.io/en/latest/getting_started/tutorial/05_interpolating_rasters.html)." ] }, { "cell_type": "code", "execution_count": null, "id": "revolutionary-calibration", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:57.090457Z", "start_time": "2022-04-09T06:45:55.878414Z" } }, "outputs": [], "source": [ "topo_raster = gg.vector.interpolate_raster(gdf=topo, value='Z', method='rbf', res=5)" ] }, { "cell_type": "markdown", "id": "experimental-press", "metadata": {}, "source": [ "\n", "\n", "### Plotting the raster\n", "\n", "The interpolated digital elevation model can be displayed using `matplotlib` and its `plt.imshow()` function and by providing the extent of the raster to align it with the contour lines. " ] }, { "cell_type": "code", "execution_count": null, "id": "frozen-gazette", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:57.631903Z", "start_time": "2022-04-09T06:45:57.094466Z" } }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "\n", "from mpl_toolkits.axes_grid1 import make_axes_locatable\n", "\n", "fix, ax = plt.subplots(1, figsize=(5,5))\n", "topo.plot(ax=ax, aspect='equal', column='Z', cmap='gist_earth')\n", "im = ax.imshow(topo_raster, origin='lower', extent=[0,1370,0,1561], cmap='gist_earth')\n", "divider = make_axes_locatable(ax)\n", "cax = divider.append_axes(\"right\", size=\"5%\", pad=0.05)\n", "cbar = plt.colorbar(im, cax=cax)\n", "cbar.set_label('Altitude [m]')\n", "ax.set_xlabel('X [m]')\n", "ax.set_ylabel('Y [m]')" ] }, { "cell_type": "markdown", "id": "common-franklin", "metadata": {}, "source": [ "### Saving the raster to disc\n", "\n", "After the interpolation of the contour lines, the raster is saved to disc using `gg.raster.save_as_tiff()`. The function will not be executed as as raster is already provided with the example data. " ] }, { "cell_type": "raw", "id": "cathedral-aquarium", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:44:48.227647Z", "start_time": "2022-04-09T06:44:48.152408Z" } }, "source": [ "gg.raster.save_as_tiff(raster=topo_raster, path=file_path + 'raster25.tif', extent=[0,1370,0,1561], crs='EPSG:4326', overwrite_file=True)" ] }, { "cell_type": "markdown", "id": "under-pursuit", "metadata": {}, "source": [ "### Opening Raster\n", "\n", "The previously computed and saved raster can now be opened using rasterio. " ] }, { "cell_type": "code", "execution_count": null, "id": "silver-defendant", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:57.709858Z", "start_time": "2022-04-09T06:45:57.636905Z" } }, "outputs": [], "source": [ "topo_raster = rasterio.open(file_path + 'raster25.tif')" ] }, { "cell_type": "markdown", "id": "central-option", "metadata": { "ExecuteTime": { "end_time": "2021-03-28T12:43:27.113805Z", "start_time": "2021-03-28T12:43:27.067793Z" } }, "source": [ "\n", "\n", "## Processing Stratigraphic Boundaries\n", "\n", "The interface points will be extracted from LineStrings digitized from the georeferenced map using QGIS. It is important to provide a `formation` name for each layer boundary. Up until now, only the `X` and `Y` position are stored in the vertices of the LineStrings. Using the digital elevation model created already, we will now sample the elevation model at the locations of the vertices to extract the height at this point as the stratigraphic boundary was mapped at the surface.\n", "\n", "\n", "Source: Powell, D. (1995): Interpretation geologischer Strukturen durch Karten - Eine praktische Anleitung mit Aufgaben und Lösungen, page 23, figure 20 B, Springer Verlag Berlin, Heidelberg, New York, ISBN: 978-3-540-58607-4." ] }, { "cell_type": "markdown", "id": "c0f27ece", "metadata": {}, "source": [ "\n", "\n", "### Opening Stratigraphic Boundaries\n", "\n", "The stratigraphic units are opened using `GeoPandas`." ] }, { "cell_type": "code", "execution_count": null, "id": "activated-namibia", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:58.154202Z", "start_time": "2022-04-09T06:45:58.079964Z" } }, "outputs": [], "source": [ "interfaces = gpd.read_file(file_path + 'interfaces25.shp')\n", "interfaces.head()" ] }, { "cell_type": "markdown", "id": "e732dab7", "metadata": {}, "source": [ "\n", "\n", "### Plotting Stratigraphic Boundaries" ] }, { "cell_type": "code", "execution_count": null, "id": "fb4d66b3", "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(1, figsize=(5,5))\n", "\n", "interfaces.plot(ax=ax, column='formation', legend=True, aspect='equal')\n", "\n", "plt.grid()\n", "ax.set_xlabel('X [m]')\n", "ax.set_ylabel('Y [m]')" ] }, { "cell_type": "markdown", "id": "prospective-drink", "metadata": {}, "source": [ "\n", "\n", "### Extracting Z coordinates from Digital Elevation Model\n", "\n", "The vertical position of the interface point will be extracted from the digital elevation model using the `GemGIS` function `gg.vector.extract_xyz()`. The resulting GeoDataFrame now contains single points including the information about the respective `formation` as well as the `X`, `Y`, and `Z` location. This is all we need as preparational steps to generate input data for `GemPy`. \n", "\n", "There is also a [tutorial available for this task on the GemGIS Documentation page](https://gemgis.readthedocs.io/en/latest/getting_started/tutorial/02_extract_xyz.html)." ] }, { "cell_type": "code", "execution_count": null, "id": "stopped-saint", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:58.265222Z", "start_time": "2022-04-09T06:45:58.158203Z" } }, "outputs": [], "source": [ "interfaces_coords = gg.vector.extract_xyz(gdf=interfaces, dem=topo_raster)\n", "interfaces_coords = interfaces_coords.sort_values(by='formation', ascending=False)\n", "interfaces_coords.head()" ] }, { "cell_type": "markdown", "id": "valued-coast", "metadata": {}, "source": [ "\n", "\n", "### Plotting the Interface Points\n", "\n", "The interface points incuding their altitude (Z-) values and the digitized LineString can be plotted using `matplotlib`. " ] }, { "cell_type": "code", "execution_count": null, "id": "involved-association", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:58.662335Z", "start_time": "2022-04-09T06:45:58.270229Z" } }, "outputs": [], "source": [ "fig, ax = plt.subplots(1, figsize=(10,10))\n", "\n", "interfaces.plot(ax=ax, column='formation', legend=True, aspect='equal')\n", "interfaces_coords.plot(ax=ax, column='formation', legend=True, aspect='equal')\n", "plt.grid()\n", "plt.xlabel('X [m]')\n", "plt.ylabel('Y [m]')\n", "plt.xlim(0,1370)\n", "plt.ylim(0,1561)" ] }, { "cell_type": "markdown", "id": "inner-mathematics", "metadata": {}, "source": [ "\n", "\n", "## Processing Orientations\n", "\n", "For this example, orientations must be calculated yourself. They will be calculated using functions implemented in GemGIS and the previously digitized strike lines. \n", "\n", "\n", "Source: Powell, D. (1995): Interpretation geologischer Strukturen durch Karten - Eine praktische Anleitung mit Aufgaben und Lösungen, page 23, figure 20 B, Springer Verlag Berlin, Heidelberg, New York, ISBN: 978-3-540-58607-4.\n", "\n", "\n", "### Orientations from Strike Lines\n", "\n", "Strike lines connect outcropping stratigraphic boundaries (interfaces) of the same altitude. In other words: the intersections between topographic contours and stratigraphic boundaries at the surface. The height difference and the horizontal difference between two digitized lines is used to calculate the dip and azimuth and hence an orientation that is necessary for `GemPy`.\n", "\n", "The calculation of orientations from strike lines has been implemented into `GemPy` for simple cases like these. In order to calculate the orientations, each set of strikes lines/LineStrings for one formation must be given an id number next to the altitude of the strike line. The id field is already predefined in QGIS. The strike line with the lowest altitude gets the id number `1`, the strike line with the highest altitude the the number according to the number of digitized strike lines. It is currently recommended to use one set of strike lines for each structural element of one formation as illustrated. \n", "\n", "\n", "\n", "By CrunchyRocks, after Karla Panchuck - https://openpress.usask.ca/physicalgeology/chapter/13-5-measuring-geological-structures/, CC BY 4.0, https://commons.wikimedia.org/w/index.php?curid=113554289\n", "\n", "\n", "\n", "Source: Powell, D. (1995): Interpretation geologischer Strukturen durch Karten - Eine praktische Anleitung mit Aufgaben und Lösungen, page 14, figure 8, Springer Verlag Berlin, Heidelberg, New York, ISBN: 978-3-540-58607-4." ] }, { "cell_type": "code", "execution_count": null, "id": "configured-evaluation", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:59.058798Z", "start_time": "2022-04-09T06:45:58.983602Z" } }, "outputs": [], "source": [ "strikes = gpd.read_file(file_path + 'strikes25.shp')\n", "strikes" ] }, { "cell_type": "markdown", "id": "9993e7ca", "metadata": {}, "source": [ "\n", "\n", "### Plotting Strike Lines\n", "\n", "The strike lines can be plotted using `matplotlib`. " ] }, { "cell_type": "code", "execution_count": null, "id": "3b4442b0", "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(1, figsize=(5,5))\n", "\n", "strikes.plot(ax=ax,column='id', aspect=1)\n", "interfaces.plot(ax=ax, column='formation', legend=True, aspect='equal')\n", "ax.set_xlabel('X [m]')\n", "ax.set_ylabel('Y [m]')\n", "ax.grid()" ] }, { "cell_type": "markdown", "id": "imposed-elite", "metadata": {}, "source": [ "\n", "\n", "### Calculate Orientations for each formation\n", "\n", "The calculations will be calculated using the function `gg.vector.calculate_orientations_from_strike_lines()` where the strike lines for each single formation will be provided and calculated separately. The result is a `GeoDataFrame` ready to be used in `GemPy`." ] }, { "cell_type": "code", "execution_count": null, "id": "durable-fault", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:59.234499Z", "start_time": "2022-04-09T06:45:59.063321Z" } }, "outputs": [], "source": [ "orientations_coal = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation']=='Coal'].sort_values(by='Z', ascending=True).reset_index())\n", "orientations_coal" ] }, { "cell_type": "markdown", "id": "friendly-token", "metadata": {}, "source": [ "\n", "\n", "### Merging Orientations for GemPy\n", "\n", "Since `GemPy` only takes one `DataFrame` for the necessary orientations, the single `DataFrames` are concatenated using `pd.concat()`. " ] }, { "cell_type": "code", "execution_count": null, "id": "sitting-reproduction", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:59.281388Z", "start_time": "2022-04-09T06:45:59.237501Z" } }, "outputs": [], "source": [ "import pandas as pd\n", "orientations = pd.concat([orientations_coal]).reset_index()\n", "orientations['formation'] = 'Coal'\n", "orientations" ] }, { "cell_type": "markdown", "id": "textile-christianity", "metadata": {}, "source": [ "\n", "\n", "### Plotting the Orientations\n", "\n", "The orientations can be plotted using `matplotlib`." ] }, { "cell_type": "code", "execution_count": null, "id": "detected-certificate", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:45:59.772748Z", "start_time": "2022-04-09T06:45:59.285639Z" } }, "outputs": [], "source": [ "fig, ax = plt.subplots(1, figsize=(5,5))\n", "\n", "interfaces.plot(ax=ax, column='formation', legend=True, aspect='equal')\n", "interfaces_coords.plot(ax=ax, column='formation', legend=True, aspect='equal')\n", "orientations.plot(ax=ax, color='red', aspect='equal')\n", "plt.grid()\n", "plt.xlabel('X [m]')\n", "plt.ylabel('Y [m]')\n", "plt.xlim(0,1370)\n", "plt.ylim(0,1561)" ] }, { "cell_type": "markdown", "id": "wired-vietnamese", "metadata": {}, "source": [ "\n", "\n", "# GemPy Model Calculation\n", "\n", "\n", "The creation of a `GemPy` Model follows particular steps which will be performed in the following:\n", "\n", "1. Create new model: `gp.create_model()`\n", "2. Data Initiation: `gp.init_data()`\n", "3. Map Stack to Surfaces: `gp.map_stack_to_surfaces()`\n", "4. [...]\n", "5. Set the Interpolator: `gp.set_interpolator()`\n", "6. Computing the Model: `gp.compute_model()`\n", "\n", "\n", "\n", "## Creating the GemPy Model\n", "\n", "The first step is to create a new empty `GemPy` model by providing a name for it. " ] }, { "cell_type": "code", "execution_count": null, "id": "binding-fishing", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:03.386333Z", "start_time": "2022-04-09T06:46:02.105388Z" } }, "outputs": [], "source": [ "geo_model = gp.create_model('Model25')\n", "geo_model" ] }, { "cell_type": "markdown", "id": "stopped-poster", "metadata": {}, "source": [ "\n", "\n", "## Data Initiation\n", "\n", "During this step, the `extent` of the model (`xmin`, `xmax`, `ymin`, `ymax`, `zmin`, `zmax`) and the `resolution` in `X`, `Y`and `Z` direction (`res_x`, `res_y`, `res_z`, equal to the number of cells in each direction) will be set using lists of values. \n", "\n", "The interface points (`surface_points_df`) and orientations (`orientations_df`) will be passed as `pandas` `DataFrames`. " ] }, { "cell_type": "code", "execution_count": null, "id": "assisted-nothing", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:03.706405Z", "start_time": "2022-04-09T06:46:03.389335Z" } }, "outputs": [], "source": [ "gp.init_data(geo_model, [0,1370,0,1561,0,800], [100,100,100],\n", " surface_points_df = interfaces_coords[interfaces_coords['Z']!=0],\n", " orientations_df = orientations,\n", " default_values=True)" ] }, { "cell_type": "markdown", "id": "integrated-pension", "metadata": {}, "source": [ "\n", "\n", "## Inspecting the Surfaces\n", "\n", "The model consists of five different layers or surfaces now which all belong to the `Default series`. During the next step, the proper `Series` will be assigned to the surfaces. Using the `surfaces`-attribute again, we can check which layers were loaded." ] }, { "cell_type": "code", "execution_count": null, "id": "cutting-energy", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:03.802536Z", "start_time": "2022-04-09T06:46:03.714405Z" } }, "outputs": [], "source": [ "geo_model.surfaces" ] }, { "cell_type": "markdown", "id": "4eb0ee2d", "metadata": {}, "source": [ "\n", "\n", "## Inspecting the Input Data\n", "\n", "The loaded interface points and orientations can again be inspected using the `surface_points`- and `orientations`-attributes. Using the `df`-attribute of this object will convert the displayed table in a `pandas` `DataFrame`." ] }, { "cell_type": "code", "execution_count": null, "id": "8284940d", "metadata": {}, "outputs": [], "source": [ "geo_model.surface_points.df.head()" ] }, { "cell_type": "code", "execution_count": null, "id": "0d6c096b", "metadata": {}, "outputs": [], "source": [ "geo_model.orientations.df.head()" ] }, { "cell_type": "markdown", "id": "younger-young", "metadata": {}, "source": [ "\n", "\n", "## Map Stack to Surfaces\n", "\n", "During this step, the layer of the model is assigned to the `Strata1` series. We will also add a `Basement` here (`geo_model.add_surfaces('Basement')`). " ] }, { "cell_type": "code", "execution_count": null, "id": "formed-thought", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:03.978574Z", "start_time": "2022-04-09T06:46:03.807539Z" } }, "outputs": [], "source": [ "gp.map_stack_to_surfaces(geo_model,\n", " {\n", " 'Strata1': ('Coal'),\n", " },\n", " remove_unused_series=True)\n", "geo_model.add_surfaces('Basement')" ] }, { "cell_type": "markdown", "id": "subtle-techno", "metadata": {}, "source": [ "\n", "\n", "## Showing the Number of Data Points\n", "\n", "You can also return the number of interfaces and orientations for each formation using `gg.utils.show_number_of_data_points()`" ] }, { "cell_type": "code", "execution_count": null, "id": "forty-treaty", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:04.061355Z", "start_time": "2022-04-09T06:46:03.981572Z" } }, "outputs": [], "source": [ "gg.utils.show_number_of_data_points(geo_model=geo_model)" ] }, { "cell_type": "markdown", "id": "medieval-deployment", "metadata": {}, "source": [ "\n", "\n", "## Loading Digital Elevation Model\n", "\n", "`GemPy` is capable of including a topography into the modeling process. Here, we use the topography that we have interpolated in one of the previous steps. `GemPy` takes the file path of the raster/digital elevation model and loads it as grid into the `geo_model` object." ] }, { "cell_type": "code", "execution_count": null, "id": "subsequent-technique", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:04.560347Z", "start_time": "2022-04-09T06:46:04.067358Z" } }, "outputs": [], "source": [ "geo_model.set_topography(\n", " source='gdal', filepath=file_path + 'raster25.tif')" ] }, { "cell_type": "markdown", "id": "extreme-drink", "metadata": {}, "source": [ "\n", "\n", "## Plotting the input data in 2D using Matplotlib\n", "\n", "The input data can now be visualized in 2D using `matplotlib`. This might for example be useful to check if all points and measurements are defined the way we want them to. Using the function `plot_2d()`, we attain a 2D projection of our data points onto a plane of chosen direction (we can choose this attribute to be either `'x'`, `'y'`, or `'z'`)." ] }, { "cell_type": "code", "execution_count": null, "id": "conservative-philip", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:04.908437Z", "start_time": "2022-04-09T06:46:04.563350Z" } }, "outputs": [], "source": [ "gp.plot_2d(geo_model, direction='z', show_lith=False, show_boundaries=False)\n", "plt.grid()" ] }, { "cell_type": "markdown", "id": "e72c53b8", "metadata": {}, "source": [ "\n", "\n", "## Plotting the input data in 3D using PyVista\n", "\n", "The input data can also be viszualized using the `pyvista` package. In this view, the interface points are visible as well as the orientations (marked as arrows) which indicate the normals of each orientation value. " ] }, { "cell_type": "code", "execution_count": null, "id": "vocational-intranet", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:05.461756Z", "start_time": "2022-04-09T06:46:04.910427Z" } }, "outputs": [], "source": [ "gp.plot_3d(geo_model, image=False, plotter_type='basic', notebook=True)" ] }, { "cell_type": "markdown", "id": "geological-triple", "metadata": {}, "source": [ "\n", "## Setting the interpolator\n", "\n", "Once we have made sure that we have defined all our primary information, we can continue with the next step towards creating our geological model: preparing the input data for interpolation.\n", "\n", "Setting the interpolator is necessary before computing the actual model. Here, the most important kriging parameters can be defined. " ] }, { "cell_type": "code", "execution_count": null, "id": "external-clerk", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:08.373004Z", "start_time": "2022-04-09T06:46:05.464757Z" } }, "outputs": [], "source": [ "gp.set_interpolator(geo_model,\n", " compile_theano=True,\n", " theano_optimizer='fast_compile',\n", " verbose=[],\n", " update_kriging = False\n", " )" ] }, { "cell_type": "markdown", "id": "above-lending", "metadata": {}, "source": [ "\n", "\n", "## Computing the model\n", "\n", "At this point, we have all we need to compute our full model via `gp.compute_model()`. By default, this will return two separate solutions in the form of arrays. The first provides information on the lithological formations, the second on the fault network in the model, which is not present in this example. " ] }, { "cell_type": "code", "execution_count": null, "id": "impressed-adams", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:15.491226Z", "start_time": "2022-04-09T06:46:08.375005Z" } }, "outputs": [], "source": [ "sol = gp.compute_model(geo_model, compute_mesh=True)" ] }, { "cell_type": "code", "execution_count": null, "id": "1a8c90eb", "metadata": {}, "outputs": [], "source": [ "sol" ] }, { "cell_type": "code", "execution_count": null, "id": "190cece8", "metadata": {}, "outputs": [], "source": [ "geo_model.solutions" ] }, { "cell_type": "markdown", "id": "developing-wallet", "metadata": {}, "source": [ "\n", "\n", "# Model Visualization and Post-Processing\n", "\n", "\n", "\n", "## Visulazing Cross Sections of the computed model\n", "\n", "Cross sections in different `direction`s and at different `cell_number`s can be displayed. Here, we see the folded layers of the model in the different directions. \n", "\n", "The first section to be plotted is the custom section `Section1` followed by an array of cross sections." ] }, { "cell_type": "code", "execution_count": null, "id": "champion-collectible", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:16.575679Z", "start_time": "2022-04-09T06:46:15.493244Z" } }, "outputs": [], "source": [ "gp.plot_2d(geo_model, direction=['x', 'x', 'y', 'y'], cell_number=[25,75,25,75], show_topography=True, show_data=False)" ] }, { "cell_type": "markdown", "id": "3893eeb9", "metadata": {}, "source": [ "Next to the lithology data, we can also plot the calculated scalar field." ] }, { "cell_type": "code", "execution_count": null, "id": "5d937969", "metadata": {}, "outputs": [], "source": [ "gp.plot_2d(geo_model, direction='y', show_data=False, show_scalar=True, show_lith=False)" ] }, { "cell_type": "markdown", "id": "intimate-connectivity", "metadata": {}, "source": [ "### Plotting 3D Model" ] }, { "cell_type": "code", "execution_count": null, "id": "developing-comparison", "metadata": { "ExecuteTime": { "end_time": "2022-04-09T06:46:19.244512Z", "start_time": "2022-04-09T06:46:16.577679Z" } }, "outputs": [], "source": [ "gpv = gp.plot_3d(geo_model, image=False, show_topography=True,\n", " plotter_type='basic', notebook=True, show_lith=True)" ] }, { "cell_type": "markdown", "id": "f9dd6cb1", "metadata": {}, "source": [ "\n", "# Conclusions\n", "\n", "
\n", "In this tutorial, you have learnt the following:
\n", "- How to build your sixth GemPy model with input data generated through GemGIS
\n", "- Finishing the the extra model for that section
\n", "
\n", "\n", "\n", "# Outlook\n", "\n", "
\n", "In the next tutorial, you will learn the following:
\n", "- How to build your fourth GemPy model with input data generated through GemGIS
\n", "- How to build a GemPy model with folded layers
\n", "- How to obtain the the fold axis of a structure
\n", "- How to extract contour lines from a PyVista depth map and to save them as GeoDataFrame
\n", "- How to convert a depth map to an array/raster
\n", "- How to convert contour lines from that raster
\n", "
\n", "\n", "[Take me to the next notebook on Github](https://github.com/cgre-aachen/gemgis_data/blob/main/notebooks/03_folded_layers/example01_folded_layers.ipynb)\n", "\n", "\n", "Source: Bennison, G.M. (1988): An Introduction to Geological Structures and Maps, page 22, figure 9, Springer Verlag Berlin, Heidelberg, New York, ISBN: 978-1-4615-9632-5\n", "\n", "\n", "\n", "\n", "## Licensing\n", "\n", "Institute for Computational Geoscience, Geothermics and Reservoir Geophysics, RWTH Aachen University & Fraunhofer IEG, Fraunhofer Research Institution for Energy Infrastructures and Geothermal Systems IEG, Authors: Alexander Juestel. For more information contact: alexander.juestel(at)ieg.fraunhofer.de\n", "\n", "All notebooks are licensed under a Creative Commons Attribution 4.0 International License (CC BY 4.0, http://creativecommons.org/licenses/by/4.0/). References for each displayed map are provided. Most of the maps originate from the books of [Powell (1992)](https://link.springer.com/book/9783540586074) and [Bennison (1990)](https://link.springer.com/book/10.1007/978-1-4615-9630-1). References for maps with unknown origin will gladly be added." ] } ], "metadata": { "hide_input": false, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.15" }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 5 }