8
8
9
9
# %%
10
10
# Import necessary libraries
11
+ import matplotlib
12
+ matplotlib .use ('Agg' ) # Use non-interactive backend
11
13
import gempy as gp
12
14
import gempy_viewer as gpv
13
15
import numpy as np
14
16
import json
15
17
from pathlib import Path
18
+ import matplotlib .pyplot as plt
16
19
17
20
# %%
18
21
# Define the model data
24
27
"owner" : "tutorial"
25
28
},
26
29
"surface_points" : [
27
- # rock1 surface points
28
- {"x" : 500.0 , "y" : 500.0 , "z" : 500.0 , "id" : 0 , "nugget" : 0.00002 },
29
- {"x" : 500.0 , "y" : 500.0 , "z" : 600.0 , "id" : 0 , "nugget" : 0.00002 },
30
- {"x" : 500.0 , "y" : 500.0 , "z" : 700.0 , "id" : 0 , "nugget" : 0.00002 },
31
- {"x" : 500.0 , "y" : 500.0 , "z" : 800.0 , "id" : 0 , "nugget" : 0.00002 },
32
- {"x" : 500.0 , "y" : 500.0 , "z" : 900.0 , "id" : 0 , "nugget" : 0.00002 },
33
30
# rock2 surface points
34
- {"x" : 500.0 , "y" : 500.0 , "z" : 200.0 , "id" : 1 , "nugget" : 0.00002 },
35
- {"x" : 500.0 , "y" : 500.0 , "z" : 300.0 , "id" : 1 , "nugget" : 0.00002 },
36
- {"x" : 500.0 , "y" : 500.0 , "z" : 400.0 , "id" : 1 , "nugget" : 0.00002 },
37
- {"x" : 500.0 , "y" : 500.0 , "z" : 500.0 , "id" : 1 , "nugget" : 0.00002 },
38
- {"x" : 500.0 , "y" : 500.0 , "z" : 600.0 , "id" : 1 , "nugget" : 0.00002 },
31
+ {"x" : 100.0 , "y" : 200.0 , "z" : 600.0 , "id" : 1 , "nugget" : 0.00002 },
32
+ {"x" : 500.0 , "y" : 200.0 , "z" : 600.0 , "id" : 1 , "nugget" : 0.00002 },
33
+ {"x" : 900.0 , "y" : 200.0 , "z" : 600.0 , "id" : 1 , "nugget" : 0.00002 },
34
+ {"x" : 100.0 , "y" : 800.0 , "z" : 600.0 , "id" : 1 , "nugget" : 0.00002 },
35
+ {"x" : 500.0 , "y" : 800.0 , "z" : 600.0 , "id" : 1 , "nugget" : 0.00002 },
36
+ {"x" : 900.0 , "y" : 800.0 , "z" : 600.0 , "id" : 1 , "nugget" : 0.00002 },
37
+ # rock1 surface points
38
+ {"x" : 100.0 , "y" : 200.0 , "z" : 400.0 , "id" : 0 , "nugget" : 0.00002 },
39
+ {"x" : 500.0 , "y" : 200.0 , "z" : 400.0 , "id" : 0 , "nugget" : 0.00002 },
40
+ {"x" : 900.0 , "y" : 200.0 , "z" : 400.0 , "id" : 0 , "nugget" : 0.00002 },
41
+ {"x" : 100.0 , "y" : 800.0 , "z" : 400.0 , "id" : 0 , "nugget" : 0.00002 },
42
+ {"x" : 500.0 , "y" : 800.0 , "z" : 400.0 , "id" : 0 , "nugget" : 0.00002 },
43
+ {"x" : 900.0 , "y" : 800.0 , "z" : 400.0 , "id" : 0 , "nugget" : 0.00002 },
39
44
],
40
45
"orientations" : [
41
- # rock1 orientations
42
- {"x" : 500.0 , "y" : 500.0 , "z" : 500.0 , "G_x" : 0.0 , "G_y" : 0.0 , "G_z" : 1.0 , "id" : 0 , "nugget" : 0.01 , "polarity" : 1 },
43
- {"x" : 500.0 , "y" : 500.0 , "z" : 700.0 , "G_x" : 0.0 , "G_y" : 0.0 , "G_z" : 1.0 , "id" : 0 , "nugget" : 0.01 , "polarity" : 1 },
44
- {"x" : 500.0 , "y" : 500.0 , "z" : 900.0 , "G_x" : 0.0 , "G_y" : 0.0 , "G_z" : 1.0 , "id" : 0 , "nugget" : 0.01 , "polarity" : 1 },
45
- # rock2 orientations
46
- {"x" : 500.0 , "y" : 500.0 , "z" : 200.0 , "G_x" : 0.0 , "G_y" : 0.0 , "G_z" : 1.0 , "id" : 1 , "nugget" : 0.01 , "polarity" : 1 },
47
- {"x" : 500.0 , "y" : 500.0 , "z" : 400.0 , "G_x" : 0.0 , "G_y" : 0.0 , "G_z" : 1.0 , "id" : 1 , "nugget" : 0.01 , "polarity" : 1 },
46
+ # rock2 orientation
48
47
{"x" : 500.0 , "y" : 500.0 , "z" : 600.0 , "G_x" : 0.0 , "G_y" : 0.0 , "G_z" : 1.0 , "id" : 1 , "nugget" : 0.01 , "polarity" : 1 },
48
+ # rock1 orientation
49
+ {"x" : 500.0 , "y" : 500.0 , "z" : 400.0 , "G_x" : 0.0 , "G_y" : 0.0 , "G_z" : 1.0 , "id" : 0 , "nugget" : 0.01 , "polarity" : 1 },
49
50
],
50
51
"series" : [
51
52
{
72
73
# Load the model from JSON
73
74
model = gp .modules .json_io .JsonIO .load_model_from_json (str (json_file ))
74
75
76
+ # %%
77
+ # Compute the geological model
78
+ gp .compute_model (model )
79
+
75
80
# %%
76
81
# Plot the model
77
82
# Plot the initial geological model in the y direction without results
78
- gpv .plot_2d (model , direction = ['y' ], show_results = False )
83
+ fig , ax = plt .subplots (figsize = (10 , 6 ))
84
+ gpv .plot_2d (model , direction = ['y' ], show_results = False , ax = ax )
85
+ plt .title ("Initial Geological Model (y direction)" )
86
+ plt .savefig ('initial_model_y.png' )
87
+ plt .close ()
79
88
80
89
# Plot the result of the model in the x and y direction with data and without boundaries
81
- gpv .plot_2d (model , direction = ['x' ], show_data = True , show_boundaries = False )
82
- gpv .plot_2d (model , direction = ['y' ], show_data = True , show_boundaries = False )
90
+ fig , (ax1 , ax2 ) = plt .subplots (1 , 2 , figsize = (15 , 6 ))
91
+ gpv .plot_2d (model , direction = ['x' ], show_data = True , show_boundaries = False , ax = ax1 )
92
+ ax1 .set_title ("Model with Data (x direction)" )
93
+ gpv .plot_2d (model , direction = ['y' ], show_data = True , show_boundaries = False , ax = ax2 )
94
+ ax2 .set_title ("Model with Data (y direction)" )
95
+ plt .tight_layout ()
96
+ plt .savefig ('model_with_data.png' )
97
+ plt .close ()
0 commit comments