Skip to content

Commit c1783c0

Browse files
committed
[DOC/WIP] Getting gempy elements from subsurface wells
1 parent 1d2f047 commit c1783c0

File tree

1 file changed

+57
-74
lines changed

1 file changed

+57
-74
lines changed

examples/examples/real/mik.py

Lines changed: 57 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
bold=True
131131
)
132132

133-
if plot3D:=False:
133+
if plot3D := False:
134134
p.show()
135135
else:
136136
img = p.show(screenshot=True)
@@ -143,80 +143,63 @@
143143
# %% m
144144
# Welly is a very powerful tool to inspect well data but it was not design for 3D. However they have a method to export XYZ coordinates of each of the well that we can take advanatage of to create a `subsurface.UnstructuredData` object. This object is one of the core data class of `subsurface` and we will use it from now on to keep working in 3D.
145145
# %%
146-
formations = ["topo", "etchegoin", "macoma", "chanac", "mclure",
147-
"santa_margarita", "fruitvale",
148-
"round_mountain", "olcese", "freeman_jewett", "vedder", "eocene",
149-
"cretaceous",
150-
"basement", "null"]
151-
152-
153-
# %%
154-
155-
borehole_set.get_bottom_coords_for_each_lith()
156-
foo = borehole_set._merge_vertex_data_arrays_to_dataframe()
157-
well_id_mapper: dict[str, int] = borehole_set.survey.id_to_well_id
158-
# mapp well_id column to well_name
159-
fos is greato["well_name"] = foo["well_id"].map(well_id_mapper)
160-
161-
pass
162-
# %%
163-
# unstruct = sb.reader.wells.welly_to_subsurface(wts, table=[Component({'lith': l}) for l in formations])
164-
unstrc = w
165-
unstruct.data
166-
# %% md
167-
# At each core `UstructuredData` is a wrapper of a `xarray.Dataset`. Although slightly flexible, any `UnstructuredData` will contain 4 `xarray.DataArray` objects containing vertex, cells, cell attributes and vertex attibutes. This is the minimum amount of information necessary to work in 3D.
168-
# %% md
169-
# From an `UnstructuredData` we can construct *elements*. *elements* are a higher level construct and includes the definion of type of geometric representation - e.g. points, lines, surfaces, etc. For the case of borehole we will use LineSets. *elements* have a very close relation to `vtk` data structures what enables easily to plot the data using `pyvista`
170-
# %%
171-
# %% md
172-
# ## Finding the boreholes bases
173-
#
174-
# `GemPy` interpolates the bottom of a unit, therefore we need to be able to extract those points to be able tointerpolate them. `xarray`, `pandas` and `numpy` are using the same type of memory representation what makes possible to use the same or at least similar methods to manipulate the data to our will.
175-
#
176-
# Lets find the base points of each well:
177-
# %%
178-
# Creating references to the xarray.DataArray
179-
cells_attr = unstruct.data.cell_attrs
180-
cells = unstruct.data.cells
181-
vertex = unstruct.data.vertex
182-
# %%
183-
# Find vertex points at the boundary of two units
184-
# Marking each vertex
185-
bool_prop_change = cells_attr.values[1:] != cells_attr.values[:-1]
186-
# Getting the index of the vertex
187-
args_prop_change = np.where(bool_prop_change)[0]
188-
# Getting the attr values at those points
189-
vals_prop_change = cells_attr[args_prop_change]
190-
vals_prop_change.to_pandas()
191-
# %%
192-
# Getting the vertex values at those points
193-
vertex_args_prop_change = cells[args_prop_change, 1]
194-
interface_points = vertex[vertex_args_prop_change]
195-
interface_points
196-
# %%
197-
# Creating a new UnstructuredData
198-
interf_us = ss.UnstructuredData.from_array(vertex=interface_points.values, cells="points",
199-
cells_attr=vals_prop_change.to_pandas())
200-
interf_us
201-
# %% md
202-
# This new `UnstructuredData` object instead containing data that represent lines, contain point data at the bottom of each unit. We can plot it very similar as before:
203-
# %%
204-
element = ss.PointSet(interf_us)
205-
pyvista_mesh = ss.visualization.to_pyvista_points(element)
206-
207-
p = init_plotter()
208-
import matplotlib.pyplot as plt
209-
210-
p.add_mesh(collar_mesh, render_points_as_spheres=True)
211-
p.add_point_labels(
212-
points=collars.collar_loc.points,
213-
labels=collars.ids,
214-
point_size=10,
215-
shape_opacity=0.5,
216-
font_size=12,
217-
bold=True
146+
elements = gp.structural_elements_from_borehole_set(
147+
borehole_set=borehole_set,
148+
elements_dict={
149+
"null": {
150+
"id": -1,
151+
"color": "#983999"
152+
},
153+
"etchgoin": {
154+
"id": 1,
155+
"color": "#00923f"
156+
},
157+
"macoma": {
158+
"id": 2,
159+
"color": "#da251d"
160+
},
161+
"chanac": {
162+
"id": 3,
163+
"color": "#f8c300"
164+
},
165+
"mclure": {
166+
"id": 4,
167+
"color": "#bb825b"
168+
},
169+
"santa_margarita": {
170+
"id": 5,
171+
"color": "#983999"
172+
},
173+
"fruitvale": {
174+
"id": 6,
175+
"color": "#00923f"
176+
},
177+
"round_mountain": {
178+
"id": 7,
179+
"color": "#da251d"
180+
},
181+
"olcese": {
182+
"id": 8,
183+
"color": "#f8c300"
184+
},
185+
"freeman_jewett": {
186+
"id": 9,
187+
"color": "#bb825b"
188+
},
189+
"vedder": {
190+
"id": 10,
191+
"color": "#983999"
192+
},
193+
"eocene": {
194+
"id": 11,
195+
"color": "#00923f"
196+
},
197+
"cretaceous": {
198+
"id": 12,
199+
"color": "#da251d"
200+
},
201+
}
218202
)
219-
p.show()
220203

221204

222205
# %% md

0 commit comments

Comments
 (0)