xtgeo 4.14.1__cp313-cp313-win_amd64.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.
- cxtgeo.py +558 -0
- cxtgeoPYTHON_wrap.c +19537 -0
- xtgeo/__init__.py +248 -0
- xtgeo/_cxtgeo.cp313-win_amd64.pyd +0 -0
- xtgeo/_internal.cp313-win_amd64.pyd +0 -0
- xtgeo/common/__init__.py +19 -0
- xtgeo/common/_angles.py +29 -0
- xtgeo/common/_xyz_enum.py +50 -0
- xtgeo/common/calc.py +396 -0
- xtgeo/common/constants.py +30 -0
- xtgeo/common/exceptions.py +42 -0
- xtgeo/common/log.py +93 -0
- xtgeo/common/sys.py +166 -0
- xtgeo/common/types.py +18 -0
- xtgeo/common/version.py +34 -0
- xtgeo/common/xtgeo_dialog.py +604 -0
- xtgeo/cube/__init__.py +9 -0
- xtgeo/cube/_cube_export.py +214 -0
- xtgeo/cube/_cube_import.py +532 -0
- xtgeo/cube/_cube_roxapi.py +180 -0
- xtgeo/cube/_cube_utils.py +287 -0
- xtgeo/cube/_cube_window_attributes.py +273 -0
- xtgeo/cube/cube1.py +1023 -0
- xtgeo/grid3d/__init__.py +15 -0
- xtgeo/grid3d/_ecl_grid.py +778 -0
- xtgeo/grid3d/_ecl_inte_head.py +152 -0
- xtgeo/grid3d/_ecl_logi_head.py +71 -0
- xtgeo/grid3d/_ecl_output_file.py +81 -0
- xtgeo/grid3d/_egrid.py +1004 -0
- xtgeo/grid3d/_find_gridprop_in_eclrun.py +625 -0
- xtgeo/grid3d/_grdecl_format.py +309 -0
- xtgeo/grid3d/_grdecl_grid.py +400 -0
- xtgeo/grid3d/_grid3d.py +29 -0
- xtgeo/grid3d/_grid3d_fence.py +284 -0
- xtgeo/grid3d/_grid3d_utils.py +228 -0
- xtgeo/grid3d/_grid_boundary.py +76 -0
- xtgeo/grid3d/_grid_etc1.py +1683 -0
- xtgeo/grid3d/_grid_export.py +222 -0
- xtgeo/grid3d/_grid_hybrid.py +50 -0
- xtgeo/grid3d/_grid_import.py +79 -0
- xtgeo/grid3d/_grid_import_ecl.py +101 -0
- xtgeo/grid3d/_grid_import_roff.py +135 -0
- xtgeo/grid3d/_grid_import_xtgcpgeom.py +375 -0
- xtgeo/grid3d/_grid_refine.py +258 -0
- xtgeo/grid3d/_grid_roxapi.py +292 -0
- xtgeo/grid3d/_grid_translate_coords.py +154 -0
- xtgeo/grid3d/_grid_wellzone.py +165 -0
- xtgeo/grid3d/_gridprop_export.py +202 -0
- xtgeo/grid3d/_gridprop_import_eclrun.py +164 -0
- xtgeo/grid3d/_gridprop_import_grdecl.py +132 -0
- xtgeo/grid3d/_gridprop_import_roff.py +52 -0
- xtgeo/grid3d/_gridprop_import_xtgcpprop.py +168 -0
- xtgeo/grid3d/_gridprop_lowlevel.py +171 -0
- xtgeo/grid3d/_gridprop_op1.py +272 -0
- xtgeo/grid3d/_gridprop_roxapi.py +301 -0
- xtgeo/grid3d/_gridprop_value_init.py +140 -0
- xtgeo/grid3d/_gridprops_import_eclrun.py +344 -0
- xtgeo/grid3d/_gridprops_import_roff.py +83 -0
- xtgeo/grid3d/_roff_grid.py +470 -0
- xtgeo/grid3d/_roff_parameter.py +303 -0
- xtgeo/grid3d/grid.py +3010 -0
- xtgeo/grid3d/grid_properties.py +699 -0
- xtgeo/grid3d/grid_property.py +1313 -0
- xtgeo/grid3d/types.py +15 -0
- xtgeo/interfaces/rms/__init__.py +18 -0
- xtgeo/interfaces/rms/_regular_surface.py +460 -0
- xtgeo/interfaces/rms/_rms_base.py +100 -0
- xtgeo/interfaces/rms/_rmsapi_package.py +69 -0
- xtgeo/interfaces/rms/rmsapi_utils.py +438 -0
- xtgeo/io/__init__.py +1 -0
- xtgeo/io/_file.py +603 -0
- xtgeo/metadata/__init__.py +17 -0
- xtgeo/metadata/metadata.py +435 -0
- xtgeo/roxutils/__init__.py +7 -0
- xtgeo/roxutils/_roxar_loader.py +54 -0
- xtgeo/roxutils/_roxutils_etc.py +122 -0
- xtgeo/roxutils/roxutils.py +207 -0
- xtgeo/surface/__init__.py +20 -0
- xtgeo/surface/_regsurf_boundary.py +26 -0
- xtgeo/surface/_regsurf_cube.py +210 -0
- xtgeo/surface/_regsurf_cube_window.py +391 -0
- xtgeo/surface/_regsurf_cube_window_v2.py +297 -0
- xtgeo/surface/_regsurf_cube_window_v3.py +360 -0
- xtgeo/surface/_regsurf_export.py +388 -0
- xtgeo/surface/_regsurf_grid3d.py +275 -0
- xtgeo/surface/_regsurf_gridding.py +347 -0
- xtgeo/surface/_regsurf_ijxyz_parser.py +278 -0
- xtgeo/surface/_regsurf_import.py +347 -0
- xtgeo/surface/_regsurf_lowlevel.py +122 -0
- xtgeo/surface/_regsurf_oper.py +538 -0
- xtgeo/surface/_regsurf_utils.py +81 -0
- xtgeo/surface/_surfs_import.py +43 -0
- xtgeo/surface/_zmap_parser.py +138 -0
- xtgeo/surface/regular_surface.py +3043 -0
- xtgeo/surface/surfaces.py +276 -0
- xtgeo/well/__init__.py +24 -0
- xtgeo/well/_blockedwell_roxapi.py +241 -0
- xtgeo/well/_blockedwells_roxapi.py +68 -0
- xtgeo/well/_well_aux.py +30 -0
- xtgeo/well/_well_io.py +327 -0
- xtgeo/well/_well_oper.py +483 -0
- xtgeo/well/_well_roxapi.py +304 -0
- xtgeo/well/_wellmarkers.py +486 -0
- xtgeo/well/_wells_utils.py +158 -0
- xtgeo/well/blocked_well.py +220 -0
- xtgeo/well/blocked_wells.py +134 -0
- xtgeo/well/well1.py +1516 -0
- xtgeo/well/wells.py +211 -0
- xtgeo/xyz/__init__.py +6 -0
- xtgeo/xyz/_polygons_oper.py +272 -0
- xtgeo/xyz/_xyz.py +758 -0
- xtgeo/xyz/_xyz_data.py +646 -0
- xtgeo/xyz/_xyz_io.py +737 -0
- xtgeo/xyz/_xyz_lowlevel.py +42 -0
- xtgeo/xyz/_xyz_oper.py +613 -0
- xtgeo/xyz/_xyz_roxapi.py +766 -0
- xtgeo/xyz/points.py +698 -0
- xtgeo/xyz/polygons.py +827 -0
- xtgeo-4.14.1.dist-info/METADATA +146 -0
- xtgeo-4.14.1.dist-info/RECORD +122 -0
- xtgeo-4.14.1.dist-info/WHEEL +5 -0
- xtgeo-4.14.1.dist-info/licenses/LICENSE.md +165 -0
xtgeo/common/sys.py
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""Module for basic XTGeo interaction with OS/system files and folders."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
import io
|
|
7
|
+
import pathlib
|
|
8
|
+
from types import BuiltinFunctionType
|
|
9
|
+
from typing import TYPE_CHECKING, Literal
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
|
|
13
|
+
from xtgeo import _cxtgeo
|
|
14
|
+
from xtgeo.io._file import FileWrapper
|
|
15
|
+
|
|
16
|
+
from ._xyz_enum import _AttrType
|
|
17
|
+
from .log import null_logger
|
|
18
|
+
|
|
19
|
+
if TYPE_CHECKING:
|
|
20
|
+
from collections.abc import Callable
|
|
21
|
+
|
|
22
|
+
import numpy.typing as npt
|
|
23
|
+
import pandas as pd
|
|
24
|
+
|
|
25
|
+
logger = null_logger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def npfromfile(
|
|
29
|
+
fname: str | pathlib.Path | io.BytesIO | io.StringIO,
|
|
30
|
+
dtype: npt.DTypeLike = np.float32,
|
|
31
|
+
count: int = 1,
|
|
32
|
+
offset: int = 0,
|
|
33
|
+
mmap: bool = False,
|
|
34
|
+
) -> np.ndarray:
|
|
35
|
+
"""Wrapper round np.fromfile to be compatible with older np versions."""
|
|
36
|
+
try:
|
|
37
|
+
if mmap and not isinstance(fname, (io.BytesIO, io.StringIO)):
|
|
38
|
+
vals = np.memmap(
|
|
39
|
+
fname, dtype=dtype, shape=(count,), mode="r", offset=offset
|
|
40
|
+
)
|
|
41
|
+
else:
|
|
42
|
+
vals = np.fromfile(fname, dtype=dtype, count=count, offset=offset)
|
|
43
|
+
except TypeError as err:
|
|
44
|
+
# offset keyword requires numpy >= 1.17, need this for backward compat.:
|
|
45
|
+
if "'offset' is an invalid" not in str(err):
|
|
46
|
+
raise
|
|
47
|
+
if not isinstance(fname, (str, pathlib.Path)):
|
|
48
|
+
raise
|
|
49
|
+
with open(fname, "rb") as buffer:
|
|
50
|
+
buffer.seek(offset)
|
|
51
|
+
vals = np.fromfile(buffer, dtype=dtype, count=count)
|
|
52
|
+
return vals
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def check_folder(
|
|
56
|
+
fname: str | pathlib.Path | io.BytesIO | io.StringIO,
|
|
57
|
+
raiseerror: type[Exception] | None = None,
|
|
58
|
+
) -> bool:
|
|
59
|
+
"""General function to check folder."""
|
|
60
|
+
_nn = FileWrapper(fname)
|
|
61
|
+
status = _nn.check_folder(raiseerror=raiseerror)
|
|
62
|
+
del _nn
|
|
63
|
+
return status
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def generic_hash(
|
|
67
|
+
gid: str, hashmethod: Literal["md5", "sha256", "blake2d"] | Callable = "md5"
|
|
68
|
+
) -> str:
|
|
69
|
+
"""Return a unique hash ID for current instance.
|
|
70
|
+
|
|
71
|
+
This hash can e.g. be used to compare two instances for equality.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
gid: Any string as signature, e.g. cumulative attributes of an instance.
|
|
75
|
+
hashmethod: Supported methods are "md5", "sha256", "blake2b"
|
|
76
|
+
or use a full function signature e.g. hashlib.sha128.
|
|
77
|
+
Defaults to md5.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Hash signature.
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
KeyError: String in hashmethod has an invalid option
|
|
84
|
+
|
|
85
|
+
.. versionadded:: 2.14
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
validmethods: dict[str, Callable] = {
|
|
89
|
+
"md5": hashlib.md5,
|
|
90
|
+
"sha256": hashlib.sha256,
|
|
91
|
+
"blake2b": hashlib.blake2b,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if isinstance(hashmethod, str) and hashmethod in validmethods:
|
|
95
|
+
mhash = validmethods[hashmethod]()
|
|
96
|
+
elif isinstance(hashmethod, BuiltinFunctionType):
|
|
97
|
+
mhash = hashmethod()
|
|
98
|
+
else:
|
|
99
|
+
raise ValueError(f"Invalid hash method provided: {hashmethod}")
|
|
100
|
+
|
|
101
|
+
mhash.update(gid.encode())
|
|
102
|
+
return mhash.hexdigest()
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def inherit_docstring(inherit_from: Callable) -> Callable:
|
|
106
|
+
def decorator_set_docstring(func: Callable) -> Callable:
|
|
107
|
+
if func.__doc__ is None and inherit_from.__doc__ is not None:
|
|
108
|
+
func.__doc__ = inherit_from.__doc__
|
|
109
|
+
return func
|
|
110
|
+
|
|
111
|
+
return decorator_set_docstring
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# ----------------------------------------------------------------------------------
|
|
115
|
+
# Special methods for nerds, to be removed when not appplied any more
|
|
116
|
+
# ----------------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _convert_np_carr_int(length: int, np_array: np.ndarray) -> np.ndarray:
|
|
120
|
+
"""Convert numpy 1D array to C array, assuming int type.
|
|
121
|
+
|
|
122
|
+
The numpy is always a double (float64), so need to convert first
|
|
123
|
+
"""
|
|
124
|
+
carr = _cxtgeo.new_intarray(length)
|
|
125
|
+
np_array = np_array.astype(np.int32)
|
|
126
|
+
_cxtgeo.swig_numpy_to_carr_i1d(np_array, carr)
|
|
127
|
+
return carr
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _convert_np_carr_double(length: int, np_array: np.ndarray) -> np.ndarray:
|
|
131
|
+
"""Convert numpy 1D array to C array, assuming double type."""
|
|
132
|
+
carr = _cxtgeo.new_doublearray(length)
|
|
133
|
+
_cxtgeo.swig_numpy_to_carr_1d(np_array, carr)
|
|
134
|
+
return carr
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _convert_carr_double_np(
|
|
138
|
+
length: int, carray: np.ndarray, nlen: int | None = None
|
|
139
|
+
) -> np.ndarray:
|
|
140
|
+
"""Convert a C array to numpy, assuming double type."""
|
|
141
|
+
if nlen is None:
|
|
142
|
+
nlen = length
|
|
143
|
+
return _cxtgeo.swig_carr_to_numpy_1d(nlen, carray)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _get_carray(
|
|
147
|
+
dataframe: pd.DataFrame, attributes: _AttrType, attrname: str
|
|
148
|
+
) -> np.ndarray | None:
|
|
149
|
+
"""
|
|
150
|
+
Returns the C array pointer (via SWIG) for a given attr.
|
|
151
|
+
|
|
152
|
+
Type conversion is double if float64, int32 if DISC attr.
|
|
153
|
+
Returns None if log does not exist.
|
|
154
|
+
"""
|
|
155
|
+
np_array = None
|
|
156
|
+
if attrname in dataframe:
|
|
157
|
+
np_array = dataframe[attrname].values
|
|
158
|
+
else:
|
|
159
|
+
return None
|
|
160
|
+
|
|
161
|
+
nlen = len(dataframe.index)
|
|
162
|
+
if attributes[attrname] == _AttrType.DISC.value:
|
|
163
|
+
carr = _convert_np_carr_int(nlen, np_array)
|
|
164
|
+
else:
|
|
165
|
+
carr = _convert_np_carr_double(nlen, np_array)
|
|
166
|
+
return carr
|
xtgeo/common/types.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This file contains commen types used in xtgeo, keep it free some logic.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from io import BytesIO, StringIO
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import NamedTuple, Union
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Dimensions(NamedTuple):
|
|
11
|
+
"""Class for a Dimensions NamedTuple"""
|
|
12
|
+
|
|
13
|
+
ncol: int
|
|
14
|
+
nrow: int
|
|
15
|
+
nlay: int
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
FileLike = Union[str, Path, StringIO, BytesIO]
|
xtgeo/common/version.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
TYPE_CHECKING = False
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from typing import Tuple
|
|
16
|
+
from typing import Union
|
|
17
|
+
|
|
18
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
20
|
+
else:
|
|
21
|
+
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
23
|
+
|
|
24
|
+
version: str
|
|
25
|
+
__version__: str
|
|
26
|
+
__version_tuple__: VERSION_TUPLE
|
|
27
|
+
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
30
|
+
|
|
31
|
+
__version__ = version = '4.14.1'
|
|
32
|
+
__version_tuple__ = version_tuple = (4, 14, 1)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = 'gcdcf054cf'
|