Skip to content

Commit a051c25

Browse files
committed
[WIP] Building a gempy parser for subsurface.wells
1 parent 56e64b1 commit a051c25

File tree

3 files changed

+86
-29
lines changed

3 files changed

+86
-29
lines changed

gempy/core/data/orientations.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class OrientationsTable:
2525

2626
_model_transform: Optional[Transform] = None
2727

28+
def __post_init__(self):
29+
# Check if the data array has the correct data type
30+
if self.data.dtype != OrientationsTable.dt:
31+
raise ValueError(f"Data array must have the following data type: {OrientationsTable.dt}")
32+
2833
@classmethod
2934
def from_arrays(cls, x: np.ndarray, y: np.ndarray, z: np.ndarray,
3035
G_x: np.ndarray, G_y: np.ndarray, G_z: np.ndarray,

gempy/core/data/surface_points.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class SurfacePointsTable:
2525

2626
dt = np.dtype([('X', 'f8'), ('Y', 'f8'), ('Z', 'f8'), ('id', 'i4'), ('nugget', 'f8')]) #: The custom data type for the data array.
2727
_model_transform: Optional[Transform] = None
28+
29+
def __post_init__(self):
30+
# Check if the data array has the correct data type
31+
if self.data.dtype != SurfacePointsTable.dt:
32+
raise ValueError(f"Data array must have the following data type: {SurfacePointsTable.dt}")
2833

2934
def __str__(self):
3035
return "\n" + np.array2string(self.data, precision=2, separator=',', suppress_small=True)

test/test_modules/test_pile/test_stratigraphic_pile.py

Lines changed: 76 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import numpy as np
12
import os
23
import pandas as pd
34

@@ -13,7 +14,7 @@
1314
import gempy as gp
1415

1516

16-
@pytest.mark.skip(reason="Not implemented yet")
17+
# @pytest.mark.skip(reason="Not implemented yet")
1718
class TestStratigraphicPile:
1819
@pytest.fixture(autouse=True)
1920
def borehole_set(self):
@@ -64,64 +65,110 @@ def borehole_set(self):
6465
return borehole_set
6566

6667
def test_structural_elements(self, borehole_set: BoreholeSet):
68+
from subsurface import LineSet
69+
borehole_trajectory: LineSet = borehole_set.combined_trajectory
6770
if PLOT := False:
6871
s = to_pyvista_line(
69-
line_set=borehole_set.combined_trajectory,
72+
line_set=borehole_trajectory,
7073
radius=10,
7174
active_scalar="lith_ids"
7275
)
7376
pv_plot([s], image_2d=False, cmap="tab20c")
7477

75-
vertex_attributes: pd.DataFrame = borehole_set.combined_trajectory.data.points_attributes
78+
vertex_attributes: pd.DataFrame = borehole_trajectory.data.points_attributes
7679
unique_lith_codes = vertex_attributes['component lith'].unique()
77-
80+
81+
component_lith = borehole_set.compute_tops()
82+
7883
pleistozen = gp.data.StructuralElement(
79-
name= "Pleistozen",
84+
name="Pleistozen",
8085
id=10_000,
8186
color="#f9f97f",
82-
surface_points=gp.data.SurfacePointsTable(),
83-
orientations=gp.data.OrientationsTable()
87+
surface_points=gp.data.SurfacePointsTable(np.empty(0, dtype=gp.data.SurfacePointsTable.dt)),
88+
orientations=gp.data.OrientationsTable(np.zeros(0, dtype=gp.data.OrientationsTable.dt))
8489
)
85-
90+
8691
kreide = gp.data.StructuralElement(
87-
name= "Kreide",
92+
name="Kreide",
8893
id=30_000,
8994
color="#a6d84a",
90-
surface_points=gp.data.SurfacePointsTable(),
91-
orientations=gp.data.OrientationsTable()
95+
surface_points=gp.data.SurfacePointsTable(np.empty(0, dtype=gp.data.SurfacePointsTable.dt)),
96+
orientations=gp.data.OrientationsTable(np.zeros(0, dtype=gp.data.OrientationsTable.dt))
9297
)
93-
98+
9499
trias = gp.data.StructuralElement(
95-
name= "Trias",
100+
name="Trias",
96101
id=50_000,
97102
color="#a4469f",
98-
surface_points=gp.data.SurfacePointsTable(),
99-
orientations=gp.data.OrientationsTable()
103+
surface_points=gp.data.SurfacePointsTable(np.empty(0, dtype=gp.data.SurfacePointsTable.dt)),
104+
orientations=gp.data.OrientationsTable(np.zeros(0, dtype=gp.data.OrientationsTable.dt))
100105
)
101-
106+
102107
perm = gp.data.StructuralElement(
103-
name= "Perm",
108+
name="Perm",
104109
id=60_000,
105110
color="#f4a142",
106-
surface_points=gp.data.SurfacePointsTable(),
107-
orientations=gp.data.OrientationsTable()
111+
surface_points=gp.data.SurfacePointsTable(np.empty(0, dtype=gp.data.SurfacePointsTable.dt)),
112+
orientations=gp.data.OrientationsTable(np.zeros(0, dtype=gp.data.OrientationsTable.dt))
108113
)
109-
114+
115+
rotliegend_id = 62_000
116+
rotliegend_xyz = component_lith[rotliegend_id]
117+
118+
# Add the id
119+
rotliegend_surface_points = gp.data.SurfacePointsTable.from_arrays(
120+
x=rotliegend_xyz[:, 0],
121+
y=rotliegend_xyz[:, 1],
122+
z=rotliegend_xyz[:, 2],
123+
names=["Rotliegend"],
124+
name_id_map={"Rotliegend": rotliegend_id}
125+
)
126+
110127
rotliegend = gp.data.StructuralElement(
111-
name= "Rotliegend",
112-
id=62_000,
128+
name="Rotliegend",
129+
id=rotliegend_id,
113130
color="#bb825b",
114-
surface_points=gp.data.SurfacePointsTable(),
115-
orientations=gp.data.OrientationsTable()
131+
surface_points=rotliegend_surface_points,
132+
orientations=gp.data.OrientationsTable(np.zeros(0, dtype=gp.data.OrientationsTable.dt))
116133
)
117-
134+
118135
devon = gp.data.StructuralElement(
119-
name= "Devon",
136+
name="Devon",
120137
id=80_000,
121138
color="#969594",
122-
surface_points=gp.data.SurfacePointsTable(),
123-
orientations=gp.data.OrientationsTable()
139+
surface_points=gp.data.SurfacePointsTable(np.empty(0, dtype=gp.data.SurfacePointsTable.dt)),
140+
orientations=gp.data.OrientationsTable(np.zeros(0, dtype=gp.data.OrientationsTable.dt))
124141
)
125-
126142

143+
group = gp.data.StructuralGroup(
144+
name="Stratigraphic Pile",
145+
elements=[rotliegend],
146+
structural_relation=gp.data.StackRelationType.ERODE
147+
)
148+
structural_frame = gp.data.StructuralFrame(
149+
structural_groups=[group],
150+
color_gen=gp.data.ColorsGenerator()
151+
)
152+
print(group)
153+
154+
extent_from_data = rotliegend_xyz.min(axis=0), rotliegend_xyz.max(axis=0)
155+
156+
geo_model = gp.data.GeoModel(
157+
name="Stratigraphic Pile",
158+
structural_frame=structural_frame,
159+
grid=gp.data.Grid(
160+
extent=[extent_from_data[0][0], extent_from_data[1][0], extent_from_data[0][1], extent_from_data[1][1], extent_from_data[0][2], extent_from_data[1][2]],
161+
resolution=(50, 50, 50)
162+
),
163+
interpolation_options=gp.data.InterpolationOptions(
164+
range=5,
165+
c_o=10,
166+
mesh_extraction=True,
167+
number_octree_levels=3,
168+
),
169+
170+
)
171+
172+
import gempy_viewer as gpv
173+
gpv.plot_3d(geo_model)
127174
pass

0 commit comments

Comments
 (0)