Skip to content

Commit 0f3f582

Browse files
committed
[ENH] Add 3D visualization tutorial and Graben example model
A new tutorial on 3D visualization has been added in fundamentals section. Moreover, a new 'Graben' model example has been included in 'gempy' library's example models. The tutorial script includes importing the necessary libraries, loading the example geology model, basic plotting API commands and data visualizations.
1 parent 4c555f6 commit 0f3f582

File tree

4 files changed

+112
-1
lines changed

4 files changed

+112
-1
lines changed

examples/tutorials/ch1_fundamentals/__init__.py

Whitespace-only changes.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"""
2+
1.7: 3-D Visualization
3+
======================
4+
5+
"""
6+
7+
# %%
8+
# Importing GemPy
9+
import gempy as gp
10+
import gempy_viewer as gpv
11+
from gempy import generate_example_model
12+
from gempy.core.data.enumerators import ExampleModel
13+
14+
# %%
15+
# Loading an example geomodel
16+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
17+
#
18+
19+
# %%
20+
21+
22+
geo_model = generate_example_model(ExampleModel.GRABEN)
23+
24+
gp.compute_model(geo_model)
25+
26+
# %%
27+
# Basic plotting API
28+
# ------------------
29+
#
30+
31+
32+
# %%
33+
# Data plot
34+
# ~~~~~~~~~
35+
#
36+
37+
# %%
38+
gpv.plot_3d(
39+
model=geo_model,
40+
show_surfaces=False,
41+
show_data=True,
42+
show_lith=False,
43+
image=False
44+
)
45+
46+
# %%
47+
# Geomodel plot
48+
# ~~~~~~~~~~~~~
49+
#
50+
51+
# %%
52+
gpv.plot_3d(geo_model, image=False)
53+
54+
# %%
55+
56+
# sphinx_gallery_thumbnail_number = 2
57+
gpv = gpv.plot_3d(
58+
model=geo_model,
59+
plotter_type='basic',
60+
off_screen=False,
61+
show_topography=True,
62+
show_scalar=False,
63+
show_lith=True,
64+
kwargs_plot_structured_grid={'opacity': .5}
65+
)

gempy/API/examples_generator.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import numpy as np
1+
import os
2+
3+
import numpy as np
24

35
import gempy as gp
46
from gempy_engine.core.data.stack_relation_type import StackRelationType
57
from gempy.core.data.enumerators import ExampleModel
68

79

10+
11+
812
def generate_example_model(example_model: ExampleModel, compute_model: bool = True) -> gp.data.GeoModel:
913
match example_model:
1014
case ExampleModel.HORIZONTAL_STRAT:
@@ -19,6 +23,8 @@ def generate_example_model(example_model: ExampleModel, compute_model: bool = Tr
1923
return _generate_combination_model(compute_model)
2024
case ExampleModel.ONE_FAULT_GRAVITY:
2125
return _generate_one_fault_model_gravity(compute_model)
26+
case ExampleModel.GRABEN:
27+
return _generate_graben_model(compute_model)
2228
case _:
2329
raise NotImplementedError(f"Example model {example_model} not implemented.")
2430

@@ -437,3 +443,42 @@ def _generate_one_fault_model_gravity(compute_model):
437443
grav[0].backward()
438444

439445
return geo_model
446+
447+
448+
def _generate_graben_model(compute_model: bool) -> gp.data.GeoModel:
449+
# Data path is in root/examples/data
450+
# script_dir = os.path.dirname(os.path.abspath(__file__))
451+
# data_path = os.path.join(script_dir, '.../examples/')
452+
# n_model = 7
453+
# https: // github.com / gempy - project / gempy / blob / 279
454+
# bbe904283e16320c54d868fe74be873177cca / examples / data / input_data / lisa_models / interfaces7.csv
455+
# csv_ = data_path + "/data/input_data/lisa_models/foliations" + n_model + ".csv"
456+
457+
data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
458+
path_to_data = data_path + "/data/input_data/lisa_models/"
459+
460+
geo_data: gp.data.GeoModel = gp.create_geomodel(
461+
project_name="Graben",
462+
extent=[0, 2000, 0, 2000, 0, 1600],
463+
resolution=[50, 50, 50],
464+
refinement=6, # * For this model is better not to use octrees because we want to see what is happening in the scalar fields
465+
importer_helper=gp.data.ImporterHelper(
466+
path_to_orientations= path_to_data + "foliations7.csv",
467+
path_to_surface_points= path_to_data + "interfaces7.csv"
468+
)
469+
)
470+
471+
gp.map_stack_to_surfaces(
472+
gempy_model=geo_data,
473+
mapping_object={
474+
"Fault_1" : 'Fault_1', "Fault_2": 'Fault_2',
475+
"Strat_Series": ('Sandstone', 'Siltstone', 'Shale', 'Sandstone_2', 'Schist', 'Gneiss')
476+
},
477+
)
478+
479+
gp.set_is_fault(geo_data, ['Fault_1', 'Fault_2'])
480+
if compute_model:
481+
sol = gp.compute_model(gempy_model=geo_data)
482+
483+
return geo_data
484+

gempy/core/data/enumerators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ class ExampleModel(Enum):
88
ONE_FAULT = auto()
99
COMBINATION = auto()
1010
ONE_FAULT_GRAVITY = auto()
11+
GRABEN = auto()

0 commit comments

Comments
 (0)