{ "cells": [ { "cell_type": "markdown", "id": "worldwide-contact", "metadata": {}, "source": [ "\n", "\n", "#
From Maps to Models - Tutorials for structural geological modeling using GemPy and GemGIS
\n", "\n", "# Model 4 - Unconformable/Truncated Layers\n", "\n", "The fourth and last notebook in this tutorial series builds upon the builds upon the [previous three notebooks](../01_basic_modeling) ([previous three notebooks on Github](https://nbviewer.org/github/cgre-aachen/gemgis_data/tree/main/notebooks/01_basic_modeling)) where parallel horizontal, parallel folded and parallel faulted layers were modeled. This notebook illustrates now how to create a simple model of unconformable layers in `GemPy`. The model consists of four layers of which only two are always parallel. These two groups (`Series`) of parallel layers are separated and truncated by an unconformity. The model has an extent of 1000 m by 1000 m with a vertical extent of 600 m. \n", "\n", "
\n", "In this tutorial, you will learn the following:
\n", "- Get an understanding of how unconformities are modeled/displayed in GemPy
\n", "- How to build a simple model consisting of unconformable layers belonging to multiple Series
\n", "\n", "
\n", "\n", "## Contents\n", "\n", "1. [Installing GemPy](#installing-gempy)\n", "2. [Importing Libraries](#importing-libraries)\n", "3. [Data Preparation](#data-preparation)\n", " 1. [Importing Interface Points](#importing-interface-points)\n", " 2. [Importing Orientations](#importing-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. [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 Cross Sections of the Computed Model](#visualizing-cross-sections-of-the-computed-model)\n", " 2. [Visualizing the computed model in 3D](#visualizing-the-computed-model-in-3d)\n", "6. [Conclusions](#conclusions)\n", "7. [Outlook](#outlook)\n", "8. [Licensing](#licensing)\n", "\n", "\n", "\n", "" ] }, { "cell_type": "markdown", "id": "04c77e47", "metadata": {}, "source": [ "Unconformities are the last element that `GemPy` is capable of modeling apart from folded and faulted layers. Unconformities are not calculated as a fault surface that offsets layers. Instead, a new scalar field is calculated, which is merged with other scalar fields. In order to create another scalar field, the layers just have to be defined as non-parallel layers in `gp.map_stack_to_surfaces()` by defining multiple `Series`. \n", "\n", "\n", "Source: de la Varga et al. (2019)" ] }, { "cell_type": "markdown", "id": "solid-hormone", "metadata": {}, "source": [ "\n", "\n", "# Installing GemPy\n", "\n", "If you have not installed `GemPy` yet, please follow the [installation instructions](https://docs.gempy.org/installation.html). If you encounter any issues, feel free to open a new discussion at [GemPy Discussions](https://github.com/cgre-aachen/gempy/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). There, the `GemPy` development team will help you out. " ] }, { "cell_type": "markdown", "id": "artificial-customs", "metadata": {}, "source": [ "\n", "\n", "# Importing Libraries\n", "\n", "For this notebook, we need the `pandas` library for the data preparation and `matplotlib` for plotting and of course the `gempy` library. Any warnings that may appear can be ignored for now. " ] }, { "cell_type": "code", "execution_count": null, "id": "2f498618", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:14.045424Z", "start_time": "2022-04-02T13:47:09.525220Z" } }, "outputs": [], "source": [ "import pandas as pd\n", "import gempy as gp\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "id": "jewish-complex", "metadata": {}, "source": [ "\n", "# Data Preparation\n", "\n", "For this model, the only thing that needs to be done is loading the already created interface points and orientations. In the next tutorials, you will create the data yourself and process it further to make it usable for GemPy. \n", "\n", "\n", "## Importing Interface Points\n", "\n", "We are using the `pandas` library to load the interface points that were prepared beforehand and stored as CSV-file. The only information that is needed are the location of the interface point (`X`, `Y`, `Z`) and the `formation` it belongs to. You may have to adjust the `delimiter` when loading the file." ] }, { "cell_type": "code", "execution_count": null, "id": "9c8c178c", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:14.093078Z", "start_time": "2022-04-02T13:47:14.050433Z" } }, "outputs": [], "source": [ "interfaces = pd.read_csv('../data/model4/model4_interfaces.csv', \n", " delimiter = ';')\n", "interfaces.head()" ] }, { "cell_type": "markdown", "id": "occupied-simulation", "metadata": {}, "source": [ "\n", "\n", "## Importing Orientations\n", "\n", "The orientations will also be loaded using `pandas`. In addition to the location and the formation the orientation belongs to, the dip value, azimuth value (dip direction) and a polarity value (mostly set to 1 by default) needs to be provided. As the model will feature folded layers, the dip and the azimuth are variable. Orientations are provided for all four modeled layers. " ] }, { "cell_type": "code", "execution_count": null, "id": "bd8aa29b", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:14.141105Z", "start_time": "2022-04-02T13:47:14.099097Z" } }, "outputs": [], "source": [ "orientations = pd.read_csv('../data/model4/model4_orientations.csv', \n", " delimiter=';')\n", "orientations.head()" ] }, { "cell_type": "markdown", "id": "veterinary-acceptance", "metadata": {}, "source": [ "\n", "\n", "# GemPy Model Calculation\n", "\n", "The following part presents the main steps of creating a model in `GemPy`. \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": "eb3ec438", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:15.344340Z", "start_time": "2022-04-02T13:47:14.145088Z" } }, "outputs": [], "source": [ "geo_model = gp.create_model('Model4_Truncated_Layers')\n", "geo_model" ] }, { "cell_type": "markdown", "id": "supreme-encoding", "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": "ae4bb825", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:15.758421Z", "start_time": "2022-04-02T13:47:15.350324Z" } }, "outputs": [], "source": [ "gp.init_data(geo_model=geo_model, \n", " extent=[0, 1000, 0, 1000, -600, 0], \n", " resolution=[100, 100, 100],\n", " surface_points_df=interfaces,\n", " orientations_df=orientations,\n", " default_values=True)" ] }, { "cell_type": "markdown", "id": "armed-story", "metadata": {}, "source": [ "\n", "\n", "## Inspecting the Surfaces\n", "\n", "The model consists of four 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": "9e8519ea", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:15.885192Z", "start_time": "2022-04-02T13:47:15.760405Z" } }, "outputs": [], "source": [ "geo_model.surfaces" ] }, { "cell_type": "markdown", "id": "0d2035c9", "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": "0f4e2243", "metadata": {}, "outputs": [], "source": [ "geo_model.surface_points.df.head()" ] }, { "cell_type": "code", "execution_count": null, "id": "338f3a0e", "metadata": {}, "outputs": [], "source": [ "geo_model.orientations.df.head()" ] }, { "cell_type": "markdown", "id": "occupational-coaching", "metadata": {}, "source": [ "\n", "\n", "## Map Stack to Surfaces\n", "\n", "During this step, the layers are assigned their respective `Series`. As `Layer1` and `Layer2` are parallel, they will be defined as one `Series`. However, they are not parallel to `Layer3` and `Layer4` (which are in itself parallel) and will therefore be defined in a separate series. We will also add a `Basement` here (`geo_model.add_surfaces('Basement')`). The order within one series also defines the age relations within this series and has to be according to the depositional events of the layers." ] }, { "cell_type": "code", "execution_count": null, "id": "ca6dfa3e", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:16.123172Z", "start_time": "2022-04-02T13:47:15.891195Z" } }, "outputs": [], "source": [ "gp.map_stack_to_surfaces(geo_model,\n", " {\n", " 'Strata1': ('Layer1', 'Layer2'), \n", " 'Strata2': ('Layer3', 'Layer4'),\n", " },\n", " remove_unused_series=True)\n", "geo_model.add_surfaces('Basement')\n", "geo_model.surfaces" ] }, { "cell_type": "code", "execution_count": null, "id": "4ce8d4ef", "metadata": {}, "outputs": [], "source": [ "geo_model.stack" ] }, { "cell_type": "markdown", "id": "directed-immigration", "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": "ee36f42b", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:16.549062Z", "start_time": "2022-04-02T13:47:16.127173Z" } }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "gp.plot_2d(geo_model, \n", " direction='z', \n", " show_lith=False, \n", " show_boundaries=False)\n", "plt.grid()" ] }, { "cell_type": "markdown", "id": "objective-standard", "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. \n", "\n", "The `pyvista` package requires the Visualization Toolkit (VTK) to be installed." ] }, { "cell_type": "code", "execution_count": null, "id": "03cfc42d", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:17.291101Z", "start_time": "2022-04-02T13:47:16.552063Z" } }, "outputs": [], "source": [ "gp.plot_3d(geo_model, \n", " image=False, \n", " plotter_type='basic', \n", " notebook=True)" ] }, { "cell_type": "markdown", "id": "elementary-camping", "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": "8e27b70d", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:21.664940Z", "start_time": "2022-04-02T13:47:17.294083Z" } }, "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": "innovative-cradle", "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": "5b7b2377", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:37.437247Z", "start_time": "2022-04-02T13:47:21.668943Z" } }, "outputs": [], "source": [ "sol = gp.compute_model(geo_model, \n", " compute_mesh=True)" ] }, { "cell_type": "markdown", "id": "protected-parcel", "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 horizontal layers in the one direction and the truncated layers in the other direction." ] }, { "cell_type": "code", "execution_count": null, "id": "eb54b87a", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:38.430323Z", "start_time": "2022-04-02T13:47:37.439246Z" } }, "outputs": [], "source": [ "gp.plot_2d(geo_model, \n", " direction=['x', 'x', 'y', 'y'], \n", " cell_number=[25, 50, 25, 75], \n", " show_topography=False, \n", " show_data=True)" ] }, { "cell_type": "markdown", "id": "18218288", "metadata": {}, "source": [ "Next to the lithology data, we can also plot the calculated scalar field." ] }, { "cell_type": "code", "execution_count": null, "id": "2f27b9a5", "metadata": {}, "outputs": [], "source": [ "gp.plot_2d(geo_model, direction='y', show_data=False, show_scalar=True, show_lith=False)" ] }, { "cell_type": "markdown", "id": "several-artwork", "metadata": {}, "source": [ "\n", "\n", "# Visualizing the computed model in 3D\n", "\n", "The computed model can be visualized in 3D using the `pyvista` library. Setting `notebook=False` will open an interactive windows and the model can be rotated and zooming is possible. " ] }, { "cell_type": "code", "execution_count": null, "id": "838f0e34", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T13:47:39.173131Z", "start_time": "2022-04-02T13:47:38.434317Z" } }, "outputs": [], "source": [ "gpv = gp.plot_3d(geo_model, \n", " image=False, \n", " show_topography=True,\n", " plotter_type='basic', \n", " notebook=True, \n", " show_lith=True)" ] }, { "cell_type": "markdown", "id": "smooth-characterization", "metadata": {}, "source": [ "\n", "# Conclusions\n", "\n", "This is the last notebook of the `Basic Modeling` module. After completing this module, you should be able to model parallel and non-parallel, folded, faulted, and unconformable layers.\n", "\n", "
\n", "In this tutorial, you have learnt the following:
\n", "- Get an understanding of how unconformities are modeled/displayed in GemPy
\n", "- How to build a simple model consisting of unconformable layers belonging to multiple Series
\n", "\n", "
\n", "\n", "\n", "\n", "# Outlook\n", "\n", "All following notebooks represent the main part of the `From Maps to Models` tutorial series. There, we also introduce the `GemGIS` library, which will be a huge part of the following notebooks extending your knowledge about spatial data processing and creating input data for the `GemPy` modeling. \n", "\n", "\n", "[Take me to the next notebook on Github](https://nbviewer.org/github/cgre-aachen/gemgis_data/blob/main/notebooks/00_introduction_to_working_with_gemgis.ipynb)\n", "\n", "[Take me to the next notebook locally](../00_introduction_to_working_with_gemgis.ipynb)\n", "\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 }