.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/south_model/1_setting_up_south.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_south_model_1_setting_up_south.py: Model 1 - Reading GeoTop Data ============================= This tutorial demonstrates how to read borehole data using GeoTop and set up the stratigraphic pile using GemPy. .. GENERATED FROM PYTHON SOURCE LINES 9-13 **Step 1: Import Necessary Libraries** Here we import the libraries necessary for handling the environment variables, numerical operations, data handling with pandas, and the specific functions from `subsurface` and `gempy` packages. .. GENERATED FROM PYTHON SOURCE LINES 13-25 .. code-block:: default import dotenv import os import numpy as np import pandas as pd import subsurface import gempy as gp from gempy_geotop.model_constructor import initialize_geomodel, add_fault_from_unstructured_data from gempy_geotop.geotop_stratigraphy import stratigraphy_pile, color_elements from gempy_geotop.reader import read_all_boreholes_data_to_df, read_all_fault_data_to_mesh, add_raw_faults_to_mesh from gempy_geotop.utils import plot_geotop .. GENERATED FROM PYTHON SOURCE LINES 26-30 **Step 2: Load Environment Variables** Environment variables are a secure way to manage configurations and sensitive data. Here we load the environment variables that specify the path to the borehole data. .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. code-block:: default dotenv.load_dotenv() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 34-38 **Step 3: Read Borehole Data** We read the borehole data from the specified directory. This data will be used to initialize and configure the geological model in GemPy. .. GENERATED FROM PYTHON SOURCE LINES 38-43 .. code-block:: default data_south: pd.DataFrame = read_all_boreholes_data_to_df( path=os.getenv('BOREHOLES_SOUTH_FOLDER') ) .. GENERATED FROM PYTHON SOURCE LINES 44-48 **Step 4: Initialize GemPy Model** Using the borehole data, we initialize the GemPy model. We also slice the formations to consider only the first 10, adjusting the model's complexity and processing time. .. GENERATED FROM PYTHON SOURCE LINES 48-53 .. code-block:: default geo_model = initialize_geomodel(data_south) slice_formations = slice(0, 10) # Slice the formations to the first 10 depth = -500.0 # Define a fixed depth for the model's base .. rst-class:: sphx-glr-script-out .. code-block:: none [120071, 209998, 370060, 419970, -901.5, 48.68] .. GENERATED FROM PYTHON SOURCE LINES 54-58 **Step 5: Map Stratigraphy and Color Elements** Here we map the stratigraphy pile to the GemPy model and assign colors to different geological units for better visualization. .. GENERATED FROM PYTHON SOURCE LINES 58-65 .. code-block:: default gp.map_stack_to_surfaces( gempy_model=geo_model, mapping_object=stratigraphy_pile ) color_elements(geo_model.structural_frame.structural_elements) .. rst-class:: sphx-glr-script-out .. code-block:: none Could not find element 'VE' in any group. Could not find element 'RU' in any group. Could not find element 'TO' in any group. Could not find element 'DO' in any group. Could not find element 'LA' in any group. Could not find element 'HT' in any group. Could not find element 'HO' in any group. Could not find element 'MT' in any group. Could not find element 'GU' in any group. Could not find element 'VA' in any group. Could not find element 'AK' in any group. .. GENERATED FROM PYTHON SOURCE LINES 66-70 **Step 6: Configure and Set Grid** We set up the grid for the model, defining its spatial extent and resolution based on the surface points and a specified depth. .. GENERATED FROM PYTHON SOURCE LINES 70-85 .. code-block:: default geo_model.structural_frame.structural_groups = geo_model.structural_frame.structural_groups[slice_formations] xyz = geo_model.surface_points_copy.xyz extent = [ xyz[:, 0].min(), xyz[:, 0].max(), xyz[:, 1].min(), xyz[:, 1].max(), depth, xyz[:, 2].max() ] geo_model.grid.regular_grid.set_regular_grid( extent=extent, resolution=np.array([50, 50, 50]) ) .. rst-class:: sphx-glr-script-out .. code-block:: none array([[ 1.2097027e+05, 3.7055910e+05, -4.9451320e+02], [ 1.2097027e+05, 3.7055910e+05, -4.8353960e+02], [ 1.2097027e+05, 3.7055910e+05, -4.7256600e+02], ..., [ 2.0909873e+05, 4.1947090e+05, 2.1246000e+01], [ 2.0909873e+05, 4.1947090e+05, 3.2219600e+01], [ 2.0909873e+05, 4.1947090e+05, 4.3193200e+01]]) .. GENERATED FROM PYTHON SOURCE LINES 86-90 **Step 7: Set Sections for Visualization** We define specific sections of the model for detailed visualization. These sections help in analyzing the model from different perspectives and depths. .. GENERATED FROM PYTHON SOURCE LINES 90-100 .. code-block:: default gp.set_section_grid( grid=geo_model.grid, section_dict={ 'section1': ([112873, 390934], [212359, 390346], [100, 100]), 'section2': ([121660, 416391], [196740, 416618], [100, 100]), 'section3': ([160560, 414164], [159917, 370427], [100, 100]) } ) .. rst-class:: sphx-glr-script-out .. code-block:: none Active grids: ['sections'] .. raw:: html
start stop resolution dist
section1 [112873, 390934] [212359, 390346] [100, 100] 99487.737636
section2 [121660, 416391] [196740, 416618] [100, 100] 75080.343160
section3 [160560, 414164] [159917, 370427] [100, 100] 43741.726281


.. GENERATED FROM PYTHON SOURCE LINES 101-105 **Step 8: Read and Process Fault Data** We read fault data, slice it for processing the first few entries, and integrate these faults into the geological model. .. GENERATED FROM PYTHON SOURCE LINES 105-120 .. code-block:: default all_unstruct: list[subsurface.UnstructuredData] = read_all_fault_data_to_mesh( path=os.getenv('FAULTS_SOUTH_FOLDER') ) slice_faults = slice(0, 3) # Slice the faults to the first 3 for simplicity subset = all_unstruct[slice_faults] # Take the first 3 faults for e, struct in enumerate(subset): add_fault_from_unstructured_data( unstruct=struct, geo_model=geo_model, name=f"fault{e}" ) .. GENERATED FROM PYTHON SOURCE LINES 121-125 **Step 9: Visualize the Model** Finally, we plot the 3D visualization of the geological model, showing both the stratigraphy and the faults. Adjust the vertical exaggeration for better depth perception. .. GENERATED FROM PYTHON SOURCE LINES 125-129 .. code-block:: default plot_3d = plot_geotop(geo_model, ve=100, image_3d=False, show=False) add_raw_faults_to_mesh(subset, plot_3d) plot_3d.p.show() .. image-sg:: /examples/south_model/images/sphx_glr_1_setting_up_south_001.png :alt: 1 setting up south :srcset: /examples/south_model/images/sphx_glr_1_setting_up_south_001.png :class: sphx-glr-single-img .. image-sg:: /examples/south_model/images/sphx_glr_1_setting_up_south_002.png :alt: section1, section2, section3 :srcset: /examples/south_model/images/sphx_glr_1_setting_up_south_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.776 seconds) .. _sphx_glr_download_examples_south_model_1_setting_up_south.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 1_setting_up_south.py <1_setting_up_south.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 1_setting_up_south.ipynb <1_setting_up_south.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_