.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/real/Hecho.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_real_Hecho.py: Geomodeling benchmark: the "Hecho"-Model ======== This model is part of a geomodeling benchmaring effort. More information (and, hopefully, publication) coming. .. GENERATED FROM PYTHON SOURCE LINES 7-11 .. code-block:: Python import os import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 12-20 .. code-block:: Python # Aux imports import pandas as pn # Importing gempy import gempy as gp import gempy_viewer as gpv .. GENERATED FROM PYTHON SOURCE LINES 21-27 Loading surface points from repository: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ With pandas we can do it directly from the web and with the right args we can directly tidy the data in gempy style: .. GENERATED FROM PYTHON SOURCE LINES 29-58 .. code-block:: Python data_path = os.path.abspath('../../data/input_data/Hecho') dfs = [] # First stratigraphic data for letter in range(1, 10): dfs.append(pn.read_csv( filepath_or_buffer=data_path + '/H' + str(letter) + '.csv', sep=';', names=['X', 'Y', 'Z', 'surface', '_'], header=0 )) # Also faults for f in range(1, 4): fault_df = pn.read_csv( filepath_or_buffer=data_path + '/F' + str(f) + 'Line.csv', sep=';', names=['X', 'Y', 'Z'], header=0 ) fault_df['surface'] = 'f' + str(f) dfs.append(fault_df) # We put all the surfaces points together because is how gempy likes it: surface_points = pn.concat(dfs, sort=True) surface_points.reset_index(inplace=True, drop=False) surface_points.tail() .. raw:: html
index X Y Z _ surface
761 6 11.143734 -0.172893 1.53226 NaN f3
762 7 11.171513 0.284198 1.68442 NaN f3
763 8 11.159113 0.399711 1.81939 NaN f3
764 9 11.069008 0.032232 1.92030 NaN f3
765 10 10.885192 -0.428004 2.10412 NaN f3


.. GENERATED FROM PYTHON SOURCE LINES 59-61 Now we do the same with the orientations: .. GENERATED FROM PYTHON SOURCE LINES 63-85 .. code-block:: Python orientations = pn.read_csv( filepath_or_buffer=data_path + '/Dips.csv', sep=';', names=['X', 'Y', 'Z', 'G_x', 'G_z', '_'], header=0 ) # Orientation needs to belong to a surface. This is mainly to categorize to which series belong and to # use the same color orientations['surface'] = 0 # We fill the laking direction with a dummy value: orientations['G_y'] = 0 # Replace -99999.00000 with NaN orientations.replace(-99999.00000, np.nan, inplace=True) # Drop irrelevant columns orientations.drop(columns=['_'], inplace=True) # Remove rows containing NaN orientations.dropna(inplace=True) .. GENERATED FROM PYTHON SOURCE LINES 86-95 Data initialization: ~~~~~~~~~~~~~~~~~~~~ Suggested size of the axis-aligned modeling box: Origin: 0 -0.5 0 Maximum: 16 0.5 4.5 Suggested resolution: 0.05m (grid size 321 x 21 x 91) %% .. GENERATED FROM PYTHON SOURCE LINES 95-133 .. code-block:: Python surface_points_table: gp.data.SurfacePointsTable = gp.data.SurfacePointsTable.from_arrays( x=surface_points['X'].values, y=surface_points['Y'].values, z=surface_points['Z'].values, names=surface_points['surface'].values.astype(str) ) orientations_table: gp.data.OrientationsTable = gp.data.OrientationsTable.from_arrays( x=orientations['X'].values, y=orientations['Y'].values, z=orientations['Z'].values, G_x=orientations['G_x'].values, G_y=orientations['G_y'].values, G_z=orientations['G_z'].values, names=orientations['surface'].values.astype(str), name_id_map=surface_points_table.name_id_map # ! Make sure that ids and names are shared ) structural_frame: gp.data.StructuralFrame = gp.data.StructuralFrame.from_data_tables( surface_points=surface_points_table, orientations=orientations_table ) geo_model: gp.data.GeoModel = gp.create_geomodel( project_name='Moureze', extent=[0, 16, -0.5, 0.5, 0, 4.5], resolution=[321, 21, 91], structural_frame=structural_frame ) gp.set_section_grid( grid=geo_model.grid, section_dict={ 'section': ([0, 0], [16, 0], [321, 91]) }, ) .. rst-class:: sphx-glr-script-out .. code-block:: none Active grids: GridTypes.NONE|SECTIONS|DENSE .. raw:: html
start stop resolution dist
section [0, 0] [16, 0] [321, 91] 16.0


.. GENERATED FROM PYTHON SOURCE LINES 134-138 We need an orientation per series/fault. The faults does not have orientation so the easiest is to create an orientation from the surface points availablle: .. GENERATED FROM PYTHON SOURCE LINES 140-155 .. code-block:: Python f_names = ['f1', 'f2', 'f3'] for fn in f_names: element = geo_model.structural_frame.get_element_by_name(fn) new_orientations = gp.create_orientations_from_surface_points_coords( xyz_coords=element.surface_points.xyz ) gp.add_orientations( geo_model=geo_model, x=new_orientations.data['X'], y=new_orientations.data['Y'], z=new_orientations.data['Z'], pole_vector=new_orientations.grads, elements_names=fn ) .. GENERATED FROM PYTHON SOURCE LINES 156-158 Now we can see how the data looks so far: .. GENERATED FROM PYTHON SOURCE LINES 160-162 .. code-block:: Python gpv.plot_2d(geo_model) .. image-sg:: /examples/real/images/sphx_glr_Hecho_001.png :alt: Cell Number: mid Direction: y :srcset: /examples/real/images/sphx_glr_Hecho_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 163-165 By default all surfaces belong to one unique series. .. GENERATED FROM PYTHON SOURCE LINES 167-169 .. code-block:: Python geo_model.structural_frame .. raw:: html
Structural Groups: StructuralGroup:
Name:default_formation
Structural Relation:StackRelationType.ERODE
Elements:
StructuralElement:
Name:0

StructuralElement:
Name:0.78

StructuralElement:
Name:1.15

StructuralElement:
Name:1.9

StructuralElement:
Name:2.5

StructuralElement:
Name:3.1

StructuralElement:
Name:3.9

StructuralElement:
Name:4.4

StructuralElement:
Name:5.2

StructuralElement:
Name:f1

StructuralElement:
Name:f2

StructuralElement:
Name:f3
Fault Relations:
default_fo...
default_formation
True
False


.. GENERATED FROM PYTHON SOURCE LINES 170-172 We will need to separate with surface belong to each series: .. GENERATED FROM PYTHON SOURCE LINES 174-179 .. code-block:: Python gp.map_stack_to_surfaces( gempy_model=geo_model, mapping_object={'Fault1': 'f1', 'Fault2': 'f2', 'Fault3': 'f3'} ) .. raw:: html
Structural Groups: StructuralGroup:
Name:Fault1
Structural Relation:StackRelationType.ERODE
Elements:
StructuralElement:
Name:f1

StructuralGroup:
Name:Fault2
Structural Relation:StackRelationType.ERODE
Elements:
StructuralElement:
Name:f2

StructuralGroup:
Name:Fault3
Structural Relation:StackRelationType.ERODE
Elements:
StructuralElement:
Name:f3

StructuralGroup:
Name:default_formation
Structural Relation:StackRelationType.ERODE
Elements:
StructuralElement:
Name:0

StructuralElement:
Name:0.78

StructuralElement:
Name:1.15

StructuralElement:
Name:1.9

StructuralElement:
Name:2.5

StructuralElement:
Name:3.1

StructuralElement:
Name:3.9

StructuralElement:
Name:4.4

StructuralElement:
Name:5.2
Fault Relations:
Fault1Fault2Fault3default_fo...
Fault1
Fault2
Fault3
default_formation
True
False


.. GENERATED FROM PYTHON SOURCE LINES 180-183 However if we want the faults to offset the “Default series”, they will need to be more recent (higher on the pile). We can modify the order by: .. GENERATED FROM PYTHON SOURCE LINES 187-189 Lastly, so far we did not specify which series/faults are actula faults: .. GENERATED FROM PYTHON SOURCE LINES 191-196 .. code-block:: Python gp.set_is_fault( frame=geo_model, fault_groups=['Fault1', 'Fault2', 'Fault3'] ) .. raw:: html
Structural Groups: StructuralGroup:
Name:Fault1
Structural Relation:StackRelationType.FAULT
Elements:
StructuralElement:
Name:f1

StructuralGroup:
Name:Fault2
Structural Relation:StackRelationType.FAULT
Elements:
StructuralElement:
Name:f2

StructuralGroup:
Name:Fault3
Structural Relation:StackRelationType.FAULT
Elements:
StructuralElement:
Name:f3

StructuralGroup:
Name:default_formation
Structural Relation:StackRelationType.ERODE
Elements:
StructuralElement:
Name:0

StructuralElement:
Name:0.78

StructuralElement:
Name:1.15

StructuralElement:
Name:1.9

StructuralElement:
Name:2.5

StructuralElement:
Name:3.1

StructuralElement:
Name:3.9

StructuralElement:
Name:4.4

StructuralElement:
Name:5.2
Fault Relations:
Fault1Fault2Fault3default_fo...
Fault1
Fault2
Fault3
default_formation
True
False


.. GENERATED FROM PYTHON SOURCE LINES 197-201 The default range is always the diagonal of the extent. Since in this model data is very close we will need to reduce the range to 5-10% of that value: .. GENERATED FROM PYTHON SOURCE LINES 203-205 .. code-block:: Python geo_model.interpolation_options.kernel_options.range *= 0.2 .. GENERATED FROM PYTHON SOURCE LINES 206-214 Explanation of model characteristics and adjustments This model has characteristics that make it difficult to get the right default values: - It is large, and we want high resolution - Some series have a large conditional number (i.e., the model input is not very stable) To address these issues: - Reduce the chunk size during evaluation to trade speed for memory - Reduce the std of the error parameter in octree refinement, which evaluates fewer voxels but may leave some without refinement Enable debugging options to help tune these parameters. .. GENERATED FROM PYTHON SOURCE LINES 216-217 Setting verbose and condition number options for debugging .. GENERATED FROM PYTHON SOURCE LINES 217-218 .. code-block:: Python geo_model.interpolation_options.kernel_options.compute_condition_number = True .. GENERATED FROM PYTHON SOURCE LINES 219-222 Observations and parameter adjustments The octree refinement is making the octree grid almost dense, and smaller chunks are needed to avoid running out of memory. Adjusting parameters accordingly: .. GENERATED FROM PYTHON SOURCE LINES 222-225 .. code-block:: Python geo_model.interpolation_options.evaluation_options.evaluation_chunk_size = 50_000 .. GENERATED FROM PYTHON SOURCE LINES 226-234 .. code-block:: Python gp.compute_model( gempy_model=geo_model, engine_config=gp.data.GemPyEngineConfig( backend=gp.data.AvailableBackends.PYTORCH, dtype='float64' ) ) .. rst-class:: sphx-glr-script-out .. code-block:: none Setting Backend To: AvailableBackends.PYTORCH Condition number: 1546449.733468359. Chunking done: 206 chunks Condition number: 1545102.643054532. Chunking done: 258 chunks Condition number: 1447785.0114925415. Chunking done: 206 chunks Condition number: 40165630.352466166. Chunking done: 10548 chunks Chunking done: 14 chunks Chunking done: 14 chunks Chunking done: 21 chunks Chunking done: 21 chunks Chunking done: 80 chunks Chunking done: 80 chunks Chunking done: 11 chunks Chunking done: 14 chunks Chunking done: 11 chunks Chunking done: 550 chunks Chunking done: 38 chunks Chunking done: 35 chunks Chunking done: 33 chunks Chunking done: 8 chunks Chunking done: 10 chunks Chunking done: 8 chunks Chunking done: 389 chunks .. raw:: html
Solutions: 4 Octree Levels, 12 DualContouringMeshes


.. GENERATED FROM PYTHON SOURCE LINES 235-237 .. code-block:: Python gpv.plot_2d(geo_model, cell_number=[10], series_n=3, show_scalar=True) .. image-sg:: /examples/real/images/sphx_glr_Hecho_002.png :alt: Cell Number: 10 Direction: y :srcset: /examples/real/images/sphx_glr_Hecho_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 238-240 .. code-block:: Python gpv.plot_2d(geo_model, cell_number=[10], show_data=True) .. image-sg:: /examples/real/images/sphx_glr_Hecho_003.png :alt: Cell Number: 10 Direction: y :srcset: /examples/real/images/sphx_glr_Hecho_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 241-243 .. code-block:: Python gpv.plot_2d(geo_model, section_names=['section'], show_data=True) .. image-sg:: /examples/real/images/sphx_glr_Hecho_004.png :alt: section :srcset: /examples/real/images/sphx_glr_Hecho_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/leguark/TeamCity/work/3a8738c25f60c3c9/venv/lib/python3.10/site-packages/gempy_viewer/API/_plot_2d_sections_api.py:106: UserWarning: Section contacts not implemented yet. We need to pass scalar field for the sections grid warnings.warn( .. GENERATED FROM PYTHON SOURCE LINES 244-245 sphinx_gallery_thumbnail_number = 3 .. GENERATED FROM PYTHON SOURCE LINES 245-246 .. code-block:: Python gpv.plot_3d(geo_model, kwargs_plot_structured_grid={'opacity': .2}) .. image-sg:: /examples/real/images/sphx_glr_Hecho_005.png :alt: Hecho :srcset: /examples/real/images/sphx_glr_Hecho_005.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 38.634 seconds) .. _sphx_glr_download_examples_real_Hecho.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Hecho.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Hecho.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: Hecho.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_