Skip to content

Commit 9b78ac2

Browse files
committed
fix: Update horizontal stratigraphic tutorial with correct data and model computation - Update surface points and orientations to match original CSV files - Add model computation step before plotting - Fix plot display using Agg backend
1 parent f91fa03 commit 9b78ac2

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

examples/tutorials/z_other_tutorials/json_io/02_horizontal_stratigraphic.py

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88

99
# %%
1010
# Import necessary libraries
11+
import matplotlib
12+
matplotlib.use('Agg') # Use non-interactive backend
1113
import gempy as gp
1214
import gempy_viewer as gpv
1315
import numpy as np
1416
import json
1517
from pathlib import Path
18+
import matplotlib.pyplot as plt
1619

1720
# %%
1821
# Define the model data
@@ -24,28 +27,26 @@
2427
"owner": "tutorial"
2528
},
2629
"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},
3330
# 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},
3944
],
4045
"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
4847
{"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},
4950
],
5051
"series": [
5152
{
@@ -72,11 +73,25 @@
7273
# Load the model from JSON
7374
model = gp.modules.json_io.JsonIO.load_model_from_json(str(json_file))
7475

76+
# %%
77+
# Compute the geological model
78+
gp.compute_model(model)
79+
7580
# %%
7681
# Plot the model
7782
# 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()
7988

8089
# 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

Comments
 (0)