|
| 1 | +import numpy as np |
1 | 2 | import os
|
2 | 3 | import pandas as pd
|
3 | 4 |
|
|
13 | 14 | import gempy as gp
|
14 | 15 |
|
15 | 16 |
|
16 |
| -@pytest.mark.skip(reason="Not implemented yet") |
| 17 | +# @pytest.mark.skip(reason="Not implemented yet") |
17 | 18 | class TestStratigraphicPile:
|
18 | 19 | @pytest.fixture(autouse=True)
|
19 | 20 | def borehole_set(self):
|
@@ -64,64 +65,110 @@ def borehole_set(self):
|
64 | 65 | return borehole_set
|
65 | 66 |
|
66 | 67 | def test_structural_elements(self, borehole_set: BoreholeSet):
|
| 68 | + from subsurface import LineSet |
| 69 | + borehole_trajectory: LineSet = borehole_set.combined_trajectory |
67 | 70 | if PLOT := False:
|
68 | 71 | s = to_pyvista_line(
|
69 |
| - line_set=borehole_set.combined_trajectory, |
| 72 | + line_set=borehole_trajectory, |
70 | 73 | radius=10,
|
71 | 74 | active_scalar="lith_ids"
|
72 | 75 | )
|
73 | 76 | pv_plot([s], image_2d=False, cmap="tab20c")
|
74 | 77 |
|
75 |
| - vertex_attributes: pd.DataFrame = borehole_set.combined_trajectory.data.points_attributes |
| 78 | + vertex_attributes: pd.DataFrame = borehole_trajectory.data.points_attributes |
76 | 79 | unique_lith_codes = vertex_attributes['component lith'].unique()
|
77 |
| - |
| 80 | + |
| 81 | + component_lith = borehole_set.compute_tops() |
| 82 | + |
78 | 83 | pleistozen = gp.data.StructuralElement(
|
79 |
| - name= "Pleistozen", |
| 84 | + name="Pleistozen", |
80 | 85 | id=10_000,
|
81 | 86 | 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)) |
84 | 89 | )
|
85 |
| - |
| 90 | + |
86 | 91 | kreide = gp.data.StructuralElement(
|
87 |
| - name= "Kreide", |
| 92 | + name="Kreide", |
88 | 93 | id=30_000,
|
89 | 94 | 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)) |
92 | 97 | )
|
93 |
| - |
| 98 | + |
94 | 99 | trias = gp.data.StructuralElement(
|
95 |
| - name= "Trias", |
| 100 | + name="Trias", |
96 | 101 | id=50_000,
|
97 | 102 | 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)) |
100 | 105 | )
|
101 |
| - |
| 106 | + |
102 | 107 | perm = gp.data.StructuralElement(
|
103 |
| - name= "Perm", |
| 108 | + name="Perm", |
104 | 109 | id=60_000,
|
105 | 110 | 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)) |
108 | 113 | )
|
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 | + |
110 | 127 | rotliegend = gp.data.StructuralElement(
|
111 |
| - name= "Rotliegend", |
112 |
| - id=62_000, |
| 128 | + name="Rotliegend", |
| 129 | + id=rotliegend_id, |
113 | 130 | 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)) |
116 | 133 | )
|
117 |
| - |
| 134 | + |
118 | 135 | devon = gp.data.StructuralElement(
|
119 |
| - name= "Devon", |
| 136 | + name="Devon", |
120 | 137 | id=80_000,
|
121 | 138 | 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)) |
124 | 141 | )
|
125 |
| - |
126 | 142 |
|
| 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) |
127 | 174 | pass
|
0 commit comments