Note
Click here to download the full example code
Reading Simple GemPy model in Subsurface¶
import sys
sys.path.insert(0, 'subsurface/')
import pooch
import subsurface as ss
import subsurface.reader.read_netcdf
Single surface¶
# Pull gempy model
model_files = pooch.retrieve(
url="https://github.com/cgre-aachen/gempy_data/raw/master/"
"data/subsurface/example1.zip",
known_hash="fb79a63eeb874cf0cdca557106c62c67eace23811db5935e57c3448fed7f8978",
processor=pooch.Unzip()
)
# # %%
fname, = [i for i in model_files if "meshes.nc" in i]
dataset = ss.reader.read_netcdf.read_unstruct(fname)
Out:
Downloading data from 'https://github.com/cgre-aachen/gempy_data/raw/master/data/subsurface/example1.zip' to file '/home/runner/.cache/pooch/2ff36b994aa925b842ddd264256335a9-example1.zip'.
Unzipping contents of '/home/runner/.cache/pooch/2ff36b994aa925b842ddd264256335a9-example1.zip' to '/home/runner/.cache/pooch/2ff36b994aa925b842ddd264256335a9-example1.zip.unzip'
/home/runner/work/subsurface/subsurface/subsurface/reader/read_netcdf.py:18: UserWarning: Trying loading legacy files.
warnings.warn("Trying loading legacy files.")
Out:
{}
/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pyvista/core/dataset.py:1332: PyvistaDeprecationWarning: Use of `cell_arrays` is deprecated. Use `cell_data` instead.
warnings.warn(
/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pyvista/core/dataset.py:1192: PyvistaDeprecationWarning: Use of `point_arrays` is deprecated. Use `point_data` instead.
warnings.warn(
<pyvista.plotting.plotting.Plotter object at 0x7f62fb7a2a90>
Four Layers¶
# Pull gempy model
model_files_2 = pooch.retrieve(
url="https://github.com/cgre-aachen/gempy_data/raw/master/data/gempy_models/Kim.zip",
known_hash="f530a88351ed0e38673c6937161c59a2f69df92202e14c1e5d5729ed5d72a323",
processor=pooch.Unzip()
)
Out:
Downloading data from 'https://github.com/cgre-aachen/gempy_data/raw/master/data/gempy_models/Kim.zip' to file '/home/runner/.cache/pooch/823c7ed465808f92b59f69c1da6e242b-Kim.zip'.
Unzipping contents of '/home/runner/.cache/pooch/823c7ed465808f92b59f69c1da6e242b-Kim.zip' to '/home/runner/.cache/pooch/823c7ed465808f92b59f69c1da6e242b-Kim.zip.unzip'
Triangular meshes¶
fname, = [i for i in model_files_2 if "meshes.nc" in i]
gempy_tri_mesh_unstruct = ss.reader.read_netcdf.read_unstruct(fname)
tri_surf = ss.TriSurf(gempy_tri_mesh_unstruct)
mesh = ss.visualization.to_pyvista_mesh(tri_surf)
ss.visualization.pv_plot([mesh])
Out:
/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pyvista/core/dataset.py:1332: PyvistaDeprecationWarning: Use of `cell_arrays` is deprecated. Use `cell_data` instead.
warnings.warn(
/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pyvista/core/dataset.py:1192: PyvistaDeprecationWarning: Use of `point_arrays` is deprecated. Use `point_data` instead.
warnings.warn(
<pyvista.plotting.plotting.Plotter object at 0x7f62fb799700>
Regular grid¶
fname, = [i for i in model_files_2 if "regular_grid.nc" in i]
gempy_struct = ss.reader.read_netcdf.read_struct(fname)
regular_grid = ss.StructuredGrid(gempy_struct)
pyvista_mesh = ss.visualization.to_pyvista_grid(regular_grid,
data_set_name='property_matrix',
attribute_slice={'Properties': 'id'}
)
ss.visualization.pv_plot([pyvista_mesh])
Out:
/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pyvista/core/dataset.py:1192: PyvistaDeprecationWarning: Use of `point_arrays` is deprecated. Use `point_data` instead.
warnings.warn(
<pyvista.plotting.plotting.Plotter object at 0x7f62fb3a64f0>
pyvista_mesh = ss.visualization.to_pyvista_grid(regular_grid,
data_set_name='block_matrix',
attribute_slice={'Properties': 'id',
'Features': 'Default series'})
ss.visualization.pv_plot([pyvista_mesh])
Out:
/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pyvista/core/dataset.py:1192: PyvistaDeprecationWarning: Use of `point_arrays` is deprecated. Use `point_data` instead.
warnings.warn(
<pyvista.plotting.plotting.Plotter object at 0x7f62fb3a6c70>
Total running time of the script: ( 0 minutes 10.621 seconds)