Skip to content

Commit

Permalink
Merge pull request #61 from softwareunderground/pr_pyv
Browse files Browse the repository at this point in the history
change _arrays to _data
  • Loading branch information
Japhiolite authored Mar 24, 2023
2 parents 2461d3f + b19fed3 commit 32660f2
Show file tree
Hide file tree
Showing 13 changed files with 510 additions and 505 deletions.
2 changes: 1 addition & 1 deletion requirements_opt.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openpyxl

welly == 0.4.8
welly

# There is an open PR for striplog
git+https://github.com/Leguark/striplog.git
Expand Down
2 changes: 1 addition & 1 deletion subsurface/geological_formats/seismic.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def create_pyvista_grid(self) -> pv.grid.UniformGrid:
grid = pv.UniformGrid()
grid.spacing = (1, 1, 1) # TODO: cell sizes? vertical exaggeration etc
grid.dimensions = np.array(self.data.shape) + 1
grid.cell_arrays["values"] = self.data.flatten(order="F")
grid.cell_data["values"] = self.data.flatten(order="F")
# TODO: correct orientation of cube
return grid

Expand Down
2 changes: 1 addition & 1 deletion subsurface/reader/readers_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ReaderFilesHelper:
file_or_buffer_type: Any = field(init=False)

index_col: Union[int, str] = False
header: Union[None, int, List[int]] = "infer"
header: Union[None, int, List[int]] = 0

def __post_init__(self):
if self.format is None: self.format = get_extension(self.file_or_buffer)
Expand Down
21 changes: 13 additions & 8 deletions subsurface/reader/wells/pandas_to_welly.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import pandas as pd

try:
import welly
from welly import Well, Location, Project, Curve
from striplog import Striplog, Component

welly_imported = True
except ImportError:
welly_imported = False


__all__ = ['WellyToSubsurfaceHelper', ]


Expand Down Expand Up @@ -61,16 +61,16 @@ def __init__(self,

def __repr__(self):
return self.p.__repr__()

@property
def p(self):
"""Project Alias"""
return self.welly_project

@p.setter
def p(self, p):
self.welly_project = p

@property
def lith_component_table(self):
return [Component({'lith': l}) for l in self._unique_formations]
Expand All @@ -85,8 +85,13 @@ def add_wells(self, well_names: Iterable):
self._well_names = self._well_names.union(well_names)
for b in new_boreholes:
# TODO: Name and uwi should be different
w = Well(params={'header': {'name': b, 'uwi': b}})
w.location = Location(params={'kb': 100})
if welly.__version__ < '0.5':
w = Well(params={'header': {'name': b, 'uwi': b}})
else:
w = Well()
w.uwi = b
w.name = b
# w.location = Location(params={'kb': 100})
self.p += w
return self.p

Expand Down Expand Up @@ -116,8 +121,8 @@ def add_striplog(self, data: pd.DataFrame):
w = self.p.get_well(b)
data_dict = data.loc[[b]].to_dict('list')
data_csv = data.loc[[b]].to_csv()
#s = Striplog.from_dict_advanced(data_dict, points=True)
#s = Striplog.from_dict(data_dict)
# s = Striplog.from_dict_advanced(data_dict, points=True)
# s = Striplog.from_dict(data_dict)
s = Striplog.from_csv(text=data_csv)

try:
Expand Down
6 changes: 3 additions & 3 deletions subsurface/reader/wells/welly_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def welly_to_subsurface(wts: WellyToSubsurfaceHelper,
"""
vertex = np.zeros((0, 3))
cells = np.zeros((0, 2), dtype=np.int_)
cells = np.zeros((0, 2), dtype=int)

last_index = 0
missed_wells = []
Expand All @@ -62,7 +62,7 @@ def welly_to_subsurface(wts: WellyToSubsurfaceHelper,
if table is None: table = wts.lith_component_table
w.data['lith_log'] = striplog_to_curve_log(n_vertex_per_well, table, w, wts)
else:
w.data["lith_log"] = Curve(-1 * np.ones(n_vertex_per_well - 1, dtype=int))
w.data["lith_log"] = Curve(-1 * np.ones(n_vertex_per_well - 1, dtype=int), mnemonic='lith_log')

if w.data["lith_log"].shape[0] != n_vertex_per_well - 1:
raise ValueError("Cell_attr does not match cells")
Expand All @@ -84,7 +84,7 @@ def welly_to_subsurface(wts: WellyToSubsurfaceHelper,
def striplog_to_curve_log(n_vertex_per_well, table, w: Well, wts: WellyToSubsurfaceHelper) -> Curve:
start, stop, step_size = wts._calculate_basis_parameters(w, n_vertex_per_well - 1)
s_log, basis, _table = w.data['lith'].to_log(step_size, start, stop, table=table, return_meta=True)
return Curve(s_log, basis)
return Curve(s_log, basis, mnemonic='lith_log')


def change_curve_basis_to_n_vertex_per_well_inplace(n_points, w, wts):
Expand Down
12 changes: 6 additions & 6 deletions subsurface/visualization/to_pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def to_pyvista_points(point_set: PointSet):
pv.PolyData
"""
poly = pv.PolyData(point_set.data.vertex)
poly.point_arrays.update(point_set.data.attributes_to_dict)
poly.point_data.update(point_set.data.attributes_to_dict)

return poly

Expand All @@ -106,8 +106,8 @@ def to_pyvista_mesh(unstructured_element: Union[TriSurf],
cells = np.c_[np.full(unstructured_element.mesh.n_elements, nve),
unstructured_element.mesh.cells]
mesh = pv.PolyData(vertices, cells)
mesh.cell_arrays.update(unstructured_element.mesh.attributes_to_dict)
mesh.point_arrays.update(unstructured_element.mesh.points_attributes)
mesh.cell_data.update(unstructured_element.mesh.attributes_to_dict)
mesh.point_data.update(unstructured_element.mesh.points_attributes)

return mesh

Expand Down Expand Up @@ -162,7 +162,7 @@ def to_pyvista_line(line_set: LineSet, as_tube=True, radius=None,
else:
raise NotImplementedError
# mesh = pv.Spline(ver)
mesh.cell_arrays.update(line_set.data.attributes_to_dict)
mesh.cell_data.update(line_set.data.attributes_to_dict)
if as_tube is True:
return mesh.tube(radius=radius)
else:
Expand All @@ -177,7 +177,7 @@ def to_pyvista_tetra(tetra_mesh: TetraMesh):
import vtk
ctypes = np.array([vtk.VTK_TETRA, ], np.int32)
mesh = pv.UnstructuredGrid(cells, ctypes, vertices)
mesh.cell_arrays.update(tetra_mesh.data.attributes_to_dict)
mesh.cell_data.update(tetra_mesh.data.attributes_to_dict)
return mesh


Expand Down Expand Up @@ -236,7 +236,7 @@ def update_grid_attribute(mesh, structured_grid,
if data_set_name is None:
data_set_name = structured_grid.ds.data_array_name

mesh.point_arrays.update(
mesh.point_data.update(
{data_set_name: structured_grid.ds.data[data_set_name].sel(
**attribute_slice
).values.ravel(data_order)})
Expand Down
Binary file modified tests/data/borehole/borehole_collar.xlsx
Binary file not shown.
Binary file modified tests/data/borehole/borehole_survey.xlsx
Binary file not shown.
Loading

0 comments on commit 32660f2

Please sign in to comment.