Skip to content

Commit cb34e62

Browse files
committed
feat: Add horizontal stratigraphic model tutorial
- Create tutorial demonstrating JSON I/O with horizontal stratigraphic model - Add sample JSON file with model data - Include surface points and orientations for two horizontal layers
1 parent e27ca15 commit cb34e62

File tree

2 files changed

+242
-0
lines changed

2 files changed

+242
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"""
2+
Tutorial: Loading a Horizontal Stratigraphic Model using JSON I/O
3+
===============================================================
4+
5+
This tutorial demonstrates how to load a horizontal stratigraphic model using GemPy's JSON I/O functionality.
6+
The model consists of two horizontal layers (rock1 and rock2) with surface points and orientations.
7+
"""
8+
9+
# %%
10+
# Import necessary libraries
11+
import gempy as gp
12+
import gempy_viewer as gpv
13+
import numpy as np
14+
import json
15+
from pathlib import Path
16+
17+
# %%
18+
# Define the model data
19+
model_data = {
20+
"metadata": {
21+
"name": "horizontal_stratigraphic",
22+
"creation_date": "2024-03-19",
23+
"last_modification_date": "2024-03-19",
24+
"owner": "tutorial"
25+
},
26+
"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+
# 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},
39+
],
40+
"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},
48+
{"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},
49+
],
50+
"series": [
51+
{
52+
"name": "Strat_Series",
53+
"surfaces": ["rock2", "rock1"]
54+
}
55+
],
56+
"grid_settings": {
57+
"regular_grid_resolution": [10, 10, 10],
58+
"regular_grid_extent": [0, 1000, 0, 1000, 0, 1000],
59+
"octree_levels": None
60+
},
61+
"interpolation_options": {}
62+
}
63+
64+
# %%
65+
# Save the model data to a JSON file
66+
tutorial_dir = Path(__file__).parent
67+
json_file = tutorial_dir / "horizontal_stratigraphic.json"
68+
with open(json_file, "w") as f:
69+
json.dump(model_data, f, indent=4)
70+
71+
# %%
72+
# Load the model from JSON
73+
model = gp.modules.json_io.JsonIO.load_model_from_json(str(json_file))
74+
75+
# %%
76+
# Plot the model
77+
# Plot the initial geological model in the y direction without results
78+
gpv.plot_2d(model, direction=['y'], show_results=False)
79+
80+
# 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)
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
{
2+
"metadata": {
3+
"name": "horizontal_stratigraphic",
4+
"creation_date": "2024-03-19",
5+
"last_modification_date": "2024-03-19",
6+
"owner": "tutorial"
7+
},
8+
"surface_points": [
9+
{
10+
"x": 500.0,
11+
"y": 500.0,
12+
"z": 500.0,
13+
"id": 0,
14+
"nugget": 0.00002
15+
},
16+
{
17+
"x": 500.0,
18+
"y": 500.0,
19+
"z": 600.0,
20+
"id": 0,
21+
"nugget": 0.00002
22+
},
23+
{
24+
"x": 500.0,
25+
"y": 500.0,
26+
"z": 700.0,
27+
"id": 0,
28+
"nugget": 0.00002
29+
},
30+
{
31+
"x": 500.0,
32+
"y": 500.0,
33+
"z": 800.0,
34+
"id": 0,
35+
"nugget": 0.00002
36+
},
37+
{
38+
"x": 500.0,
39+
"y": 500.0,
40+
"z": 900.0,
41+
"id": 0,
42+
"nugget": 0.00002
43+
},
44+
{
45+
"x": 500.0,
46+
"y": 500.0,
47+
"z": 200.0,
48+
"id": 1,
49+
"nugget": 0.00002
50+
},
51+
{
52+
"x": 500.0,
53+
"y": 500.0,
54+
"z": 300.0,
55+
"id": 1,
56+
"nugget": 0.00002
57+
},
58+
{
59+
"x": 500.0,
60+
"y": 500.0,
61+
"z": 400.0,
62+
"id": 1,
63+
"nugget": 0.00002
64+
},
65+
{
66+
"x": 500.0,
67+
"y": 500.0,
68+
"z": 500.0,
69+
"id": 1,
70+
"nugget": 0.00002
71+
},
72+
{
73+
"x": 500.0,
74+
"y": 500.0,
75+
"z": 600.0,
76+
"id": 1,
77+
"nugget": 0.00002
78+
}
79+
],
80+
"orientations": [
81+
{
82+
"x": 500.0,
83+
"y": 500.0,
84+
"z": 500.0,
85+
"G_x": 0.0,
86+
"G_y": 0.0,
87+
"G_z": 1.0,
88+
"id": 0,
89+
"nugget": 0.01,
90+
"polarity": 1
91+
},
92+
{
93+
"x": 500.0,
94+
"y": 500.0,
95+
"z": 700.0,
96+
"G_x": 0.0,
97+
"G_y": 0.0,
98+
"G_z": 1.0,
99+
"id": 0,
100+
"nugget": 0.01,
101+
"polarity": 1
102+
},
103+
{
104+
"x": 500.0,
105+
"y": 500.0,
106+
"z": 900.0,
107+
"G_x": 0.0,
108+
"G_y": 0.0,
109+
"G_z": 1.0,
110+
"id": 0,
111+
"nugget": 0.01,
112+
"polarity": 1
113+
},
114+
{
115+
"x": 500.0,
116+
"y": 500.0,
117+
"z": 200.0,
118+
"G_x": 0.0,
119+
"G_y": 0.0,
120+
"G_z": 1.0,
121+
"id": 1,
122+
"nugget": 0.01,
123+
"polarity": 1
124+
},
125+
{
126+
"x": 500.0,
127+
"y": 500.0,
128+
"z": 400.0,
129+
"G_x": 0.0,
130+
"G_y": 0.0,
131+
"G_z": 1.0,
132+
"id": 1,
133+
"nugget": 0.01,
134+
"polarity": 1
135+
},
136+
{
137+
"x": 500.0,
138+
"y": 500.0,
139+
"z": 600.0,
140+
"G_x": 0.0,
141+
"G_y": 0.0,
142+
"G_z": 1.0,
143+
"id": 1,
144+
"nugget": 0.01,
145+
"polarity": 1
146+
}
147+
],
148+
"series": [
149+
{
150+
"name": "Strat_Series",
151+
"surfaces": ["rock2", "rock1"]
152+
}
153+
],
154+
"grid_settings": {
155+
"regular_grid_resolution": [10, 10, 10],
156+
"regular_grid_extent": [0, 1000, 0, 1000, 0, 1000],
157+
"octree_levels": null
158+
},
159+
"interpolation_options": {}
160+
}

0 commit comments

Comments
 (0)