subsurface-terra 2025.1.0rc15__py3-none-any.whl → 2025.1.0rc16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- subsurface/__init__.py +31 -31
- subsurface/_version.py +34 -21
- subsurface/api/__init__.py +13 -13
- subsurface/api/interfaces/__init__.py +3 -3
- subsurface/api/interfaces/stream.py +136 -136
- subsurface/api/reader/read_wells.py +78 -78
- subsurface/core/geological_formats/boreholes/_combine_trajectories.py +117 -117
- subsurface/core/geological_formats/boreholes/_map_attrs_to_survey.py +236 -234
- subsurface/core/geological_formats/boreholes/_survey_to_unstruct.py +163 -163
- subsurface/core/geological_formats/boreholes/boreholes.py +140 -140
- subsurface/core/geological_formats/boreholes/collars.py +26 -26
- subsurface/core/geological_formats/boreholes/survey.py +86 -86
- subsurface/core/geological_formats/fault.py +47 -47
- subsurface/core/reader_helpers/reader_unstruct.py +11 -11
- subsurface/core/reader_helpers/readers_data.py +130 -130
- subsurface/core/reader_helpers/readers_wells.py +13 -13
- subsurface/core/structs/__init__.py +3 -3
- subsurface/core/structs/base_structures/__init__.py +2 -2
- subsurface/core/structs/base_structures/_liquid_earth_mesh.py +121 -121
- subsurface/core/structs/base_structures/_unstructured_data_constructor.py +70 -70
- subsurface/core/structs/base_structures/base_structures_enum.py +6 -6
- subsurface/core/structs/base_structures/structured_data.py +282 -282
- subsurface/core/structs/base_structures/unstructured_data.py +319 -319
- subsurface/core/structs/structured_elements/octree_mesh.py +10 -10
- subsurface/core/structs/structured_elements/structured_grid.py +59 -59
- subsurface/core/structs/structured_elements/structured_mesh.py +9 -9
- subsurface/core/structs/unstructured_elements/__init__.py +3 -3
- subsurface/core/structs/unstructured_elements/line_set.py +72 -72
- subsurface/core/structs/unstructured_elements/point_set.py +43 -43
- subsurface/core/structs/unstructured_elements/tetrahedron_mesh.py +35 -35
- subsurface/core/structs/unstructured_elements/triangular_surface.py +62 -62
- subsurface/core/utils/utils_core.py +38 -38
- subsurface/modules/reader/__init__.py +13 -13
- subsurface/modules/reader/faults/faults.py +80 -80
- subsurface/modules/reader/from_binary.py +46 -46
- subsurface/modules/reader/mesh/_GOCAD_mesh.py +82 -82
- subsurface/modules/reader/mesh/_trimesh_reader.py +447 -447
- subsurface/modules/reader/mesh/csv_mesh_reader.py +53 -53
- subsurface/modules/reader/mesh/dxf_reader.py +177 -177
- subsurface/modules/reader/mesh/glb_reader.py +30 -30
- subsurface/modules/reader/mesh/mx_reader.py +232 -232
- subsurface/modules/reader/mesh/obj_reader.py +53 -53
- subsurface/modules/reader/mesh/omf_mesh_reader.py +43 -43
- subsurface/modules/reader/mesh/surface_reader.py +56 -56
- subsurface/modules/reader/mesh/surfaces_api.py +41 -41
- subsurface/modules/reader/profiles/__init__.py +3 -3
- subsurface/modules/reader/profiles/profiles_core.py +197 -197
- subsurface/modules/reader/read_netcdf.py +38 -38
- subsurface/modules/reader/topography/__init__.py +7 -7
- subsurface/modules/reader/topography/topo_core.py +100 -100
- subsurface/modules/reader/volume/read_grav3d.py +478 -428
- subsurface/modules/reader/volume/read_volume.py +327 -230
- subsurface/modules/reader/volume/segy_reader.py +105 -105
- subsurface/modules/reader/volume/seismic.py +173 -173
- subsurface/modules/reader/volume/volume_utils.py +43 -43
- subsurface/modules/reader/wells/DEP/__init__.py +43 -43
- subsurface/modules/reader/wells/DEP/_well_files_reader.py +167 -167
- subsurface/modules/reader/wells/DEP/_wells_api.py +61 -61
- subsurface/modules/reader/wells/DEP/_welly_reader.py +180 -180
- subsurface/modules/reader/wells/DEP/pandas_to_welly.py +212 -212
- subsurface/modules/reader/wells/_read_to_df.py +57 -57
- subsurface/modules/reader/wells/read_borehole_interface.py +148 -148
- subsurface/modules/reader/wells/wells_utils.py +68 -68
- subsurface/modules/tools/mocking_aux.py +104 -104
- subsurface/modules/visualization/__init__.py +2 -2
- subsurface/modules/visualization/to_pyvista.py +320 -320
- subsurface/modules/writer/to_binary.py +12 -12
- subsurface/modules/writer/to_rex/common.py +78 -78
- subsurface/modules/writer/to_rex/data_struct.py +74 -74
- subsurface/modules/writer/to_rex/gempy_to_rexfile.py +791 -791
- subsurface/modules/writer/to_rex/material_encoder.py +44 -44
- subsurface/modules/writer/to_rex/mesh_encoder.py +152 -152
- subsurface/modules/writer/to_rex/to_rex.py +115 -115
- subsurface/modules/writer/to_rex/utils.py +15 -15
- subsurface/optional_requirements.py +116 -116
- {subsurface_terra-2025.1.0rc15.dist-info → subsurface_terra-2025.1.0rc16.dist-info}/METADATA +194 -194
- subsurface_terra-2025.1.0rc16.dist-info/RECORD +98 -0
- {subsurface_terra-2025.1.0rc15.dist-info → subsurface_terra-2025.1.0rc16.dist-info}/WHEEL +1 -1
- {subsurface_terra-2025.1.0rc15.dist-info → subsurface_terra-2025.1.0rc16.dist-info}/licenses/LICENSE +203 -203
- subsurface_terra-2025.1.0rc15.dist-info/RECORD +0 -98
- {subsurface_terra-2025.1.0rc15.dist-info → subsurface_terra-2025.1.0rc16.dist-info}/top_level.txt +0 -0
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import warnings
|
|
2
|
-
|
|
3
|
-
import xarray as xr
|
|
4
|
-
|
|
5
|
-
from subsurface import UnstructuredData, StructuredData
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
__all__ = ['read_unstruct', 'read_struct']
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def read_unstruct(path, legacy=False, **kwargs):
|
|
12
|
-
ds = xr.open_dataset(path, **kwargs)
|
|
13
|
-
|
|
14
|
-
if legacy is False:
|
|
15
|
-
try:
|
|
16
|
-
ud = UnstructuredData(ds)
|
|
17
|
-
except KeyError:
|
|
18
|
-
warnings.warn("Trying loading legacy files.")
|
|
19
|
-
ud = read_unstruct(path, legacy=True)
|
|
20
|
-
else:
|
|
21
|
-
ud = _legacy_read_unstruct(ds)
|
|
22
|
-
return ud
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def _legacy_read_unstruct(ds):
|
|
26
|
-
xarray_dict = {
|
|
27
|
-
"vertex": ds.vertex,
|
|
28
|
-
"cells": ds.cells,
|
|
29
|
-
"cell_attrs": ds.attributes.rename({"attribute": "cell_attr"}),
|
|
30
|
-
"vertex_attrs": ds.points_attributes.rename({"points_attribute": "vertex_attr"})
|
|
31
|
-
}
|
|
32
|
-
ud = UnstructuredData.from_data_arrays_dict(xarray_dict, ds.coords, ds.attrs)
|
|
33
|
-
return ud
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def read_struct(path, **kwargs):
|
|
37
|
-
ds = xr.open_dataset(path, **kwargs)
|
|
38
|
-
return StructuredData(ds)
|
|
1
|
+
import warnings
|
|
2
|
+
|
|
3
|
+
import xarray as xr
|
|
4
|
+
|
|
5
|
+
from subsurface import UnstructuredData, StructuredData
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
__all__ = ['read_unstruct', 'read_struct']
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def read_unstruct(path, legacy=False, **kwargs):
|
|
12
|
+
ds = xr.open_dataset(path, **kwargs)
|
|
13
|
+
|
|
14
|
+
if legacy is False:
|
|
15
|
+
try:
|
|
16
|
+
ud = UnstructuredData(ds)
|
|
17
|
+
except KeyError:
|
|
18
|
+
warnings.warn("Trying loading legacy files.")
|
|
19
|
+
ud = read_unstruct(path, legacy=True)
|
|
20
|
+
else:
|
|
21
|
+
ud = _legacy_read_unstruct(ds)
|
|
22
|
+
return ud
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _legacy_read_unstruct(ds):
|
|
26
|
+
xarray_dict = {
|
|
27
|
+
"vertex": ds.vertex,
|
|
28
|
+
"cells": ds.cells,
|
|
29
|
+
"cell_attrs": ds.attributes.rename({"attribute": "cell_attr"}),
|
|
30
|
+
"vertex_attrs": ds.points_attributes.rename({"points_attribute": "vertex_attr"})
|
|
31
|
+
}
|
|
32
|
+
ud = UnstructuredData.from_data_arrays_dict(xarray_dict, ds.coords, ds.attrs)
|
|
33
|
+
return ud
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def read_struct(path, **kwargs):
|
|
37
|
+
ds = xr.open_dataset(path, **kwargs)
|
|
38
|
+
return StructuredData(ds)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
from typing import Sequence, Optional
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
|
|
5
|
-
from ....core.structs.structured_elements.structured_grid import StructuredGrid
|
|
6
|
-
from ....optional_requirements import require_rasterio
|
|
7
|
-
from ....core.structs import StructuredData, UnstructuredData
|
|
8
|
-
from ....core.utils.utils_core import get_extension
|
|
9
|
-
from ....core.reader_helpers.readers_data import GenericReaderFilesHelper
|
|
10
|
-
from ....core.reader_helpers.reader_unstruct import ReaderUnstructuredHelper
|
|
11
|
-
from ..mesh.surfaces_api import read_2d_mesh_to_unstruct
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def read_structured_topography(path, crop_to_extent: Optional[Sequence]=None) -> StructuredData:
|
|
15
|
-
rasterio = require_rasterio()
|
|
16
|
-
|
|
17
|
-
extension = get_extension(path)
|
|
18
|
-
if extension == '.tif':
|
|
19
|
-
structured_data = rasterio_dataset_to_structured_data(
|
|
20
|
-
dataset=rasterio.open(path),
|
|
21
|
-
crop_to_extent=crop_to_extent
|
|
22
|
-
)
|
|
23
|
-
else:
|
|
24
|
-
raise NotImplementedError('The extension given cannot be read yet')
|
|
25
|
-
|
|
26
|
-
return structured_data
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def read_structured_topography_to_unstructured(path) -> UnstructuredData:
|
|
30
|
-
structured_data = read_structured_topography(path)
|
|
31
|
-
return topography_to_unstructured_data(structured_data)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def rasterio_dataset_to_structured_data(dataset, crop_to_extent: Optional[Sequence]=None):
|
|
35
|
-
if crop_to_extent is not None:
|
|
36
|
-
window = _get_raster_window(crop_to_extent, dataset)
|
|
37
|
-
else:
|
|
38
|
-
window = None
|
|
39
|
-
|
|
40
|
-
data = dataset.read(1, window=window)
|
|
41
|
-
data = np.fliplr(data.T)
|
|
42
|
-
shape = data.shape
|
|
43
|
-
|
|
44
|
-
# TODO: ===================
|
|
45
|
-
# TODO: Add the option to crop
|
|
46
|
-
# TODO: Resample
|
|
47
|
-
|
|
48
|
-
coords = {
|
|
49
|
-
'x': np.linspace(
|
|
50
|
-
dataset.bounds.left,
|
|
51
|
-
dataset.bounds.right,
|
|
52
|
-
shape[0]
|
|
53
|
-
),
|
|
54
|
-
'y': np.linspace(
|
|
55
|
-
dataset.bounds.bottom,
|
|
56
|
-
dataset.bounds.top,
|
|
57
|
-
shape[1]
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
structured_data = StructuredData.from_numpy(data, data_array_name='topography', coords=coords)
|
|
61
|
-
return structured_data
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def read_unstructured_topography(path, additional_reader_kwargs: Optional[dict]=None) -> UnstructuredData:
|
|
65
|
-
"""For example, a dxf file"""
|
|
66
|
-
|
|
67
|
-
additional_reader_kwargs = additional_reader_kwargs or {}
|
|
68
|
-
helper = GenericReaderFilesHelper(
|
|
69
|
-
file_or_buffer=path,
|
|
70
|
-
additional_reader_kwargs=additional_reader_kwargs or {}
|
|
71
|
-
)
|
|
72
|
-
unstructured_helper = ReaderUnstructuredHelper(helper)
|
|
73
|
-
unstruct: UnstructuredData = read_2d_mesh_to_unstruct(unstructured_helper)
|
|
74
|
-
return unstruct
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def topography_to_unstructured_data(structured_data: StructuredData) -> UnstructuredData:
|
|
78
|
-
from subsurface.modules.visualization import to_pyvista_grid
|
|
79
|
-
|
|
80
|
-
sg = StructuredGrid(structured_data)
|
|
81
|
-
s = to_pyvista_grid(sg, data_order='C', data_set_name='topography')
|
|
82
|
-
un_s = s.cast_to_unstructured_grid()
|
|
83
|
-
un_s.triangulate(inplace=True)
|
|
84
|
-
vertex = un_s.points
|
|
85
|
-
cells = un_s.cells.reshape(-1, 4)[:, 1:]
|
|
86
|
-
|
|
87
|
-
unstructured_data = UnstructuredData.from_array(vertex, cells)
|
|
88
|
-
return unstructured_data
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def _get_raster_window(crop_to_extent, dataset):
|
|
92
|
-
from rasterio.windows import Window
|
|
93
|
-
# TODO: Add None check
|
|
94
|
-
# Get the indices of the window
|
|
95
|
-
left, bottom, right, top = crop_to_extent
|
|
96
|
-
row_start, col_start = dataset.index(left, top)
|
|
97
|
-
row_stop, col_stop = dataset.index(right, bottom)
|
|
98
|
-
# Read the data in the window
|
|
99
|
-
window = Window.from_slices((row_start, row_stop), (col_start, col_stop))
|
|
100
|
-
return window
|
|
1
|
+
from typing import Sequence, Optional
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from ....core.structs.structured_elements.structured_grid import StructuredGrid
|
|
6
|
+
from ....optional_requirements import require_rasterio
|
|
7
|
+
from ....core.structs import StructuredData, UnstructuredData
|
|
8
|
+
from ....core.utils.utils_core import get_extension
|
|
9
|
+
from ....core.reader_helpers.readers_data import GenericReaderFilesHelper
|
|
10
|
+
from ....core.reader_helpers.reader_unstruct import ReaderUnstructuredHelper
|
|
11
|
+
from ..mesh.surfaces_api import read_2d_mesh_to_unstruct
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def read_structured_topography(path, crop_to_extent: Optional[Sequence]=None) -> StructuredData:
|
|
15
|
+
rasterio = require_rasterio()
|
|
16
|
+
|
|
17
|
+
extension = get_extension(path)
|
|
18
|
+
if extension == '.tif':
|
|
19
|
+
structured_data = rasterio_dataset_to_structured_data(
|
|
20
|
+
dataset=rasterio.open(path),
|
|
21
|
+
crop_to_extent=crop_to_extent
|
|
22
|
+
)
|
|
23
|
+
else:
|
|
24
|
+
raise NotImplementedError('The extension given cannot be read yet')
|
|
25
|
+
|
|
26
|
+
return structured_data
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def read_structured_topography_to_unstructured(path) -> UnstructuredData:
|
|
30
|
+
structured_data = read_structured_topography(path)
|
|
31
|
+
return topography_to_unstructured_data(structured_data)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def rasterio_dataset_to_structured_data(dataset, crop_to_extent: Optional[Sequence]=None):
|
|
35
|
+
if crop_to_extent is not None:
|
|
36
|
+
window = _get_raster_window(crop_to_extent, dataset)
|
|
37
|
+
else:
|
|
38
|
+
window = None
|
|
39
|
+
|
|
40
|
+
data = dataset.read(1, window=window)
|
|
41
|
+
data = np.fliplr(data.T)
|
|
42
|
+
shape = data.shape
|
|
43
|
+
|
|
44
|
+
# TODO: ===================
|
|
45
|
+
# TODO: Add the option to crop
|
|
46
|
+
# TODO: Resample
|
|
47
|
+
|
|
48
|
+
coords = {
|
|
49
|
+
'x': np.linspace(
|
|
50
|
+
dataset.bounds.left,
|
|
51
|
+
dataset.bounds.right,
|
|
52
|
+
shape[0]
|
|
53
|
+
),
|
|
54
|
+
'y': np.linspace(
|
|
55
|
+
dataset.bounds.bottom,
|
|
56
|
+
dataset.bounds.top,
|
|
57
|
+
shape[1]
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
structured_data = StructuredData.from_numpy(data, data_array_name='topography', coords=coords)
|
|
61
|
+
return structured_data
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def read_unstructured_topography(path, additional_reader_kwargs: Optional[dict]=None) -> UnstructuredData:
|
|
65
|
+
"""For example, a dxf file"""
|
|
66
|
+
|
|
67
|
+
additional_reader_kwargs = additional_reader_kwargs or {}
|
|
68
|
+
helper = GenericReaderFilesHelper(
|
|
69
|
+
file_or_buffer=path,
|
|
70
|
+
additional_reader_kwargs=additional_reader_kwargs or {}
|
|
71
|
+
)
|
|
72
|
+
unstructured_helper = ReaderUnstructuredHelper(helper)
|
|
73
|
+
unstruct: UnstructuredData = read_2d_mesh_to_unstruct(unstructured_helper)
|
|
74
|
+
return unstruct
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def topography_to_unstructured_data(structured_data: StructuredData) -> UnstructuredData:
|
|
78
|
+
from subsurface.modules.visualization import to_pyvista_grid
|
|
79
|
+
|
|
80
|
+
sg = StructuredGrid(structured_data)
|
|
81
|
+
s = to_pyvista_grid(sg, data_order='C', data_set_name='topography')
|
|
82
|
+
un_s = s.cast_to_unstructured_grid()
|
|
83
|
+
un_s.triangulate(inplace=True)
|
|
84
|
+
vertex = un_s.points
|
|
85
|
+
cells = un_s.cells.reshape(-1, 4)[:, 1:]
|
|
86
|
+
|
|
87
|
+
unstructured_data = UnstructuredData.from_array(vertex, cells)
|
|
88
|
+
return unstructured_data
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _get_raster_window(crop_to_extent, dataset):
|
|
92
|
+
from rasterio.windows import Window
|
|
93
|
+
# TODO: Add None check
|
|
94
|
+
# Get the indices of the window
|
|
95
|
+
left, bottom, right, top = crop_to_extent
|
|
96
|
+
row_start, col_start = dataset.index(left, top)
|
|
97
|
+
row_stop, col_stop = dataset.index(right, bottom)
|
|
98
|
+
# Read the data in the window
|
|
99
|
+
window = Window.from_slices((row_start, row_stop), (col_start, col_stop))
|
|
100
|
+
return window
|