1
+ """
2
+ Modeling step by step
3
+ ^^^^^^^^^^^^^^^^^^^^^
4
+
5
+ This tutorial demonstrates step-by-step geological modeling using the `gempy` and `gempy_viewer` libraries.
6
+ It follows the Video tutorial series available on the `gempy` YouTube channel (https://www.youtube.com/@GemPy3D).
7
+ """
8
+
9
+ # %%
10
+ # Video tutorial 2: Input data
11
+ # """"""""""""""""""""""""""""
12
+
13
+ # Required imports
14
+ import gempy as gp
15
+ import gempy_viewer as gpv
16
+
17
+ # %%
18
+
19
+ # Path to input data
20
+ data_path = "https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/"
21
+ path_to_data = data_path + "/data/input_data/video_tutorials_v3/"
22
+
23
+ # %%
24
+
25
+ # Create instance of geomodel
26
+ geo_model = gp .create_geomodel (
27
+ project_name = 'tutorial_model' ,
28
+ extent = [0 ,2500 ,0 ,1000 ,0 ,1000 ],
29
+ resolution = [100 ,40 ,40 ],
30
+ importer_helper = gp .data .ImporterHelper (
31
+ path_to_orientations = path_to_data + "tutorial_model_orientations.csv" ,
32
+ path_to_surface_points = path_to_data + "tutorial_model_surface_points.csv"
33
+ )
34
+ )
35
+ # %%
36
+
37
+ # Display a basic cross section of input data
38
+ gpv .plot_2d (geo_model )
39
+
40
+ # %%
41
+
42
+ # Manually add a surface point
43
+ gp .add_surface_points (
44
+ geo_model = geo_model ,
45
+ x = [2250 ],
46
+ y = [500 ],
47
+ z = [750 ],
48
+ elements_names = ['rock1' ]
49
+ )
50
+
51
+ # %%
52
+
53
+ # Show added point in cross section
54
+ gpv .plot_2d (geo_model )
55
+
56
+ # %%
57
+ # Video tutorial 3: Structural frame
58
+ # """"""""""""""""""""""""""""""""""
59
+
60
+ # View structural frame
61
+ geo_model .structural_frame
62
+
63
+ # %%
64
+
65
+ # View structural elements
66
+ geo_model .structural_frame .structural_elements
67
+
68
+ # %%
69
+
70
+ # Define structural groups and age/stratigraphic relationship
71
+ gp .map_stack_to_surfaces (
72
+ gempy_model = geo_model ,
73
+ mapping_object = {
74
+ "Strat_Series2" : ("rock3" ),
75
+ "Strat_Series1" : ("rock2" , "rock1" )
76
+ }
77
+ )
78
+
79
+ # %%
80
+ # Video tutorial 4: Computation and results
81
+ # """""""""""""""""""""""""""""""""""""""""
82
+
83
+ geo_model .interpolation_options
84
+
85
+ # %%
86
+
87
+ # Compute a solution for the model
88
+ gp .compute_model (geo_model )
89
+
90
+ # %%
91
+
92
+ # Display the result in 2d section
93
+ gpv .plot_2d (geo_model , cell_number = 20 )
94
+
95
+ # %%
96
+
97
+ # Some examples of how to access results
98
+ print (geo_model .solutions .raw_arrays .lith_block )
99
+ print (geo_model .grid .dense_grid .values )
100
+
101
+ # %%
102
+ # Video tutorial 5: 2D visualization
103
+ # """"""""""""""""""""""""""""""""""
104
+
105
+ # 2d plotting options
106
+ gpv .plot_2d (geo_model , show_value = True , show_lith = False , show_scalar = True , series_n = 1 , cell_number = 25 )
107
+
108
+ # %%
109
+
110
+ # Create custom section lines
111
+ gp .set_section_grid (
112
+ grid = geo_model .grid ,
113
+ section_dict = {
114
+ 'section1' : ([0 , 0 ], [2500 , 1000 ], [100 , 50 ]),
115
+ 'section2' : ([1000 , 1000 ], [1500 , 0 ], [100 , 100 ]),
116
+ }
117
+ )
118
+
119
+ # %%
120
+
121
+ # Show custom cross-section traces
122
+ gpv .plot_section_traces (geo_model )
123
+
124
+ # %%
125
+
126
+ # Recompute model as a new grid was added
127
+ gp .compute_model (geo_model )
128
+
129
+ # %%
130
+
131
+ # Display custom cross-sections
132
+ gpv .plot_2d (geo_model , section_names = ['section1' , 'section2' ], show_data = False )
133
+
134
+ # %%
135
+ # Video tutorial 6: 3D visualization
136
+ # """"""""""""""""""""""""""""""""""
137
+
138
+ # Display the result in 3d
139
+ gpv .plot_3d (geo_model , show_lith = True , show_boundaries = True , ve = None )
140
+
141
+ # %%
142
+
143
+ # How to access DC meshes
144
+ geo_model .solutions .dc_meshes [0 ].dc_data
145
+
146
+ # %%
147
+ # Video tutorial 7: 2D Topography
148
+ # """""""""""""""""""""""""""""""
149
+
150
+ # Setting a randomly generated topography
151
+ import numpy as np
152
+
153
+ gp .set_topography_from_random (
154
+ grid = geo_model .grid ,
155
+ fractal_dimension = 1.2 ,
156
+ d_z = np .array ([700 , 900 ]),
157
+ topography_resolution = np .array ([250 , 100 ])
158
+ )
159
+
160
+ # %%
161
+
162
+ # Recompute model as a new grid was added
163
+ gp .compute_model (geo_model )
164
+
165
+ # %%
166
+
167
+ # Display a cross-section with topography
168
+ gpv .plot_2d (geo_model , show_topography = True )
169
+
170
+ # %%
171
+
172
+ # Displaying a geological map
173
+ gpv .plot_2d (geo_model , show_topography = True , section_names = ['topography' ], show_boundaries = False , show_data = False )
174
+
175
+ # %%
176
+
177
+ # Display the 3d model with topography
178
+ gpv .plot_3d (geo_model , show_lith = True , show_topography = True )
0 commit comments