.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorials/ch1_fundamentals/ch1_6_2d_visualization.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_6_2d_visualization.py: 1.6: 2D Visualization. ====================== .. GENERATED FROM PYTHON SOURCE LINES 7-19 .. code-block:: python3 # Importing GemPy import gempy as gp # Importing auxiliary libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt np.random.seed(1515) pd.set_option('precision', 2) .. GENERATED FROM PYTHON SOURCE LINES 20-23 Model interpolation ~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 25-26 Data Preparation .. GENERATED FROM PYTHON SOURCE LINES 26-32 .. code-block:: python3 data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/' geo_data = gp.create_data('viz_2d', [0, 1000, 0, 1000, 0, 1000], resolution=[10, 10, 10], path_o=data_path + "/data/input_data/jan_models/model5_orientations.csv", path_i=data_path + "/data/input_data/jan_models/model5_surface_points.csv") .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Active grids: ['regular'] .. GENERATED FROM PYTHON SOURCE LINES 33-35 .. code-block:: python3 gp.plot_2d(geo_data) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_001.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 36-38 .. code-block:: python3 geo_data.set_topography(d_z=(500, 1000)) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Active grids: ['regular' 'topography'] Grid Object. Values: array([[ 50. , 50. , 50. ], [ 50. , 50. , 150. ], [ 50. , 50. , 250. ], ..., [1000. , 777.77777778, 601.70645773], [1000. , 888.88888889, 547.79987061], [1000. , 1000. , 531.67197073]]) .. GENERATED FROM PYTHON SOURCE LINES 39-43 .. code-block:: python3 section_dict = {'section1': ([0, 0], [1000, 1000], [100, 80]), 'section2': ([800, 0], [800, 1000], [150, 100]), 'section3': ([50, 200], [100, 500], [200, 150])} .. GENERATED FROM PYTHON SOURCE LINES 44-47 .. code-block:: python3 geo_data.set_section_grid(section_dict) gp.plot.plot_section_traces(geo_data) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_002.png :alt: Cell Number: -1 Direction: z :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Active grids: ['regular' 'topography' 'sections'] .. GENERATED FROM PYTHON SOURCE LINES 48-50 .. code-block:: python3 geo_data.grid.sections .. raw:: html
start stop resolution dist
section1 [0, 0] [1000, 1000] [100, 80] 1414.21
section2 [800, 0] [800, 1000] [150, 100] 1000.00
section3 [50, 200] [100, 500] [200, 150] 304.14


.. GENERATED FROM PYTHON SOURCE LINES 51-53 .. code-block:: python3 gp.set_interpolator(geo_data, theano_optimizer='fast_compile') .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Setting kriging parameters to their default values. Compiling theano function... Level of Optimization: fast_compile Device: cpu Precision: float64 Number of faults: 0 Compilation Done! Kriging values: values range 1732.05 $C_o$ 71428.57 drift equations [3, 3] .. GENERATED FROM PYTHON SOURCE LINES 54-59 .. code-block:: python3 gp.map_stack_to_surfaces(geo_data, {"Fault_Series": 'fault', "Strat_Series": ('rock2', 'rock1')}) geo_data.set_is_fault(['Fault_Series']) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Fault colors changed. If you do not like this behavior, set change_color to False. .. raw:: html
order_series BottomRelation isActive isFault isFinite
Fault_Series 1 Fault True True False
Strat_Series 2 Erosion True False False
Basement 3 Erosion False False False


.. GENERATED FROM PYTHON SOURCE LINES 60-62 .. code-block:: python3 geo_data.get_active_grids() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none array(['regular', 'topography', 'sections'], dtype=' .. GENERATED FROM PYTHON SOURCE LINES 70-71 or .. GENERATED FROM PYTHON SOURCE LINES 73-75 .. code-block:: python3 gp.plot.plot_2d(geo_data, section_names=['section1']) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_004.png :alt: section1 :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 76-79 Plot 2d: Object oriented: ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 82-85 One plot ^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 87-91 .. code-block:: python3 p = gp.plot_2d(geo_data, section_names=[], direction=None, show=False) p.fig.show() .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_005.png :alt: ch1 6 2d visualization :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 92-100 .. code-block:: python3 p = gp.plot_2d(geo_data, section_names=[], direction=None, show=False) # -----new code------ sec_name = 'section1' s1 = p.add_section(sec_name) p.plot_data(s1, sec_name, projection_distance=200) p.fig.show() .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_006.png :alt: section1 :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 101-110 .. code-block:: python3 p = gp.plot_2d(geo_data, section_names=[], direction=None, show=False) sec_name = 'section1' s1 = p.add_section(sec_name) # -----new code------ p.plot_data(s1, sec_name, projection_distance=200) p.plot_contacts(s1, sec_name) p.fig.show() .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_007.png :alt: section1 :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 111-122 .. code-block:: python3 p = gp.plot_2d(geo_data, section_names=[], direction=None, show=False) sec_name = 'section1' s1 = p.add_section(sec_name) p.plot_data(s1, sec_name, projection_distance=200) p.plot_contacts(s1, sec_name) # -----new code------ p.plot_lith(s1, sec_name) p.plot_topography(s1, sec_name) p.fig.show() .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_008.png :alt: section1 :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 123-126 Several plots ^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 128-136 .. code-block:: python3 sec_name = 'section1' sec_name_2 = 'section3' p2 = gp.plot_2d(geo_data, n_axis=3, figsize=(15, 15), # General fig options section_names=[sec_name, 'topography'], cell_number=[3], # Defining the sections show_data=False, show_lith=False, show_scalar=False, show_boundaries=False) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_009.png :alt: section1, Geological map, Cell Number: 3 Direction: y :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 137-150 .. code-block:: python3 # Create the section. This loacte the axes and give the right # aspect ratio and labels p2 = gp.plot_2d(geo_data, n_axis=3, figsize=(15, 15), # General fig options section_names=[sec_name, 'topography'], cell_number=[3], # Defining the sections show_data=False, show_lith=False, show_scalar=False, show_boundaries=False, show=False) # -----new code------ s1 = p2.add_section(sec_name_2, ax_pos=224) p2.fig.show() .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_010.png :alt: section1, Geological map, Cell Number: 3 Direction: y, section3 :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 151-152 Axes 0 .. GENERATED FROM PYTHON SOURCE LINES 152-166 .. code-block:: python3 p2 = gp.plot_2d(geo_data, n_axis=3, figsize=(15, 15), # General fig options section_names=[sec_name, 'topography'], cell_number=[3], # Defining the sections show_data=False, show_lith=False, show_scalar=False, show_boundaries=False, show=False) s1 = p2.add_section(sec_name_2, ax_pos=224) # -----new code------ p2.plot_contacts(s1, sec_name_2) p2.plot_lith(s1, sec_name_2) p2.plot_data(s1, sec_name_2, projection_distance=200) p2.plot_topography(s1, sec_name_2) p2.fig.show() .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_011.png :alt: section1, Geological map, Cell Number: 3 Direction: y, section3 :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 167-168 Axes 1 .. GENERATED FROM PYTHON SOURCE LINES 168-186 .. code-block:: python3 # sphinx_gallery_thumbnail_number = 12 p2 = gp.plot_2d(geo_data, n_axis=3, figsize=(15, 15), # General fig options section_names=[sec_name, 'topography'], cell_number=[3], # Defining the sections show_data=False, show_lith=False, show_scalar=False, show_boundaries=False, show=False) s1 = p2.add_section(sec_name_2, ax_pos=224) p2.plot_contacts(s1, sec_name_2) p2.plot_lith(s1, sec_name_2) p2.plot_data(s1, sec_name_2, projection_distance=200) p2.plot_topography(s1, sec_name_2) # -----new code------ p2.plot_contacts(p2.axes[0], cell_number=3) p2.plot_scalar_field(p2.axes[0], cell_number=3, series_n=1) p2.fig.show() .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_012.png :alt: section1, Geological map, Cell Number: 3 Direction: y, section3 :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 187-188 Axes2 .. GENERATED FROM PYTHON SOURCE LINES 188-206 .. code-block:: python3 p2 = gp.plot_2d(geo_data, n_axis=3, figsize=(15, 15), # General fig options section_names=[sec_name, 'topography'], cell_number=[3], # Defining the sections show_data=False, show_lith=False, show_scalar=False, show_boundaries=False, show=False) s1 = p2.add_section(sec_name_2, ax_pos=224) p2.plot_contacts(s1, sec_name_2) p2.plot_lith(s1, sec_name_2) p2.plot_data(s1, sec_name_2, projection_distance=200) p2.plot_topography(s1, sec_name_2) p2.plot_contacts(p2.axes[0], cell_number=3) p2.plot_scalar_field(p2.axes[0], cell_number=3, series_n=1) # -----new code------ p2.plot_lith(p2.axes[1], 'topography') p2.plot_contacts(p2.axes[1], 'topography') p2.fig.show() .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_013.png :alt: section1, Geological map, Cell Number: 3 Direction: y, section3 :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 207-210 Plotting traces: '''''''''''''''' .. GENERATED FROM PYTHON SOURCE LINES 212-215 .. code-block:: python3 p2.plot_section_traces(p2.axes[1]) p2.fig.show() .. GENERATED FROM PYTHON SOURCE LINES 216-218 .. code-block:: python3 gp.plot.plot_section_traces(geo_data) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_014.png :alt: Cell Number: -1 Direction: z :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 219-222 Plot API -------- .. GENERATED FROM PYTHON SOURCE LINES 225-228 If nothing is passed, a Plot2D object is created and therefore you are in the same situation as above: .. GENERATED FROM PYTHON SOURCE LINES 230-232 .. code-block:: python3 p3 = gp.plot_2d(geo_data) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_015.png :alt: Cell Number: mid Direction: y :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 233-236 Alternatively you can pass section\_names, cell\_numbers + direction or any combination of the above: .. GENERATED FROM PYTHON SOURCE LINES 238-240 .. code-block:: python3 gp.plot_2d(geo_data, section_names=['topography']) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_016.png :alt: Geological map :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 241-243 .. code-block:: python3 gp.plot_2d(geo_data, section_names=['section1']) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_017.png :alt: section1 :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 244-246 .. code-block:: python3 gp.plot_2d(geo_data, section_names=['section1', 'section2']) .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_018.png :alt: section1, section2 :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 247-249 .. code-block:: python3 gp.plot_2d(geo_data, figsize=(15, 15), section_names=['section1', 'section2', 'topography'], cell_number='mid') .. image:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_6_2d_visualization_019.png :alt: section1, section2, Geological map, Cell Number: mid Direction: y :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 9.016 seconds) .. _sphx_glr_download_tutorials_ch1_fundamentals_ch1_6_2d_visualization.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_6_2d_visualization.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ch1_6_2d_visualization.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_