.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorials/ch1_fundamentals/ch1_5_fault_relations.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_tutorials_ch1_fundamentals_ch1_5_fault_relations.py: 1.5: Fault relations ==================== .. GENERATED FROM PYTHON SOURCE LINES 8-9 Importing gempy .. GENERATED FROM PYTHON SOURCE LINES 9-23 .. code-block:: python3 import gempy as gp # Aux imports import numpy as np import pandas as pd import os # Importing the function to find the interface from gempy.utils.input_manipulation import find_interfaces_from_block_bottoms import matplotlib.pyplot as plt np.random.seed(1515) pd.set_option('precision', 2) .. GENERATED FROM PYTHON SOURCE LINES 24-26 We import a model from an existing folder. .. GENERATED FROM PYTHON SOURCE LINES 28-39 .. code-block:: python3 cwd = os.getcwd() if 'examples' not in cwd: data_path = os.getcwd() + '/examples/' else: data_path = cwd + '/../../' geo_model = gp.load_model(r'Tutorial_ch1-9a_Fault_relations', path=data_path + 'data/gempy_models/Tutorial_ch1-9a_Fault_relations', recompile=True) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Active grids: ['regular'] Setting kriging parameters to their default values. Compiling theano function... Level of Optimization: fast_compile Device: cpu Precision: float64 Number of faults: 1 Compilation Done! Kriging values: values range 1732.05 $C_o$ 71428.57 drift equations [3, 3, 3, 3] nugget grad 0.01 nugget scalar 0.0 .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: python3 geo_model.faults.faults_relations_df .. raw:: html
fault_series1 series2 series1 basement_series
fault_series1 False False True True
series2 False False False False
series1 False False False False
basement_series False False False False


.. GENERATED FROM PYTHON SOURCE LINES 43-45 .. code-block:: python3 geo_model.faults .. raw:: html
order_series BottomRelation isFault isFinite isActive
fault_series1 1 Fault True False True
series2 2 Erosion False False True
series1 3 Erosion False False True
basement_series 4 Erosion False False False


.. GENERATED FROM PYTHON SOURCE LINES 46-48 .. code-block:: python3 geo_model.surfaces .. raw:: html
surface series order_surfaces color id
5 fault1 fault_series1 1 #015482 1
7 rock5 series2 1 #9f0052 2
6 rock4 series2 2 #ffbe00 3
0 rock3 series1 1 #728f02 4
3 rock2 series1 2 #443988 5
1 rock1 series1 3 #ff3f20 6
4 basement basement_series 1 #325916 7


.. GENERATED FROM PYTHON SOURCE LINES 49-51 .. code-block:: python3 gp.compute_model(geo_model, compute_mesh=False) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Lithology ids [7. 7. 7. ... 2. 2. 2.] .. GENERATED FROM PYTHON SOURCE LINES 52-54 .. code-block:: python3 geo_model.solutions.lith_block .. rst-class:: sphx-glr-script-out Out: .. code-block:: none array([7., 7., 7., ..., 2., 2., 2.]) .. GENERATED FROM PYTHON SOURCE LINES 55-57 .. code-block:: python3 geo_model.solutions.block_matrix[0] .. rst-class:: sphx-glr-script-out Out: .. code-block:: none array([[2., 2., 2., ..., 1., 1., 1.]]) .. GENERATED FROM PYTHON SOURCE LINES 58-64 .. code-block:: python3 gp.plot_2d(geo_model, cell_number=[25], show_data=True) # Graben example # -------------- .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_001.png :alt: Cell Number: 25 Direction: y :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 65-70 .. code-block:: python3 geo_model_graben = gp.load_model(r'Tutorial_ch1-9b_Fault_relations', path=data_path + 'data/gempy_models/Tutorial_ch1-9b_Fault_relations', recompile=True) geo_model.meta.project_name = "Faults_relations" .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Active grids: ['regular'] Setting kriging parameters to their default values. Compiling theano function... Level of Optimization: fast_compile Device: cpu Precision: float64 Number of faults: 2 Compilation Done! Kriging values: values range 1732.05 $C_o$ 71428.57 drift equations [3, 3, 3, 3] nugget grad 0.01 nugget scalar 0.0 .. GENERATED FROM PYTHON SOURCE LINES 71-73 .. code-block:: python3 geo_model_graben.surfaces .. raw:: html
surface series order_surfaces color id
7 fault2 fault_series2 1 #015482 1
5 fault1 fault_series1 1 #9f0052 2
6 rock4 series1 1 #ffbe00 3
0 rock3 series1 2 #728f02 4
3 rock2 series1 3 #443988 5
1 rock1 series1 4 #ff3f20 6
4 basement basement_series 1 #325916 7


.. GENERATED FROM PYTHON SOURCE LINES 74-76 .. code-block:: python3 geo_model_graben.additional_data .. raw:: html
values
Structure isLith True
isFault True
number faults 2
number surfaces 6
number series 4
number surfaces per series [1, 1, 4, 0]
len surfaces surface_points [9, 9, 15, 15, 12, 12]
len series surface_points [9, 9, 54, 0]
len series orientations [1, 1, 10, 0]
Options dtype float64
output geology
theano_optimizer fast_compile
device cpu
verbosity [0]
Kriging range 1732.05
$C_o$ 71428.57
drift equations [3, 3, 3, 3]
nugget grad 0.01
nugget scalar 0.0
Rescaling rescaling factor 1600.0
centers [500.0, 500.0, -650.0]


.. GENERATED FROM PYTHON SOURCE LINES 77-79 Displaying the input data: .. GENERATED FROM PYTHON SOURCE LINES 81-83 .. code-block:: python3 gp.plot_2d(geo_model_graben, direction='y') .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_002.png :alt: Cell Number: mid Direction: y :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 84-87 .. code-block:: python3 gp.plot_2d(geo_model_graben, direction='x') .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_003.png :alt: Cell Number: mid Direction: x :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 88-90 .. code-block:: python3 geo_model_graben.stack .. raw:: html
order_series BottomRelation isFault isFinite isActive
fault_series2 1 Fault True False True
fault_series1 2 Fault True False True
series1 3 Erosion False False True
basement_series 4 Erosion False False False


.. GENERATED FROM PYTHON SOURCE LINES 91-93 .. code-block:: python3 geo_model_graben.faults .. raw:: html
order_series BottomRelation isFault isFinite isActive
fault_series2 1 Fault True False True
fault_series1 2 Fault True False True
series1 3 Erosion False False True
basement_series 4 Erosion False False False


.. GENERATED FROM PYTHON SOURCE LINES 94-96 .. code-block:: python3 geo_model_graben.faults.faults_relations_df .. raw:: html
fault_series2 fault_series1 series1 basement_series
fault_series2 False True True True
fault_series1 False False True True
series1 False False False False
basement_series False False False False


.. GENERATED FROM PYTHON SOURCE LINES 97-99 .. code-block:: python3 gp.compute_model(geo_model_graben) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Lithology ids [7. 7. 7. ... 3. 3. 3.] .. GENERATED FROM PYTHON SOURCE LINES 100-102 .. code-block:: python3 gp.plot_2d(geo_model_graben, cell_number=[25], show_data=True) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_004.png :alt: Cell Number: 25 Direction: y :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 103-104 sphinx_gallery_thumbnail_number = 5 .. GENERATED FROM PYTHON SOURCE LINES 104-106 .. code-block:: python3 gp.plot_3d(geo_model_graben, image=True) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_005.png :alt: ch1 5 fault relations :class: sphx-glr-single-img .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_006.png :alt: ch1 5 fault relations :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 107-111 .. code-block:: python3 gp.plot_2d(geo_model_graben, cell_number=[25], show_scalar=True, series_n=0) gp.plot_2d(geo_model_graben, cell_number=[25], show_scalar=True, series_n=1) .. rst-class:: sphx-glr-horizontal * .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_007.png :alt: Cell Number: 25 Direction: y :class: sphx-glr-multi-img * .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_008.png :alt: Cell Number: 25 Direction: y :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 112-115 Offset parameter (Experimental) ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 117-121 .. code-block:: python3 geo_model_graben._interpolator.theano_graph.offset.set_value(1) gp.compute_model(geo_model_graben, compute_mesh=False) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Lithology ids [7. 7. 7. ... 3. 3. 3.] .. GENERATED FROM PYTHON SOURCE LINES 122-125 .. code-block:: python3 gp.plot_2d(geo_model_graben, block=geo_model_graben.solutions.block_matrix[1, 0, :125000], show_data=True) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_009.png :alt: Cell Number: mid Direction: y :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 126-128 .. code-block:: python3 gp.plot_2d(geo_model_graben, series_n=2, show_scalar=True) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_010.png :alt: Cell Number: mid Direction: y :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 129-131 .. code-block:: python3 geo_model_graben.solutions.scalar_field_matrix[1] .. rst-class:: sphx-glr-script-out Out: .. code-block:: none array([0.17363373, 0.1848186 , 0.19600352, ..., 1.36450254, 1.37569005, 1.38687763]) .. GENERATED FROM PYTHON SOURCE LINES 132-139 Finding the faults intersection: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sometimes we need to find the voxels that contain the each fault. To do so we can use gempy's functionality to find interfaces as follows. Lets use the first fault as an example: .. GENERATED FROM PYTHON SOURCE LINES 141-145 .. code-block:: python3 gp.plot_2d(geo_model_graben, regular_grid=geo_model_graben.solutions.block_matrix[0, 0, :125000], show_data=True) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_011.png :alt: Cell Number: mid Direction: y :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 146-147 Remember the fault block is stored on: .. GENERATED FROM PYTHON SOURCE LINES 147-149 .. code-block:: python3 geo_model_graben.solutions.block_matrix[0, 0, :125000] .. rst-class:: sphx-glr-script-out Out: .. code-block:: none array([1., 1., 1., ..., 2., 2., 2.]) .. GENERATED FROM PYTHON SOURCE LINES 150-152 Now we can find where is the intersection of the values 1 by calling the following function. This will return Trues on those voxels on the intersection .. GENERATED FROM PYTHON SOURCE LINES 152-155 .. code-block:: python3 intersection = find_interfaces_from_block_bottoms( geo_model_graben.solutions.block_matrix[0, 0, :125000].reshape(50, 50, 50), 1, shift=1) .. GENERATED FROM PYTHON SOURCE LINES 156-157 We can manually plotting together to see exactly what we have done .. GENERATED FROM PYTHON SOURCE LINES 157-164 .. code-block:: python3 ax = gp.plot_2d(geo_model_graben, block=geo_model_graben.solutions.block_matrix[0, 0, :125000], show_data=True, show=False) plt.imshow(intersection[:, 25, :].T, origin='lower', extent=(0, 1000, -1000, 0), alpha=.5) plt.show() gp.save_model(geo_model) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_5_fault_relations_012.png :alt: Cell Number: mid Direction: y :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none True .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 19.931 seconds) .. _sphx_glr_download_tutorials_ch1_fundamentals_ch1_5_fault_relations.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ch1_5_fault_relations.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ch1_5_fault_relations.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_