resdata 7.0.0b4__cp315-cp315-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.
Files changed (160) hide show
  1. resdata/__init__.py +39 -0
  2. resdata/_base_c_class.py +96 -0
  3. resdata/_rd_util.cp315-win_amd64.pyd +0 -0
  4. resdata/_rd_util.pyi +85 -0
  5. resdata/bin.py +8 -0
  6. resdata/geometry/__init__.py +15 -0
  7. resdata/geometry/_cpolyline_collection.cp315-win_amd64.pyd +0 -0
  8. resdata/geometry/_geo_pointset.cp315-win_amd64.pyd +0 -0
  9. resdata/geometry/_geo_region.cp315-win_amd64.pyd +0 -0
  10. resdata/geometry/_surface.cp315-win_amd64.pyd +0 -0
  11. resdata/geometry/cpolyline.cp315-win_amd64.pyd +0 -0
  12. resdata/geometry/cpolyline.pyi +33 -0
  13. resdata/geometry/cpolyline_collection.py +78 -0
  14. resdata/geometry/geo_pointset.py +48 -0
  15. resdata/geometry/geo_region.py +88 -0
  16. resdata/geometry/geometry_tools.py +454 -0
  17. resdata/geometry/polyline.py +157 -0
  18. resdata/geometry/surface.py +248 -0
  19. resdata/geometry/xyz_io.py +57 -0
  20. resdata/gravimetry/__init__.py +11 -0
  21. resdata/gravimetry/_grav.cp315-win_amd64.pyd +0 -0
  22. resdata/gravimetry/_subsidence.cp315-win_amd64.pyd +0 -0
  23. resdata/gravimetry/rd_grav.py +220 -0
  24. resdata/gravimetry/rd_subsidence.py +182 -0
  25. resdata/grid/__init__.py +19 -0
  26. resdata/grid/_grid.cp315-win_amd64.pyd +0 -0
  27. resdata/grid/_rd_region.cp315-win_amd64.pyd +0 -0
  28. resdata/grid/cell.py +123 -0
  29. resdata/grid/faults/__init__.py +7 -0
  30. resdata/grid/faults/_fault_block_layer.cp315-win_amd64.pyd +0 -0
  31. resdata/grid/faults/_layer.cp315-win_amd64.pyd +0 -0
  32. resdata/grid/faults/fault.py +563 -0
  33. resdata/grid/faults/fault_block.cp315-win_amd64.pyd +0 -0
  34. resdata/grid/faults/fault_block.pyi +60 -0
  35. resdata/grid/faults/fault_block_layer.py +179 -0
  36. resdata/grid/faults/fault_collection.py +104 -0
  37. resdata/grid/faults/fault_line.py +210 -0
  38. resdata/grid/faults/fault_segments.py +134 -0
  39. resdata/grid/faults/layer.py +204 -0
  40. resdata/grid/rd_grid.py +1300 -0
  41. resdata/grid/rd_grid_generator.py +739 -0
  42. resdata/grid/rd_region.py +969 -0
  43. resdata/py.typed +0 -0
  44. resdata/rd_type.py +138 -0
  45. resdata/rd_util.py +70 -0
  46. resdata/resdata_info_build.py.in +9 -0
  47. resdata/resdata_info_install.py.in +9 -0
  48. resdata/resfile/__init__.py +42 -0
  49. resdata/resfile/_kw.cp315-win_amd64.pyd +0 -0
  50. resdata/resfile/_open_fortio.py +42 -0
  51. resdata/resfile/_open_rd_file.py +19 -0
  52. resdata/resfile/_rsthead.cp315-win_amd64.pyd +0 -0
  53. resdata/resfile/fortio.cp315-win_amd64.pyd +0 -0
  54. resdata/resfile/fortio.pyi +42 -0
  55. resdata/resfile/rd_3d_file.py +24 -0
  56. resdata/resfile/rd_3dkw.py +202 -0
  57. resdata/resfile/rd_file.cp315-win_amd64.pyd +0 -0
  58. resdata/resfile/rd_file.pyi +82 -0
  59. resdata/resfile/rd_file_view.cp315-win_amd64.pyd +0 -0
  60. resdata/resfile/rd_file_view.pyi +32 -0
  61. resdata/resfile/rd_init_file.py +13 -0
  62. resdata/resfile/rd_kw.py +1294 -0
  63. resdata/resfile/rd_restart_file.py +98 -0
  64. resdata/rft/__init__.py +8 -0
  65. resdata/rft/rd_rft.py +304 -0
  66. resdata/rft/rd_rft_cell.py +156 -0
  67. resdata/rft/well_trajectory.py +69 -0
  68. resdata/summary/__init__.py +17 -0
  69. resdata/summary/_date2num.py +36 -0
  70. resdata/summary/_rd_sum.cp315-win_amd64.pyd +0 -0
  71. resdata/summary/_rd_sum_keyword_vector.cp315-win_amd64.pyd +0 -0
  72. resdata/summary/_rd_sum_tstep.cp315-win_amd64.pyd +0 -0
  73. resdata/summary/rd_cmp.py +141 -0
  74. resdata/summary/rd_npv.py +182 -0
  75. resdata/summary/rd_smspec_node.cp315-win_amd64.pyd +0 -0
  76. resdata/summary/rd_smspec_node.pyi +29 -0
  77. resdata/summary/rd_sum.py +1522 -0
  78. resdata/summary/rd_sum_keyword_vector.py +56 -0
  79. resdata/summary/rd_sum_node.py +25 -0
  80. resdata/summary/rd_sum_tstep.py +50 -0
  81. resdata/summary/rd_sum_var_type.py +19 -0
  82. resdata/summary/rd_sum_vector.py +274 -0
  83. resdata/types/__init__.py +0 -0
  84. resdata/types/_type.cp315-win_amd64.pyd +0 -0
  85. resdata/util/__init__.py +0 -0
  86. resdata/util/util/__init__.py +17 -0
  87. resdata/util/util/_ctime.cp315-win_amd64.pyd +0 -0
  88. resdata/util/util/ctime.py +150 -0
  89. resdata/version.py +24 -0
  90. resdata/well/__init__.pyi +17 -0
  91. resdata/well/well_connection.pyi +24 -0
  92. resdata/well/well_connection_direction_enum.pyi +23 -0
  93. resdata/well/well_info.pyi +24 -0
  94. resdata/well/well_segment.pyi +15 -0
  95. resdata/well/well_state.pyi +36 -0
  96. resdata/well/well_time_line.pyi +11 -0
  97. resdata/well/well_type_enum.pyi +23 -0
  98. resdata/well.cp315-win_amd64.pyd +0 -0
  99. resdata-7.0.0b4.data/headers/resdata/ert/geometry/geo_pointset.hpp +35 -0
  100. resdata-7.0.0b4.data/headers/resdata/ert/geometry/geo_polygon.hpp +42 -0
  101. resdata-7.0.0b4.data/headers/resdata/ert/geometry/geo_polygon_collection.hpp +28 -0
  102. resdata-7.0.0b4.data/headers/resdata/ert/geometry/geo_region.hpp +45 -0
  103. resdata-7.0.0b4.data/headers/resdata/ert/geometry/geo_surface.hpp +45 -0
  104. resdata-7.0.0b4.data/headers/resdata/ert/util/build_config.hpp +51 -0
  105. resdata-7.0.0b4.data/headers/resdata/ert/util/ert_api_config.hpp +15 -0
  106. resdata-7.0.0b4.data/headers/resdata/ert/util/parser.hpp +127 -0
  107. resdata-7.0.0b4.data/headers/resdata/ert/util/test_util.hpp +163 -0
  108. resdata-7.0.0b4.data/headers/resdata/ert/util/test_work_area.hpp +54 -0
  109. resdata-7.0.0b4.data/headers/resdata/ert/util/type_macros.hpp +137 -0
  110. resdata-7.0.0b4.data/headers/resdata/ert/util/util.hpp +267 -0
  111. resdata-7.0.0b4.data/headers/resdata/resdata/FortIO.hpp +111 -0
  112. resdata-7.0.0b4.data/headers/resdata/resdata/fault_block.hpp +76 -0
  113. resdata-7.0.0b4.data/headers/resdata/resdata/fault_block_layer.hpp +53 -0
  114. resdata-7.0.0b4.data/headers/resdata/resdata/layer.hpp +61 -0
  115. resdata-7.0.0b4.data/headers/resdata/resdata/nnc_info.hpp +35 -0
  116. resdata-7.0.0b4.data/headers/resdata/resdata/nnc_vector.hpp +31 -0
  117. resdata-7.0.0b4.data/headers/resdata/resdata/rd_box.hpp +24 -0
  118. resdata-7.0.0b4.data/headers/resdata/resdata/rd_coarse_cell.hpp +32 -0
  119. resdata-7.0.0b4.data/headers/resdata/resdata/rd_endian_flip.hpp +29 -0
  120. resdata-7.0.0b4.data/headers/resdata/resdata/rd_file.hpp +119 -0
  121. resdata-7.0.0b4.data/headers/resdata/resdata/rd_file_flag.hpp +51 -0
  122. resdata-7.0.0b4.data/headers/resdata/resdata/rd_file_kw.hpp +88 -0
  123. resdata-7.0.0b4.data/headers/resdata/resdata/rd_file_view.hpp +238 -0
  124. resdata-7.0.0b4.data/headers/resdata/resdata/rd_grav.hpp +47 -0
  125. resdata-7.0.0b4.data/headers/resdata/resdata/rd_grav_common.hpp +18 -0
  126. resdata-7.0.0b4.data/headers/resdata/resdata/rd_grid.hpp +198 -0
  127. resdata-7.0.0b4.data/headers/resdata/resdata/rd_kw.hpp +311 -0
  128. resdata-7.0.0b4.data/headers/resdata/resdata/rd_kw_header.hpp +78 -0
  129. resdata-7.0.0b4.data/headers/resdata/resdata/rd_kw_magic.hpp +648 -0
  130. resdata-7.0.0b4.data/headers/resdata/resdata/rd_region.hpp +223 -0
  131. resdata-7.0.0b4.data/headers/resdata/resdata/rd_rsthead.hpp +233 -0
  132. resdata-7.0.0b4.data/headers/resdata/resdata/rd_smspec.hpp +148 -0
  133. resdata-7.0.0b4.data/headers/resdata/resdata/rd_subsidence.hpp +43 -0
  134. resdata-7.0.0b4.data/headers/resdata/resdata/rd_sum.hpp +166 -0
  135. resdata-7.0.0b4.data/headers/resdata/resdata/rd_sum_data.hpp +92 -0
  136. resdata-7.0.0b4.data/headers/resdata/resdata/rd_sum_tstep.hpp +55 -0
  137. resdata-7.0.0b4.data/headers/resdata/resdata/rd_sum_vector.hpp +37 -0
  138. resdata-7.0.0b4.data/headers/resdata/resdata/rd_type.hpp +145 -0
  139. resdata-7.0.0b4.data/headers/resdata/resdata/rd_units.hpp +39 -0
  140. resdata-7.0.0b4.data/headers/resdata/resdata/rd_util.hpp +194 -0
  141. resdata-7.0.0b4.data/headers/resdata/resdata/smspec_node.hpp +154 -0
  142. resdata-7.0.0b4.data/headers/resdata/resdata/well/well_branch_collection.hpp +27 -0
  143. resdata-7.0.0b4.data/headers/resdata/resdata/well/well_conn.hpp +100 -0
  144. resdata-7.0.0b4.data/headers/resdata/resdata/well/well_const.hpp +119 -0
  145. resdata-7.0.0b4.data/headers/resdata/resdata/well/well_info.hpp +214 -0
  146. resdata-7.0.0b4.data/headers/resdata/resdata/well/well_rseg_loader.hpp +14 -0
  147. resdata-7.0.0b4.data/headers/resdata/resdata/well/well_segment.hpp +84 -0
  148. resdata-7.0.0b4.data/headers/resdata/resdata/well/well_segment_collection.hpp +46 -0
  149. resdata-7.0.0b4.data/headers/resdata/resdata/well/well_state.hpp +209 -0
  150. resdata-7.0.0b4.data/headers/resdata/resdata/well/well_ts.hpp +24 -0
  151. resdata-7.0.0b4.dist-info/DELVEWHEEL +2 -0
  152. resdata-7.0.0b4.dist-info/METADATA +92 -0
  153. resdata-7.0.0b4.dist-info/RECORD +160 -0
  154. resdata-7.0.0b4.dist-info/WHEEL +5 -0
  155. resdata-7.0.0b4.dist-info/licenses/COPYING +674 -0
  156. resdata-7.0.0b4.dist-info/licenses/LICENSE +674 -0
  157. resdata.libs/libresdata-8e8eb8300662c2270bfda47775c81bd8.dll +0 -0
  158. resdata.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
  159. view_summary/__init__.py +10 -0
  160. view_summary/__main__.py +653 -0
resdata/__init__.py ADDED
@@ -0,0 +1,39 @@
1
+ """""" # start delvewheel patch
2
+ def _delvewheel_patch_1_13_2():
3
+ import os
4
+ if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'resdata.libs'))):
5
+ os.add_dll_directory(libs_dir)
6
+
7
+
8
+ _delvewheel_patch_1_13_2()
9
+ del _delvewheel_patch_1_13_2
10
+ # end delvewheel patch
11
+
12
+ import ctypes as ct
13
+ import os
14
+ import pathlib
15
+ import warnings
16
+ from importlib.util import find_spec
17
+
18
+ warnings.filterwarnings(
19
+ action="always",
20
+ category=DeprecationWarning,
21
+ module="resdata",
22
+ )
23
+
24
+ from .rd_type import ResDataType, ResdataTypeEnum
25
+ from .rd_util import (
26
+ FileMode,
27
+ FileType,
28
+ Phase,
29
+ ResdataUtil,
30
+ UnitSystem,
31
+ )
32
+ from .version import version as __version__
33
+
34
+
35
+ def root():
36
+ """
37
+ Will print the filesystem root of the current ert package.
38
+ """
39
+ return os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))
@@ -0,0 +1,96 @@
1
+ import ctypes
2
+
3
+ # PyCapsule_GetPointer extracts the raw void* address wrapped by an (unnamed)
4
+ # capsule. Used only for equality/hashing/repr - never to reconstruct a typed
5
+ # pointer for use by C++ code (that goes through cast_cwrap in C++ instead).
6
+ _pycapsule_get_pointer = ctypes.pythonapi.PyCapsule_GetPointer
7
+ _pycapsule_get_pointer.restype = ctypes.c_void_p
8
+ _pycapsule_get_pointer.argtypes = (ctypes.py_object, ctypes.c_char_p)
9
+
10
+
11
+ def _capsule_address(capsule):
12
+ if capsule is None:
13
+ return 0
14
+ return _pycapsule_get_pointer(capsule, None)
15
+
16
+
17
+ class _BaseCClass:
18
+ def __new__(cls, *args, **kwargs):
19
+ obj = super().__new__(cls)
20
+ # Set safe defaults before __init__ runs, so that a __del__ call on a
21
+ # partially constructed object (e.g. because a subclass __init__
22
+ # raised before calling super().__init__()) does not itself raise an
23
+ # AttributeError - it will just see a None c_pointer and skip free().
24
+ obj.__c_pointer = None
25
+ obj.__parent = None
26
+ obj.__is_reference = False
27
+ return obj
28
+
29
+ def __init__(self, c_pointer, parent=None, is_reference=False):
30
+ if c_pointer is None:
31
+ raise ValueError("Must have a valid (not null) pointer value!")
32
+
33
+ self.__c_pointer = c_pointer
34
+ self.__parent = parent
35
+ self.__is_reference = is_reference
36
+
37
+ def setParent(self, parent):
38
+ self.__parent = parent
39
+ return self
40
+
41
+ def _ad_str(self):
42
+ return f"at 0x{_capsule_address(self.__c_pointer):x}"
43
+
44
+ def _create_repr(self, args=""):
45
+ return f"{self.__class__.__name__}({args}) {self._ad_str()}"
46
+
47
+ def free(self):
48
+ raise NotImplementedError(
49
+ "A _BaseCClass requires a free method implementation!"
50
+ )
51
+
52
+ def __del__(self):
53
+ if (
54
+ self.free is not None
55
+ and not self.__is_reference
56
+ and self.__c_pointer is not None
57
+ ):
58
+ # Important to check the c_pointer; in the case of failed object creation
59
+ # we can have a Python object with c_pointer == None.
60
+ self.free()
61
+
62
+ def __repr__(self):
63
+ return self._create_repr()
64
+
65
+ def __eq__(self, other):
66
+ if not isinstance(other, _BaseCClass):
67
+ return NotImplemented
68
+ return _capsule_address(self.__c_pointer) == _capsule_address(other.__c_pointer)
69
+
70
+ def __hash__(self):
71
+ return hash(_capsule_address(self.__c_pointer))
72
+
73
+ @classmethod
74
+ def createPythonObject(cls, c_pointer):
75
+ if c_pointer is not None:
76
+ new_obj = cls.__new__(cls)
77
+ _BaseCClass.__init__(
78
+ new_obj, c_pointer=c_pointer, parent=None, is_reference=False
79
+ )
80
+ return new_obj
81
+ else:
82
+ return None
83
+
84
+ @classmethod
85
+ def createCReference(cls, c_pointer, parent=None):
86
+ if c_pointer is not None:
87
+ new_obj = cls.__new__(cls)
88
+ _BaseCClass.__init__(
89
+ new_obj, c_pointer=c_pointer, parent=parent, is_reference=True
90
+ )
91
+ return new_obj
92
+ else:
93
+ return None
94
+
95
+
96
+ __all__ = ["_BaseCClass"]
Binary file
resdata/_rd_util.pyi ADDED
@@ -0,0 +1,85 @@
1
+ import enum
2
+ import typing
3
+
4
+ __all__ = ["FileMode", "FileType", "Phase"]
5
+
6
+ class FileMode:
7
+ CLOSE_STREAM: typing.ClassVar[FileMode]
8
+ DEFAULT: typing.ClassVar[FileMode]
9
+ WRITABLE: typing.ClassVar[FileMode]
10
+ __members__: typing.ClassVar[dict[str, FileMode]]
11
+ def __and__(self, arg0: FileMode) -> FileMode: ...
12
+ def __eq__(self, other: object) -> bool: ...
13
+ def __ge__(self, other: typing.Any) -> bool: ...
14
+ def __getstate__(self) -> int: ...
15
+ def __gt__(self, other: typing.Any) -> bool: ...
16
+ def __hash__(self) -> int: ...
17
+ def __index__(self) -> int: ...
18
+ def __init__(self, value: typing.SupportsInt) -> None: ...
19
+ def __int__(self) -> int: ...
20
+ def __invert__(self) -> FileMode: ...
21
+ def __le__(self, other: typing.Any) -> bool: ...
22
+ def __lt__(self, other: typing.Any) -> bool: ...
23
+ def __ne__(self, other: object) -> bool: ...
24
+ def __or__(self, arg0: FileMode) -> FileMode: ...
25
+ def __setstate__(self, state: typing.SupportsInt) -> None: ...
26
+ def __xor__(self, arg0: FileMode) -> FileMode: ...
27
+ @property
28
+ def name(self) -> str: ...
29
+ @property
30
+ def value(self) -> int: ...
31
+
32
+ class FileType:
33
+ DATA: typing.ClassVar[FileType]
34
+ EGRID: typing.ClassVar[FileType]
35
+ GRID: typing.ClassVar[FileType]
36
+ INIT: typing.ClassVar[FileType]
37
+ OTHER: typing.ClassVar[FileType]
38
+ RESTART: typing.ClassVar[FileType]
39
+ RFT: typing.ClassVar[FileType]
40
+ SUMMARY: typing.ClassVar[FileType]
41
+ SUMMARY_HEADER: typing.ClassVar[FileType]
42
+ UNIFIED_RESTART: typing.ClassVar[FileType]
43
+ UNIFIED_SUMMARY: typing.ClassVar[FileType]
44
+ __members__: typing.ClassVar[dict[str, FileType]]
45
+ def __eq__(self, other: object) -> bool: ...
46
+ def __getstate__(self) -> int: ...
47
+ def __hash__(self) -> int: ...
48
+ def __index__(self) -> int: ...
49
+ def __init__(self, value: typing.SupportsInt) -> None: ...
50
+ def __int__(self) -> int: ...
51
+ def __ne__(self, other: object) -> bool: ...
52
+ def __setstate__(self, state: typing.SupportsInt) -> None: ...
53
+ @property
54
+ def name(self) -> str: ...
55
+ @property
56
+ def value(self) -> int: ...
57
+
58
+ def _get_file_type(filename: str) -> tuple[FileType, bool, int]: ...
59
+ def _get_num_cpu(filename: str) -> int: ...
60
+ def _get_report_step(filename: str) -> int: ...
61
+ def _get_start_date(filename: str) -> int: ...
62
+
63
+ class UnitSystem:
64
+ METRIC: typing.ClassVar[UnitSystem]
65
+ FIELD: typing.ClassVar[UnitSystem]
66
+ LAB: typing.ClassVar[UnitSystem]
67
+ PVT_M: typing.ClassVar[UnitSystem]
68
+ __members__: typing.ClassVar[dict[str, UnitSystem]]
69
+ def __eq__(self, other: object) -> bool: ...
70
+ def __getstate__(self) -> int: ...
71
+ def __hash__(self) -> int: ...
72
+ def __index__(self) -> int: ...
73
+ def __init__(self, value: typing.SupportsInt) -> None: ...
74
+ def __int__(self) -> int: ...
75
+ def __ne__(self, other: object) -> bool: ...
76
+ def __setstate__(self, state: typing.SupportsInt) -> None: ...
77
+ @property
78
+ def name(self) -> str: ...
79
+ @property
80
+ def value(self) -> int: ...
81
+
82
+ class Phase(enum.IntFlag):
83
+ OIL = 1
84
+ GAS = 2
85
+ WATER = 4
resdata/bin.py ADDED
@@ -0,0 +1,8 @@
1
+ import os
2
+ import sys
3
+
4
+
5
+ def main():
6
+ prog = os.path.basename(sys.argv[0])
7
+ path = os.path.abspath(os.path.join(os.path.dirname(__file__), prog))
8
+ os.execl(path, path, *sys.argv[1:])
@@ -0,0 +1,15 @@
1
+ """
2
+ Simple package for working with 2D geometry.
3
+
4
+ """
5
+
6
+ import resdata
7
+
8
+ from .cpolyline import CPolyline
9
+ from .cpolyline_collection import CPolylineCollection
10
+ from .geo_pointset import GeoPointset
11
+ from .geo_region import GeoRegion
12
+ from .geometry_tools import GeometryTools
13
+ from .polyline import Polyline
14
+ from .surface import Surface
15
+ from .xyz_io import XYZIo
@@ -0,0 +1,33 @@
1
+ import typing
2
+
3
+ __all__: list[str] = ["CPolyline"]
4
+
5
+ class CPolyline:
6
+ def __init__(
7
+ self,
8
+ name: str | None = None,
9
+ init_points: typing.Iterable[tuple[float, float]] = (),
10
+ ) -> None: ...
11
+ @staticmethod
12
+ def createFromXYZFile(filename: str, name: str | None = None) -> CPolyline: ...
13
+ def __len__(self) -> int: ...
14
+ def __getitem__(self, index: int) -> tuple[float, float]: ...
15
+ def __eq__(self, other: object) -> bool: ...
16
+ def __add__(self, other: typing.Iterable[tuple[float, float]]) -> CPolyline: ...
17
+ def __radd__(self, other: typing.Iterable[tuple[float, float]]) -> CPolyline: ...
18
+ def __iadd__(self, other: typing.Iterable[tuple[float, float]]) -> typing.Self: ...
19
+ def addPoint(self, xc: float, yc: float, front: bool = False) -> None: ...
20
+ def getName(self) -> str | None: ...
21
+ def segmentIntersects(
22
+ self, p1: tuple[float, float], p2: tuple[float, float]
23
+ ) -> bool: ...
24
+ def intersects(self, polyline: typing.Iterable[tuple[float, float]]) -> bool: ...
25
+ def segmentLength(self) -> float: ...
26
+ def extendToBBox(
27
+ self, bbox: typing.Sequence[tuple[float, float]], start: bool = True
28
+ ) -> CPolyline: ...
29
+ def connect(
30
+ self, target: typing.Sequence[tuple[float, float]]
31
+ ) -> list[tuple[float, float]]: ...
32
+ def unzip(self) -> tuple[list[float], list[float]]: ...
33
+ def unzip2(self) -> tuple[list[float], list[float]]: ...
@@ -0,0 +1,78 @@
1
+ """
2
+ Create a polygon
3
+ """
4
+
5
+ import resdata.geometry._cpolyline_collection as _cpolyline_collection
6
+ from resdata._base_c_class import _BaseCClass
7
+ from resdata.geometry import CPolyline
8
+
9
+
10
+ class CPolylineCollection(_BaseCClass):
11
+ TYPE_NAME = "rd_geo_polygon_collection"
12
+
13
+ def __init__(self):
14
+ c_ptr = _cpolyline_collection._alloc_new()
15
+ super().__init__(c_ptr)
16
+
17
+ def __contains__(self, name):
18
+ return _cpolyline_collection._has_polyline(self, name)
19
+
20
+ def __len__(self):
21
+ return _cpolyline_collection._size(self)
22
+
23
+ def __iter__(self):
24
+ index = 0
25
+
26
+ while index < len(self):
27
+ yield self[index]
28
+ index += 1
29
+
30
+ def __getitem__(self, index):
31
+ if isinstance(index, int):
32
+ if index < 0:
33
+ index += len(self)
34
+
35
+ if 0 <= index < len(self):
36
+ return _cpolyline_collection._iget(self, index)
37
+ else:
38
+ raise IndexError(
39
+ "Invalid index:%d - valid range: [0,%d)" % (index, len(self))
40
+ )
41
+ elif isinstance(index, str):
42
+ if index in self:
43
+ return _cpolyline_collection._get(self, index)
44
+ else:
45
+ raise KeyError("No polyline named:%s" % index)
46
+ else:
47
+ raise TypeError("The index argument must be string or integer")
48
+
49
+ def shallowCopy(self):
50
+ copy = CPolylineCollection()
51
+ for pl in self:
52
+ _cpolyline_collection._add_polyline(copy, pl)
53
+
54
+ return copy
55
+
56
+ def addPolyline(self, polyline, name=None):
57
+ if not isinstance(polyline, CPolyline):
58
+ polyline = CPolyline(init_points=polyline, name=name)
59
+ else:
60
+ if name is not None:
61
+ raise ValueError(
62
+ "The name keyword argument can only be supplied when add not CPOlyline object"
63
+ )
64
+
65
+ name = polyline.getName()
66
+ if name and name in self:
67
+ raise KeyError("The polyline collection already has an object:%s" % name)
68
+
69
+ _cpolyline_collection._add_polyline(self, polyline)
70
+
71
+ def createPolyline(self, name=None):
72
+ if name and name in self:
73
+ raise KeyError("The polyline collection already has an object:%s" % name)
74
+
75
+ return _cpolyline_collection._create_polyline(self, name)
76
+
77
+ def free(self):
78
+ _cpolyline_collection._free(self)
@@ -0,0 +1,48 @@
1
+ import resdata.geometry._geo_pointset as _geo_pointset
2
+ from resdata._base_c_class import _BaseCClass
3
+
4
+
5
+ class GeoPointset(_BaseCClass):
6
+ TYPE_NAME = "rd_geo_points"
7
+
8
+ def __init__(self, external_z=False):
9
+ c_ptr = _geo_pointset._alloc(external_z)
10
+ if c_ptr is not None:
11
+ super().__init__(c_ptr)
12
+ else:
13
+ ext = "external" if external_z else "internal"
14
+ raise ValueError("Failed to construct GeoPointset with %s_z." % ext)
15
+
16
+ @staticmethod
17
+ def fromSurface(surface):
18
+ return surface.getPointset()
19
+
20
+ def __eq__(self, other):
21
+ if isinstance(other, GeoPointset):
22
+ return _geo_pointset._equal(self, other)
23
+ return NotImplemented
24
+
25
+ def __getitem__(self, key):
26
+ size = len(self)
27
+ if isinstance(key, int):
28
+ idx = key
29
+ if idx < 0:
30
+ idx += size
31
+ if 0 <= idx < size:
32
+ return _geo_pointset._iget_z(self, idx)
33
+ else:
34
+ raise IndexError(
35
+ "Invalid index, must be in [0, %d), was: %d." % (size, key)
36
+ )
37
+ else:
38
+ # TODO implement slicing?
39
+ raise ValueError("Index must be int, not %s." % type(key))
40
+
41
+ def __len__(self):
42
+ return _geo_pointset._get_size(self)
43
+
44
+ def __repr__(self):
45
+ return self._create_repr("len=%d" % len(self))
46
+
47
+ def free(self):
48
+ _geo_pointset._free(self)
@@ -0,0 +1,88 @@
1
+ import resdata.geometry._geo_region as _geo_region
2
+ from resdata._base_c_class import _BaseCClass
3
+
4
+ from .cpolyline import CPolyline
5
+
6
+
7
+ class GeoRegion(_BaseCClass):
8
+ TYPE_NAME = "rd_geo_region"
9
+
10
+ def __init__(self, pointset, preselect=False):
11
+ self._preselect = True if preselect else False
12
+ c_ptr = _geo_region._alloc(pointset, self._preselect)
13
+ if c_ptr is not None:
14
+ super().__init__(c_ptr)
15
+ # The C geo_region only borrows the pointset, so we must keep a
16
+ # reference to it (and, transitively, whatever owns its memory)
17
+ # alive for as long as the region exists.
18
+ self._pointset = pointset
19
+ else:
20
+ raise ValueError(
21
+ "Could not construct GeoRegion from pointset %s." % pointset
22
+ )
23
+
24
+ def getActiveList(self) -> list[int]:
25
+ return _geo_region._get_index_list(self)
26
+
27
+ def _assert_polygon(self, polygon):
28
+ if not isinstance(polygon, CPolyline):
29
+ raise ValueError("Need to select with a CPolyline, not %s." % type(polygon))
30
+
31
+ def _construct_cline(self, line):
32
+ """Takes a line ((x1,y1), (x2,y2)) and returns them
33
+ reordered to (x1x2, y1y2).
34
+ """
35
+ try:
36
+ p1, p2 = line
37
+ x1, y1 = map(float, p1)
38
+ x2, y2 = map(float, p2)
39
+ except Exception as err:
40
+ err_msg = "Select with pair ((x1,y1), (x2,y2)), not %s (%s)."
41
+ raise ValueError(err_msg % (line, err))
42
+ return (x1, x2), (y1, y2)
43
+
44
+ def select_inside(self, polygon):
45
+ self._assert_polygon(polygon)
46
+ _geo_region._select_inside_polygon(self, polygon)
47
+
48
+ def select_outside(self, polygon):
49
+ self._assert_polygon(polygon)
50
+ _geo_region._select_outside_polygon(self, polygon)
51
+
52
+ def deselect_inside(self, polygon):
53
+ self._assert_polygon(polygon)
54
+ _geo_region._deselect_inside_polygon(self, polygon)
55
+
56
+ def deselect_outside(self, polygon):
57
+ self._assert_polygon(polygon)
58
+ _geo_region._deselect_outside_polygon(self, polygon)
59
+
60
+ def select_above(self, line):
61
+ x_ptr, y_ptr = self._construct_cline(line)
62
+ _geo_region._select_above_line(self, x_ptr, y_ptr)
63
+
64
+ def select_below(self, line):
65
+ x_ptr, y_ptr = self._construct_cline(line)
66
+ _geo_region._select_below_line(self, x_ptr, y_ptr)
67
+
68
+ def deselect_above(self, line):
69
+ x_ptr, y_ptr = self._construct_cline(line)
70
+ _geo_region._deselect_above_line(self, x_ptr, y_ptr)
71
+
72
+ def deselect_below(self, line):
73
+ x_ptr, y_ptr = self._construct_cline(line)
74
+ _geo_region._deselect_below_line(self, x_ptr, y_ptr)
75
+
76
+ def __len__(self):
77
+ """Returns the size of the active list, not the size of the
78
+ underlying pointset"""
79
+ return _geo_region._len(self)
80
+
81
+ def __repr__(self):
82
+ ls = len(self)
83
+ il = repr(self.getActiveList())
84
+ pres = "preselected" if self._preselect else "not preselected"
85
+ return self._create_repr("size=%d, active_list=<%s>, %s" % (ls, il, pres))
86
+
87
+ def free(self):
88
+ _geo_region._free(self)