.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorials/ch1_fundamentals/ch1_3c_topography.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_tutorials_ch1_fundamentals_ch1_3c_topography.py: 1.3c: Adding topography to geological models ============================================ .. GENERATED FROM PYTHON SOURCE LINES 8-13 .. code-block:: Python import gempy as gp import gempy_viewer as gpv import numpy as np import os .. GENERATED FROM PYTHON SOURCE LINES 14-17 1. The common procedure to set up a model: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 19-32 .. code-block:: Python data_path = os.path.abspath('../../') geo_model: gp.data.GeoModel = gp.create_geomodel( project_name='Single_layer_topo', extent=[450000, 460000, 70000, 80000, -1000, 500], resolution=[50, 50, 50], refinement=4, importer_helper=gp.data.ImporterHelper( path_to_orientations=data_path + "/data/input_data/tut-ch1-7/onelayer_orient.csv", path_to_surface_points=data_path + "/data/input_data/tut-ch1-7/onelayer_interfaces.csv", ) ) .. GENERATED FROM PYTHON SOURCE LINES 35-42 .. code-block:: Python gp.set_section_grid( grid=geo_model.grid, section_dict={ 'section1': ([450000, 75000], [460000, 75500], [100, 100]), } ) .. rst-class:: sphx-glr-script-out .. code-block:: none Active grids: ['regular' 'sections'] .. raw:: html
start stop resolution dist
section1 [450000, 75000] [460000, 75500] [100, 100] 10012.492197


.. GENERATED FROM PYTHON SOURCE LINES 43-46 2. Adding topography ~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 49-59 2 a. Load from raster file ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. admonition:: Coming soon: Importing raster data This feature is not yet available in the current version of GemPy. Probably will be moved to `subsurface` since coupling it with the geological model does not add much value. %% .. GENERATED FROM PYTHON SOURCE LINES 59-77 .. code-block:: Python # This is to make it work in sphinx gallery # cwd = os.getcwd() # if not 'examples' in cwd: # path_dir = os.getcwd() + '/examples/tutorials/ch5_probabilistic_modeling' # else: # path_dir = cwd # # fp = path_dir + "/../../data/input_data/tut-ch1-7/bogota.tif" # # # %% # geo_model.set_topography(source='gdal', filepath=fp) # gp.plot_2d(geo_model, show_topography=True, section_names=['topography'], show_lith=False, # show_boundaries=False, # kwargs_topography={'cmap': 'gray', 'norm': None} # ) # plt.show() .. GENERATED FROM PYTHON SOURCE LINES 78-81 2 b. create fun topography ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 84-89 If there is no topography file, but you think that your model with topography would look significantly cooler, you can use gempys :meth:`set_topography ` function to generate a random topography based on a fractal grid: .. GENERATED FROM PYTHON SOURCE LINES 91-92 sphinx_gallery_thumbnail_number = 2 .. GENERATED FROM PYTHON SOURCE LINES 92-96 .. code-block:: Python gp.set_topography_from_random(grid=geo_model.grid) gpv.plot_2d(geo_model, show_topography=True, section_names=['topography']) .. image-sg:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_3c_topography_001.png :alt: Geological map :srcset: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_3c_topography_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [200. 500.] Active grids: ['regular' 'topography' 'sections'] .. GENERATED FROM PYTHON SOURCE LINES 97-117 It has additional keywords to play around with: * fd: fractal dimension: defaults to 2.0. The higher (try 2.9), the rougher the landscape will be. * d\_z: height difference: If none, last 20% of the model in z direction. * extent: extent in xy direction. If none, ``geo_model.grid.extent`` is used. * resolution: resolution of the topography array. If none, ``geo_model.grid.resoution`` is used. Increasing the resolution leads to much nicer geological maps! .. GENERATED FROM PYTHON SOURCE LINES 119-126 .. code-block:: Python gp.set_topography_from_random( grid=geo_model.grid, fractal_dimension=1.9, d_z=np.array([0, 250]), topography_resolution=np.array([200, 200]) ) .. rst-class:: sphx-glr-script-out .. code-block:: none Active grids: ['regular' 'topography' 'sections'] .. GENERATED FROM PYTHON SOURCE LINES 127-130 Compute model ~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 132-134 .. code-block:: Python gp.compute_model(geo_model) .. rst-class:: sphx-glr-script-out .. code-block:: none Setting Backend To: AvailableBackends.numpy /home/leguark/gempy/gempy/core/data/geo_model.py:118: UserWarning: Both octree levels and resolution are set. The default grid for the `raw_array_solution`and plots will be the dense regular grid. To use octrees instead, set resolution to None in the regular grid. warnings.warn("Both octree levels and resolution are set. The default grid for the `raw_array_solution`" .. raw:: html
Solutions: 4 Octree Levels, 1 DualContouringMeshes


.. GENERATED FROM PYTHON SOURCE LINES 135-141 Visualize: ^^^^^^^^^^ Now, the solutions object does also contain the computed geological map. It can be visualized using the 2D and 3D plotting functionality: .. GENERATED FROM PYTHON SOURCE LINES 143-145 .. code-block:: Python gpv.plot_2d(geo_model, show_topography=True, section_names=['topography'], show_boundaries=False, show_data=True) .. image-sg:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_3c_topography_002.png :alt: Geological map :srcset: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_3c_topography_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 146-148 .. code-block:: Python gpv.plot_2d(geo_model, show_topography=True, section_names=['section1']) .. image-sg:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_3c_topography_003.png :alt: section1 :srcset: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_3c_topography_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/leguark/gempy_viewer/gempy_viewer/API/_plot_2d_sections_api.py:104: UserWarning: Section contacts not implemented yet. We need to pass scalar field for the sections grid warnings.warn( .. GENERATED FROM PYTHON SOURCE LINES 149-158 .. code-block:: Python g3d = gpv.plot_3d( model=geo_model, show_topography=True, show_lith=False, show_surfaces=False, show_results=False, ve=5 ) .. image-sg:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_3c_topography_004.png :alt: ch1 3c topography :srcset: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_3c_topography_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 159-160 sphinx_gallery_thumbnail_number = 3 .. GENERATED FROM PYTHON SOURCE LINES 160-167 .. code-block:: Python g3d = gpv.plot_3d( model=geo_model, show_topography=True, show_lith=True, show_surfaces=True, ve=5 ) .. image-sg:: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_3c_topography_005.png :alt: ch1 3c topography :srcset: /tutorials/ch1_fundamentals/images/sphx_glr_ch1_3c_topography_005.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.617 seconds) .. _sphx_glr_download_tutorials_ch1_fundamentals_ch1_3c_topography.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ch1_3c_topography.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ch1_3c_topography.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_