xtgeo 4.14.0__cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.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.

Potentially problematic release.


This version of xtgeo might be problematic. Click here for more details.

Files changed (658) hide show
  1. cxtgeo.py +558 -0
  2. cxtgeoPYTHON_wrap.c +19537 -0
  3. xtgeo/__init__.py +248 -0
  4. xtgeo/_cxtgeo.cpython-311-aarch64-linux-gnu.so +0 -0
  5. xtgeo/_internal.cpython-311-aarch64-linux-gnu.so +0 -0
  6. xtgeo/common/__init__.py +19 -0
  7. xtgeo/common/_angles.py +29 -0
  8. xtgeo/common/_xyz_enum.py +50 -0
  9. xtgeo/common/calc.py +396 -0
  10. xtgeo/common/constants.py +30 -0
  11. xtgeo/common/exceptions.py +42 -0
  12. xtgeo/common/log.py +93 -0
  13. xtgeo/common/sys.py +166 -0
  14. xtgeo/common/types.py +18 -0
  15. xtgeo/common/version.py +34 -0
  16. xtgeo/common/xtgeo_dialog.py +604 -0
  17. xtgeo/cube/__init__.py +9 -0
  18. xtgeo/cube/_cube_export.py +214 -0
  19. xtgeo/cube/_cube_import.py +532 -0
  20. xtgeo/cube/_cube_roxapi.py +180 -0
  21. xtgeo/cube/_cube_utils.py +287 -0
  22. xtgeo/cube/_cube_window_attributes.py +273 -0
  23. xtgeo/cube/cube1.py +1023 -0
  24. xtgeo/grid3d/__init__.py +15 -0
  25. xtgeo/grid3d/_ecl_grid.py +778 -0
  26. xtgeo/grid3d/_ecl_inte_head.py +152 -0
  27. xtgeo/grid3d/_ecl_logi_head.py +71 -0
  28. xtgeo/grid3d/_ecl_output_file.py +81 -0
  29. xtgeo/grid3d/_egrid.py +1004 -0
  30. xtgeo/grid3d/_find_gridprop_in_eclrun.py +625 -0
  31. xtgeo/grid3d/_grdecl_format.py +309 -0
  32. xtgeo/grid3d/_grdecl_grid.py +400 -0
  33. xtgeo/grid3d/_grid3d.py +29 -0
  34. xtgeo/grid3d/_grid3d_fence.py +284 -0
  35. xtgeo/grid3d/_grid3d_utils.py +228 -0
  36. xtgeo/grid3d/_grid_boundary.py +76 -0
  37. xtgeo/grid3d/_grid_etc1.py +1683 -0
  38. xtgeo/grid3d/_grid_export.py +222 -0
  39. xtgeo/grid3d/_grid_hybrid.py +50 -0
  40. xtgeo/grid3d/_grid_import.py +79 -0
  41. xtgeo/grid3d/_grid_import_ecl.py +101 -0
  42. xtgeo/grid3d/_grid_import_roff.py +135 -0
  43. xtgeo/grid3d/_grid_import_xtgcpgeom.py +375 -0
  44. xtgeo/grid3d/_grid_refine.py +258 -0
  45. xtgeo/grid3d/_grid_roxapi.py +292 -0
  46. xtgeo/grid3d/_grid_translate_coords.py +154 -0
  47. xtgeo/grid3d/_grid_wellzone.py +165 -0
  48. xtgeo/grid3d/_gridprop_export.py +202 -0
  49. xtgeo/grid3d/_gridprop_import_eclrun.py +164 -0
  50. xtgeo/grid3d/_gridprop_import_grdecl.py +130 -0
  51. xtgeo/grid3d/_gridprop_import_roff.py +52 -0
  52. xtgeo/grid3d/_gridprop_import_xtgcpprop.py +168 -0
  53. xtgeo/grid3d/_gridprop_lowlevel.py +171 -0
  54. xtgeo/grid3d/_gridprop_op1.py +272 -0
  55. xtgeo/grid3d/_gridprop_roxapi.py +301 -0
  56. xtgeo/grid3d/_gridprop_value_init.py +140 -0
  57. xtgeo/grid3d/_gridprops_import_eclrun.py +344 -0
  58. xtgeo/grid3d/_gridprops_import_roff.py +83 -0
  59. xtgeo/grid3d/_roff_grid.py +470 -0
  60. xtgeo/grid3d/_roff_parameter.py +303 -0
  61. xtgeo/grid3d/grid.py +3010 -0
  62. xtgeo/grid3d/grid_properties.py +699 -0
  63. xtgeo/grid3d/grid_property.py +1313 -0
  64. xtgeo/grid3d/types.py +15 -0
  65. xtgeo/include/eigen3/Eigen/Cholesky +45 -0
  66. xtgeo/include/eigen3/Eigen/CholmodSupport +48 -0
  67. xtgeo/include/eigen3/Eigen/Core +384 -0
  68. xtgeo/include/eigen3/Eigen/Dense +7 -0
  69. xtgeo/include/eigen3/Eigen/Eigen +2 -0
  70. xtgeo/include/eigen3/Eigen/Eigenvalues +60 -0
  71. xtgeo/include/eigen3/Eigen/Geometry +59 -0
  72. xtgeo/include/eigen3/Eigen/Householder +29 -0
  73. xtgeo/include/eigen3/Eigen/IterativeLinearSolvers +48 -0
  74. xtgeo/include/eigen3/Eigen/Jacobi +32 -0
  75. xtgeo/include/eigen3/Eigen/KLUSupport +41 -0
  76. xtgeo/include/eigen3/Eigen/LU +47 -0
  77. xtgeo/include/eigen3/Eigen/MetisSupport +35 -0
  78. xtgeo/include/eigen3/Eigen/OrderingMethods +70 -0
  79. xtgeo/include/eigen3/Eigen/PaStiXSupport +49 -0
  80. xtgeo/include/eigen3/Eigen/PardisoSupport +35 -0
  81. xtgeo/include/eigen3/Eigen/QR +50 -0
  82. xtgeo/include/eigen3/Eigen/QtAlignedMalloc +39 -0
  83. xtgeo/include/eigen3/Eigen/SPQRSupport +34 -0
  84. xtgeo/include/eigen3/Eigen/SVD +50 -0
  85. xtgeo/include/eigen3/Eigen/Sparse +34 -0
  86. xtgeo/include/eigen3/Eigen/SparseCholesky +37 -0
  87. xtgeo/include/eigen3/Eigen/SparseCore +69 -0
  88. xtgeo/include/eigen3/Eigen/SparseLU +50 -0
  89. xtgeo/include/eigen3/Eigen/SparseQR +36 -0
  90. xtgeo/include/eigen3/Eigen/StdDeque +27 -0
  91. xtgeo/include/eigen3/Eigen/StdList +26 -0
  92. xtgeo/include/eigen3/Eigen/StdVector +27 -0
  93. xtgeo/include/eigen3/Eigen/SuperLUSupport +64 -0
  94. xtgeo/include/eigen3/Eigen/UmfPackSupport +40 -0
  95. xtgeo/include/eigen3/Eigen/src/Cholesky/LDLT.h +688 -0
  96. xtgeo/include/eigen3/Eigen/src/Cholesky/LLT.h +558 -0
  97. xtgeo/include/eigen3/Eigen/src/Cholesky/LLT_LAPACKE.h +99 -0
  98. xtgeo/include/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h +682 -0
  99. xtgeo/include/eigen3/Eigen/src/Core/ArithmeticSequence.h +413 -0
  100. xtgeo/include/eigen3/Eigen/src/Core/Array.h +417 -0
  101. xtgeo/include/eigen3/Eigen/src/Core/ArrayBase.h +226 -0
  102. xtgeo/include/eigen3/Eigen/src/Core/ArrayWrapper.h +209 -0
  103. xtgeo/include/eigen3/Eigen/src/Core/Assign.h +90 -0
  104. xtgeo/include/eigen3/Eigen/src/Core/AssignEvaluator.h +1010 -0
  105. xtgeo/include/eigen3/Eigen/src/Core/Assign_MKL.h +178 -0
  106. xtgeo/include/eigen3/Eigen/src/Core/BandMatrix.h +353 -0
  107. xtgeo/include/eigen3/Eigen/src/Core/Block.h +448 -0
  108. xtgeo/include/eigen3/Eigen/src/Core/BooleanRedux.h +162 -0
  109. xtgeo/include/eigen3/Eigen/src/Core/CommaInitializer.h +164 -0
  110. xtgeo/include/eigen3/Eigen/src/Core/ConditionEstimator.h +175 -0
  111. xtgeo/include/eigen3/Eigen/src/Core/CoreEvaluators.h +1741 -0
  112. xtgeo/include/eigen3/Eigen/src/Core/CoreIterators.h +132 -0
  113. xtgeo/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h +183 -0
  114. xtgeo/include/eigen3/Eigen/src/Core/CwiseNullaryOp.h +1001 -0
  115. xtgeo/include/eigen3/Eigen/src/Core/CwiseTernaryOp.h +197 -0
  116. xtgeo/include/eigen3/Eigen/src/Core/CwiseUnaryOp.h +103 -0
  117. xtgeo/include/eigen3/Eigen/src/Core/CwiseUnaryView.h +132 -0
  118. xtgeo/include/eigen3/Eigen/src/Core/DenseBase.h +701 -0
  119. xtgeo/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h +685 -0
  120. xtgeo/include/eigen3/Eigen/src/Core/DenseStorage.h +652 -0
  121. xtgeo/include/eigen3/Eigen/src/Core/Diagonal.h +258 -0
  122. xtgeo/include/eigen3/Eigen/src/Core/DiagonalMatrix.h +391 -0
  123. xtgeo/include/eigen3/Eigen/src/Core/DiagonalProduct.h +28 -0
  124. xtgeo/include/eigen3/Eigen/src/Core/Dot.h +318 -0
  125. xtgeo/include/eigen3/Eigen/src/Core/EigenBase.h +160 -0
  126. xtgeo/include/eigen3/Eigen/src/Core/ForceAlignedAccess.h +150 -0
  127. xtgeo/include/eigen3/Eigen/src/Core/Fuzzy.h +155 -0
  128. xtgeo/include/eigen3/Eigen/src/Core/GeneralProduct.h +465 -0
  129. xtgeo/include/eigen3/Eigen/src/Core/GenericPacketMath.h +1040 -0
  130. xtgeo/include/eigen3/Eigen/src/Core/GlobalFunctions.h +194 -0
  131. xtgeo/include/eigen3/Eigen/src/Core/IO.h +258 -0
  132. xtgeo/include/eigen3/Eigen/src/Core/IndexedView.h +237 -0
  133. xtgeo/include/eigen3/Eigen/src/Core/Inverse.h +117 -0
  134. xtgeo/include/eigen3/Eigen/src/Core/Map.h +171 -0
  135. xtgeo/include/eigen3/Eigen/src/Core/MapBase.h +310 -0
  136. xtgeo/include/eigen3/Eigen/src/Core/MathFunctions.h +2057 -0
  137. xtgeo/include/eigen3/Eigen/src/Core/MathFunctionsImpl.h +200 -0
  138. xtgeo/include/eigen3/Eigen/src/Core/Matrix.h +565 -0
  139. xtgeo/include/eigen3/Eigen/src/Core/MatrixBase.h +547 -0
  140. xtgeo/include/eigen3/Eigen/src/Core/NestByValue.h +85 -0
  141. xtgeo/include/eigen3/Eigen/src/Core/NoAlias.h +109 -0
  142. xtgeo/include/eigen3/Eigen/src/Core/NumTraits.h +335 -0
  143. xtgeo/include/eigen3/Eigen/src/Core/PartialReduxEvaluator.h +232 -0
  144. xtgeo/include/eigen3/Eigen/src/Core/PermutationMatrix.h +605 -0
  145. xtgeo/include/eigen3/Eigen/src/Core/PlainObjectBase.h +1128 -0
  146. xtgeo/include/eigen3/Eigen/src/Core/Product.h +191 -0
  147. xtgeo/include/eigen3/Eigen/src/Core/ProductEvaluators.h +1179 -0
  148. xtgeo/include/eigen3/Eigen/src/Core/Random.h +218 -0
  149. xtgeo/include/eigen3/Eigen/src/Core/Redux.h +515 -0
  150. xtgeo/include/eigen3/Eigen/src/Core/Ref.h +381 -0
  151. xtgeo/include/eigen3/Eigen/src/Core/Replicate.h +142 -0
  152. xtgeo/include/eigen3/Eigen/src/Core/Reshaped.h +454 -0
  153. xtgeo/include/eigen3/Eigen/src/Core/ReturnByValue.h +119 -0
  154. xtgeo/include/eigen3/Eigen/src/Core/Reverse.h +217 -0
  155. xtgeo/include/eigen3/Eigen/src/Core/Select.h +164 -0
  156. xtgeo/include/eigen3/Eigen/src/Core/SelfAdjointView.h +365 -0
  157. xtgeo/include/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h +47 -0
  158. xtgeo/include/eigen3/Eigen/src/Core/Solve.h +188 -0
  159. xtgeo/include/eigen3/Eigen/src/Core/SolveTriangular.h +235 -0
  160. xtgeo/include/eigen3/Eigen/src/Core/SolverBase.h +168 -0
  161. xtgeo/include/eigen3/Eigen/src/Core/StableNorm.h +251 -0
  162. xtgeo/include/eigen3/Eigen/src/Core/StlIterators.h +463 -0
  163. xtgeo/include/eigen3/Eigen/src/Core/Stride.h +116 -0
  164. xtgeo/include/eigen3/Eigen/src/Core/Swap.h +68 -0
  165. xtgeo/include/eigen3/Eigen/src/Core/Transpose.h +464 -0
  166. xtgeo/include/eigen3/Eigen/src/Core/Transpositions.h +386 -0
  167. xtgeo/include/eigen3/Eigen/src/Core/TriangularMatrix.h +1001 -0
  168. xtgeo/include/eigen3/Eigen/src/Core/VectorBlock.h +96 -0
  169. xtgeo/include/eigen3/Eigen/src/Core/VectorwiseOp.h +784 -0
  170. xtgeo/include/eigen3/Eigen/src/Core/Visitor.h +381 -0
  171. xtgeo/include/eigen3/Eigen/src/Core/arch/AVX/Complex.h +372 -0
  172. xtgeo/include/eigen3/Eigen/src/Core/arch/AVX/MathFunctions.h +228 -0
  173. xtgeo/include/eigen3/Eigen/src/Core/arch/AVX/PacketMath.h +1574 -0
  174. xtgeo/include/eigen3/Eigen/src/Core/arch/AVX/TypeCasting.h +115 -0
  175. xtgeo/include/eigen3/Eigen/src/Core/arch/AVX512/Complex.h +422 -0
  176. xtgeo/include/eigen3/Eigen/src/Core/arch/AVX512/MathFunctions.h +362 -0
  177. xtgeo/include/eigen3/Eigen/src/Core/arch/AVX512/PacketMath.h +2303 -0
  178. xtgeo/include/eigen3/Eigen/src/Core/arch/AVX512/TypeCasting.h +89 -0
  179. xtgeo/include/eigen3/Eigen/src/Core/arch/AltiVec/Complex.h +417 -0
  180. xtgeo/include/eigen3/Eigen/src/Core/arch/AltiVec/MathFunctions.h +90 -0
  181. xtgeo/include/eigen3/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +2937 -0
  182. xtgeo/include/eigen3/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +221 -0
  183. xtgeo/include/eigen3/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +629 -0
  184. xtgeo/include/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h +2711 -0
  185. xtgeo/include/eigen3/Eigen/src/Core/arch/CUDA/Complex.h +258 -0
  186. xtgeo/include/eigen3/Eigen/src/Core/arch/Default/BFloat16.h +700 -0
  187. xtgeo/include/eigen3/Eigen/src/Core/arch/Default/ConjHelper.h +117 -0
  188. xtgeo/include/eigen3/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +1649 -0
  189. xtgeo/include/eigen3/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +110 -0
  190. xtgeo/include/eigen3/Eigen/src/Core/arch/Default/Half.h +942 -0
  191. xtgeo/include/eigen3/Eigen/src/Core/arch/Default/Settings.h +49 -0
  192. xtgeo/include/eigen3/Eigen/src/Core/arch/Default/TypeCasting.h +120 -0
  193. xtgeo/include/eigen3/Eigen/src/Core/arch/GPU/MathFunctions.h +103 -0
  194. xtgeo/include/eigen3/Eigen/src/Core/arch/GPU/PacketMath.h +1685 -0
  195. xtgeo/include/eigen3/Eigen/src/Core/arch/GPU/TypeCasting.h +80 -0
  196. xtgeo/include/eigen3/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
  197. xtgeo/include/eigen3/Eigen/src/Core/arch/MSA/Complex.h +648 -0
  198. xtgeo/include/eigen3/Eigen/src/Core/arch/MSA/MathFunctions.h +387 -0
  199. xtgeo/include/eigen3/Eigen/src/Core/arch/MSA/PacketMath.h +1233 -0
  200. xtgeo/include/eigen3/Eigen/src/Core/arch/NEON/Complex.h +584 -0
  201. xtgeo/include/eigen3/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +183 -0
  202. xtgeo/include/eigen3/Eigen/src/Core/arch/NEON/MathFunctions.h +75 -0
  203. xtgeo/include/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h +4587 -0
  204. xtgeo/include/eigen3/Eigen/src/Core/arch/NEON/TypeCasting.h +1419 -0
  205. xtgeo/include/eigen3/Eigen/src/Core/arch/SSE/Complex.h +351 -0
  206. xtgeo/include/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h +199 -0
  207. xtgeo/include/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h +1505 -0
  208. xtgeo/include/eigen3/Eigen/src/Core/arch/SSE/TypeCasting.h +142 -0
  209. xtgeo/include/eigen3/Eigen/src/Core/arch/SVE/MathFunctions.h +44 -0
  210. xtgeo/include/eigen3/Eigen/src/Core/arch/SVE/PacketMath.h +752 -0
  211. xtgeo/include/eigen3/Eigen/src/Core/arch/SVE/TypeCasting.h +49 -0
  212. xtgeo/include/eigen3/Eigen/src/Core/arch/SYCL/InteropHeaders.h +232 -0
  213. xtgeo/include/eigen3/Eigen/src/Core/arch/SYCL/MathFunctions.h +301 -0
  214. xtgeo/include/eigen3/Eigen/src/Core/arch/SYCL/PacketMath.h +670 -0
  215. xtgeo/include/eigen3/Eigen/src/Core/arch/SYCL/SyclMemoryModel.h +694 -0
  216. xtgeo/include/eigen3/Eigen/src/Core/arch/SYCL/TypeCasting.h +85 -0
  217. xtgeo/include/eigen3/Eigen/src/Core/arch/ZVector/Complex.h +426 -0
  218. xtgeo/include/eigen3/Eigen/src/Core/arch/ZVector/MathFunctions.h +233 -0
  219. xtgeo/include/eigen3/Eigen/src/Core/arch/ZVector/PacketMath.h +1060 -0
  220. xtgeo/include/eigen3/Eigen/src/Core/functors/AssignmentFunctors.h +177 -0
  221. xtgeo/include/eigen3/Eigen/src/Core/functors/BinaryFunctors.h +541 -0
  222. xtgeo/include/eigen3/Eigen/src/Core/functors/NullaryFunctors.h +189 -0
  223. xtgeo/include/eigen3/Eigen/src/Core/functors/StlFunctors.h +166 -0
  224. xtgeo/include/eigen3/Eigen/src/Core/functors/TernaryFunctors.h +25 -0
  225. xtgeo/include/eigen3/Eigen/src/Core/functors/UnaryFunctors.h +1131 -0
  226. xtgeo/include/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2645 -0
  227. xtgeo/include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix.h +517 -0
  228. xtgeo/include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +317 -0
  229. xtgeo/include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +145 -0
  230. xtgeo/include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +124 -0
  231. xtgeo/include/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h +518 -0
  232. xtgeo/include/eigen3/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +136 -0
  233. xtgeo/include/eigen3/Eigen/src/Core/products/Parallelizer.h +180 -0
  234. xtgeo/include/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +544 -0
  235. xtgeo/include/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +295 -0
  236. xtgeo/include/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h +262 -0
  237. xtgeo/include/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +118 -0
  238. xtgeo/include/eigen3/Eigen/src/Core/products/SelfadjointProduct.h +133 -0
  239. xtgeo/include/eigen3/Eigen/src/Core/products/SelfadjointRank2Update.h +94 -0
  240. xtgeo/include/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix.h +472 -0
  241. xtgeo/include/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +317 -0
  242. xtgeo/include/eigen3/Eigen/src/Core/products/TriangularMatrixVector.h +350 -0
  243. xtgeo/include/eigen3/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +255 -0
  244. xtgeo/include/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h +337 -0
  245. xtgeo/include/eigen3/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +167 -0
  246. xtgeo/include/eigen3/Eigen/src/Core/products/TriangularSolverVector.h +148 -0
  247. xtgeo/include/eigen3/Eigen/src/Core/util/BlasUtil.h +583 -0
  248. xtgeo/include/eigen3/Eigen/src/Core/util/ConfigureVectorization.h +512 -0
  249. xtgeo/include/eigen3/Eigen/src/Core/util/Constants.h +563 -0
  250. xtgeo/include/eigen3/Eigen/src/Core/util/DisableStupidWarnings.h +106 -0
  251. xtgeo/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h +322 -0
  252. xtgeo/include/eigen3/Eigen/src/Core/util/IndexedViewHelper.h +186 -0
  253. xtgeo/include/eigen3/Eigen/src/Core/util/IntegralConstant.h +272 -0
  254. xtgeo/include/eigen3/Eigen/src/Core/util/MKL_support.h +137 -0
  255. xtgeo/include/eigen3/Eigen/src/Core/util/Macros.h +1464 -0
  256. xtgeo/include/eigen3/Eigen/src/Core/util/Memory.h +1163 -0
  257. xtgeo/include/eigen3/Eigen/src/Core/util/Meta.h +812 -0
  258. xtgeo/include/eigen3/Eigen/src/Core/util/NonMPL2.h +3 -0
  259. xtgeo/include/eigen3/Eigen/src/Core/util/ReenableStupidWarnings.h +31 -0
  260. xtgeo/include/eigen3/Eigen/src/Core/util/ReshapedHelper.h +51 -0
  261. xtgeo/include/eigen3/Eigen/src/Core/util/StaticAssert.h +221 -0
  262. xtgeo/include/eigen3/Eigen/src/Core/util/SymbolicIndex.h +293 -0
  263. xtgeo/include/eigen3/Eigen/src/Core/util/XprHelper.h +856 -0
  264. xtgeo/include/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h +346 -0
  265. xtgeo/include/eigen3/Eigen/src/Eigenvalues/ComplexSchur.h +462 -0
  266. xtgeo/include/eigen3/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +91 -0
  267. xtgeo/include/eigen3/Eigen/src/Eigenvalues/EigenSolver.h +622 -0
  268. xtgeo/include/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +418 -0
  269. xtgeo/include/eigen3/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +226 -0
  270. xtgeo/include/eigen3/Eigen/src/Eigenvalues/HessenbergDecomposition.h +374 -0
  271. xtgeo/include/eigen3/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +158 -0
  272. xtgeo/include/eigen3/Eigen/src/Eigenvalues/RealQZ.h +657 -0
  273. xtgeo/include/eigen3/Eigen/src/Eigenvalues/RealSchur.h +558 -0
  274. xtgeo/include/eigen3/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +77 -0
  275. xtgeo/include/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +904 -0
  276. xtgeo/include/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +87 -0
  277. xtgeo/include/eigen3/Eigen/src/Eigenvalues/Tridiagonalization.h +561 -0
  278. xtgeo/include/eigen3/Eigen/src/Geometry/AlignedBox.h +486 -0
  279. xtgeo/include/eigen3/Eigen/src/Geometry/AngleAxis.h +247 -0
  280. xtgeo/include/eigen3/Eigen/src/Geometry/EulerAngles.h +114 -0
  281. xtgeo/include/eigen3/Eigen/src/Geometry/Homogeneous.h +501 -0
  282. xtgeo/include/eigen3/Eigen/src/Geometry/Hyperplane.h +282 -0
  283. xtgeo/include/eigen3/Eigen/src/Geometry/OrthoMethods.h +235 -0
  284. xtgeo/include/eigen3/Eigen/src/Geometry/ParametrizedLine.h +232 -0
  285. xtgeo/include/eigen3/Eigen/src/Geometry/Quaternion.h +870 -0
  286. xtgeo/include/eigen3/Eigen/src/Geometry/Rotation2D.h +199 -0
  287. xtgeo/include/eigen3/Eigen/src/Geometry/RotationBase.h +206 -0
  288. xtgeo/include/eigen3/Eigen/src/Geometry/Scaling.h +188 -0
  289. xtgeo/include/eigen3/Eigen/src/Geometry/Transform.h +1563 -0
  290. xtgeo/include/eigen3/Eigen/src/Geometry/Translation.h +202 -0
  291. xtgeo/include/eigen3/Eigen/src/Geometry/Umeyama.h +166 -0
  292. xtgeo/include/eigen3/Eigen/src/Geometry/arch/Geometry_SIMD.h +168 -0
  293. xtgeo/include/eigen3/Eigen/src/Householder/BlockHouseholder.h +110 -0
  294. xtgeo/include/eigen3/Eigen/src/Householder/Householder.h +176 -0
  295. xtgeo/include/eigen3/Eigen/src/Householder/HouseholderSequence.h +545 -0
  296. xtgeo/include/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +226 -0
  297. xtgeo/include/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +212 -0
  298. xtgeo/include/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +229 -0
  299. xtgeo/include/eigen3/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +394 -0
  300. xtgeo/include/eigen3/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +453 -0
  301. xtgeo/include/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +444 -0
  302. xtgeo/include/eigen3/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +198 -0
  303. xtgeo/include/eigen3/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +117 -0
  304. xtgeo/include/eigen3/Eigen/src/Jacobi/Jacobi.h +483 -0
  305. xtgeo/include/eigen3/Eigen/src/KLUSupport/KLUSupport.h +358 -0
  306. xtgeo/include/eigen3/Eigen/src/LU/Determinant.h +117 -0
  307. xtgeo/include/eigen3/Eigen/src/LU/FullPivLU.h +877 -0
  308. xtgeo/include/eigen3/Eigen/src/LU/InverseImpl.h +432 -0
  309. xtgeo/include/eigen3/Eigen/src/LU/PartialPivLU.h +624 -0
  310. xtgeo/include/eigen3/Eigen/src/LU/PartialPivLU_LAPACKE.h +83 -0
  311. xtgeo/include/eigen3/Eigen/src/LU/arch/InverseSize4.h +351 -0
  312. xtgeo/include/eigen3/Eigen/src/MetisSupport/MetisSupport.h +137 -0
  313. xtgeo/include/eigen3/Eigen/src/OrderingMethods/Amd.h +435 -0
  314. xtgeo/include/eigen3/Eigen/src/OrderingMethods/Eigen_Colamd.h +1863 -0
  315. xtgeo/include/eigen3/Eigen/src/OrderingMethods/Ordering.h +153 -0
  316. xtgeo/include/eigen3/Eigen/src/PaStiXSupport/PaStiXSupport.h +678 -0
  317. xtgeo/include/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h +545 -0
  318. xtgeo/include/eigen3/Eigen/src/QR/ColPivHouseholderQR.h +674 -0
  319. xtgeo/include/eigen3/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +97 -0
  320. xtgeo/include/eigen3/Eigen/src/QR/CompleteOrthogonalDecomposition.h +635 -0
  321. xtgeo/include/eigen3/Eigen/src/QR/FullPivHouseholderQR.h +713 -0
  322. xtgeo/include/eigen3/Eigen/src/QR/HouseholderQR.h +434 -0
  323. xtgeo/include/eigen3/Eigen/src/QR/HouseholderQR_LAPACKE.h +68 -0
  324. xtgeo/include/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +335 -0
  325. xtgeo/include/eigen3/Eigen/src/SVD/BDCSVD.h +1366 -0
  326. xtgeo/include/eigen3/Eigen/src/SVD/JacobiSVD.h +812 -0
  327. xtgeo/include/eigen3/Eigen/src/SVD/JacobiSVD_LAPACKE.h +91 -0
  328. xtgeo/include/eigen3/Eigen/src/SVD/SVDBase.h +376 -0
  329. xtgeo/include/eigen3/Eigen/src/SVD/UpperBidiagonalization.h +414 -0
  330. xtgeo/include/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h +697 -0
  331. xtgeo/include/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +174 -0
  332. xtgeo/include/eigen3/Eigen/src/SparseCore/AmbiVector.h +378 -0
  333. xtgeo/include/eigen3/Eigen/src/SparseCore/CompressedStorage.h +274 -0
  334. xtgeo/include/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +352 -0
  335. xtgeo/include/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h +67 -0
  336. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseAssign.h +270 -0
  337. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseBlock.h +571 -0
  338. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseColEtree.h +206 -0
  339. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseCompressedBase.h +370 -0
  340. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +722 -0
  341. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +150 -0
  342. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h +342 -0
  343. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseDiagonalProduct.h +138 -0
  344. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseDot.h +98 -0
  345. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseFuzzy.h +29 -0
  346. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseMap.h +305 -0
  347. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseMatrix.h +1518 -0
  348. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h +398 -0
  349. xtgeo/include/eigen3/Eigen/src/SparseCore/SparsePermutation.h +178 -0
  350. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseProduct.h +181 -0
  351. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseRedux.h +49 -0
  352. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseRef.h +397 -0
  353. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseSelfAdjointView.h +659 -0
  354. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseSolverBase.h +124 -0
  355. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +198 -0
  356. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseTranspose.h +92 -0
  357. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseTriangularView.h +189 -0
  358. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseUtil.h +186 -0
  359. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseVector.h +478 -0
  360. xtgeo/include/eigen3/Eigen/src/SparseCore/SparseView.h +254 -0
  361. xtgeo/include/eigen3/Eigen/src/SparseCore/TriangularSolver.h +315 -0
  362. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU.h +923 -0
  363. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
  364. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_Memory.h +226 -0
  365. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_Structs.h +110 -0
  366. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +375 -0
  367. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
  368. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_column_bmod.h +181 -0
  369. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_column_dfs.h +179 -0
  370. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +107 -0
  371. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +280 -0
  372. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +126 -0
  373. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
  374. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
  375. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
  376. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
  377. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_pruneL.h +136 -0
  378. xtgeo/include/eigen3/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
  379. xtgeo/include/eigen3/Eigen/src/SparseQR/SparseQR.h +758 -0
  380. xtgeo/include/eigen3/Eigen/src/StlSupport/StdDeque.h +116 -0
  381. xtgeo/include/eigen3/Eigen/src/StlSupport/StdList.h +106 -0
  382. xtgeo/include/eigen3/Eigen/src/StlSupport/StdVector.h +131 -0
  383. xtgeo/include/eigen3/Eigen/src/StlSupport/details.h +84 -0
  384. xtgeo/include/eigen3/Eigen/src/SuperLUSupport/SuperLUSupport.h +1025 -0
  385. xtgeo/include/eigen3/Eigen/src/UmfPackSupport/UmfPackSupport.h +642 -0
  386. xtgeo/include/eigen3/Eigen/src/misc/Image.h +82 -0
  387. xtgeo/include/eigen3/Eigen/src/misc/Kernel.h +79 -0
  388. xtgeo/include/eigen3/Eigen/src/misc/RealSvd2x2.h +55 -0
  389. xtgeo/include/eigen3/Eigen/src/misc/blas.h +440 -0
  390. xtgeo/include/eigen3/Eigen/src/misc/lapack.h +152 -0
  391. xtgeo/include/eigen3/Eigen/src/misc/lapacke.h +16292 -0
  392. xtgeo/include/eigen3/Eigen/src/misc/lapacke_mangling.h +17 -0
  393. xtgeo/include/eigen3/Eigen/src/plugins/ArrayCwiseBinaryOps.h +358 -0
  394. xtgeo/include/eigen3/Eigen/src/plugins/ArrayCwiseUnaryOps.h +696 -0
  395. xtgeo/include/eigen3/Eigen/src/plugins/BlockMethods.h +1442 -0
  396. xtgeo/include/eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h +115 -0
  397. xtgeo/include/eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h +177 -0
  398. xtgeo/include/eigen3/Eigen/src/plugins/IndexedViewMethods.h +262 -0
  399. xtgeo/include/eigen3/Eigen/src/plugins/MatrixCwiseBinaryOps.h +152 -0
  400. xtgeo/include/eigen3/Eigen/src/plugins/MatrixCwiseUnaryOps.h +95 -0
  401. xtgeo/include/eigen3/Eigen/src/plugins/ReshapedMethods.h +149 -0
  402. xtgeo/include/eigen3/signature_of_eigen3_matrix_library +1 -0
  403. xtgeo/include/eigen3/unsupported/Eigen/AdolcForward +159 -0
  404. xtgeo/include/eigen3/unsupported/Eigen/AlignedVector3 +234 -0
  405. xtgeo/include/eigen3/unsupported/Eigen/ArpackSupport +30 -0
  406. xtgeo/include/eigen3/unsupported/Eigen/AutoDiff +46 -0
  407. xtgeo/include/eigen3/unsupported/Eigen/BVH +95 -0
  408. xtgeo/include/eigen3/unsupported/Eigen/CXX11/Tensor +137 -0
  409. xtgeo/include/eigen3/unsupported/Eigen/CXX11/TensorSymmetry +42 -0
  410. xtgeo/include/eigen3/unsupported/Eigen/CXX11/ThreadPool +74 -0
  411. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/Tensor.h +554 -0
  412. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorArgMax.h +329 -0
  413. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h +247 -0
  414. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h +1176 -0
  415. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h +1559 -0
  416. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h +1093 -0
  417. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h +518 -0
  418. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorConcatenation.h +377 -0
  419. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContraction.h +1023 -0
  420. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionBlocking.h +73 -0
  421. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionCuda.h +6 -0
  422. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionGpu.h +1413 -0
  423. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionMapper.h +575 -0
  424. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionSycl.h +1650 -0
  425. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionThreadPool.h +1679 -0
  426. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h +456 -0
  427. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorConvolution.h +1132 -0
  428. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorConvolutionSycl.h +544 -0
  429. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorCostModel.h +214 -0
  430. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorCustomOp.h +347 -0
  431. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDevice.h +137 -0
  432. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceCuda.h +6 -0
  433. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceDefault.h +104 -0
  434. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h +389 -0
  435. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h +1048 -0
  436. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h +409 -0
  437. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h +236 -0
  438. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h +490 -0
  439. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorEvalTo.h +236 -0
  440. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h +983 -0
  441. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h +703 -0
  442. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorExpr.h +388 -0
  443. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorFFT.h +669 -0
  444. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h +379 -0
  445. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h +237 -0
  446. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorForwardDeclarations.h +191 -0
  447. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h +488 -0
  448. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorGenerator.h +302 -0
  449. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorGlobalFunctions.h +33 -0
  450. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorGpuHipCudaDefines.h +99 -0
  451. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorGpuHipCudaUndefines.h +44 -0
  452. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h +79 -0
  453. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h +603 -0
  454. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h +738 -0
  455. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorInflation.h +247 -0
  456. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorInitializer.h +82 -0
  457. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h +263 -0
  458. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h +216 -0
  459. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMacros.h +98 -0
  460. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h +327 -0
  461. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h +311 -0
  462. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h +1102 -0
  463. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h +708 -0
  464. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h +291 -0
  465. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorRandom.h +322 -0
  466. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +998 -0
  467. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorReductionCuda.h +6 -0
  468. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorReductionGpu.h +966 -0
  469. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorReductionSycl.h +582 -0
  470. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorRef.h +454 -0
  471. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h +465 -0
  472. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorScan.h +528 -0
  473. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorScanSycl.h +513 -0
  474. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h +471 -0
  475. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h +161 -0
  476. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h +346 -0
  477. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorTrace.h +303 -0
  478. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h +264 -0
  479. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h +249 -0
  480. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h +629 -0
  481. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/TensorSymmetry/DynamicSymmetry.h +293 -0
  482. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/TensorSymmetry/StaticSymmetry.h +236 -0
  483. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/TensorSymmetry/Symmetry.h +338 -0
  484. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/TensorSymmetry/util/TemplateGroupTheory.h +669 -0
  485. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/Barrier.h +67 -0
  486. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/EventCount.h +249 -0
  487. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h +486 -0
  488. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/RunQueue.h +236 -0
  489. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/ThreadCancel.h +23 -0
  490. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/ThreadEnvironment.h +40 -0
  491. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/ThreadLocal.h +301 -0
  492. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/ThreadPoolInterface.h +48 -0
  493. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/ThreadYield.h +20 -0
  494. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/util/CXX11Meta.h +537 -0
  495. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/util/CXX11Workarounds.h +88 -0
  496. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/util/EmulateArray.h +261 -0
  497. xtgeo/include/eigen3/unsupported/Eigen/CXX11/src/util/MaxSizeVector.h +158 -0
  498. xtgeo/include/eigen3/unsupported/Eigen/EulerAngles +43 -0
  499. xtgeo/include/eigen3/unsupported/Eigen/FFT +419 -0
  500. xtgeo/include/eigen3/unsupported/Eigen/IterativeSolvers +51 -0
  501. xtgeo/include/eigen3/unsupported/Eigen/KroneckerProduct +36 -0
  502. xtgeo/include/eigen3/unsupported/Eigen/LevenbergMarquardt +49 -0
  503. xtgeo/include/eigen3/unsupported/Eigen/MPRealSupport +213 -0
  504. xtgeo/include/eigen3/unsupported/Eigen/MatrixFunctions +504 -0
  505. xtgeo/include/eigen3/unsupported/Eigen/MoreVectorization +24 -0
  506. xtgeo/include/eigen3/unsupported/Eigen/NonLinearOptimization +140 -0
  507. xtgeo/include/eigen3/unsupported/Eigen/NumericalDiff +56 -0
  508. xtgeo/include/eigen3/unsupported/Eigen/OpenGLSupport +322 -0
  509. xtgeo/include/eigen3/unsupported/Eigen/Polynomials +137 -0
  510. xtgeo/include/eigen3/unsupported/Eigen/Skyline +39 -0
  511. xtgeo/include/eigen3/unsupported/Eigen/SparseExtra +54 -0
  512. xtgeo/include/eigen3/unsupported/Eigen/SpecialFunctions +103 -0
  513. xtgeo/include/eigen3/unsupported/Eigen/Splines +35 -0
  514. xtgeo/include/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h +108 -0
  515. xtgeo/include/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h +730 -0
  516. xtgeo/include/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h +220 -0
  517. xtgeo/include/eigen3/unsupported/Eigen/src/BVH/BVAlgorithms.h +293 -0
  518. xtgeo/include/eigen3/unsupported/Eigen/src/BVH/KdBVH.h +223 -0
  519. xtgeo/include/eigen3/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h +790 -0
  520. xtgeo/include/eigen3/unsupported/Eigen/src/EulerAngles/EulerAngles.h +355 -0
  521. xtgeo/include/eigen3/unsupported/Eigen/src/EulerAngles/EulerSystem.h +305 -0
  522. xtgeo/include/eigen3/unsupported/Eigen/src/FFT/ei_fftw_impl.h +261 -0
  523. xtgeo/include/eigen3/unsupported/Eigen/src/FFT/ei_kissfft_impl.h +449 -0
  524. xtgeo/include/eigen3/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h +187 -0
  525. xtgeo/include/eigen3/unsupported/Eigen/src/IterativeSolvers/DGMRES.h +511 -0
  526. xtgeo/include/eigen3/unsupported/Eigen/src/IterativeSolvers/GMRES.h +335 -0
  527. xtgeo/include/eigen3/unsupported/Eigen/src/IterativeSolvers/IDRS.h +436 -0
  528. xtgeo/include/eigen3/unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h +90 -0
  529. xtgeo/include/eigen3/unsupported/Eigen/src/IterativeSolvers/IterationController.h +154 -0
  530. xtgeo/include/eigen3/unsupported/Eigen/src/IterativeSolvers/MINRES.h +267 -0
  531. xtgeo/include/eigen3/unsupported/Eigen/src/IterativeSolvers/Scaling.h +193 -0
  532. xtgeo/include/eigen3/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h +305 -0
  533. xtgeo/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h +84 -0
  534. xtgeo/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h +202 -0
  535. xtgeo/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMpar.h +160 -0
  536. xtgeo/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h +188 -0
  537. xtgeo/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h +396 -0
  538. xtgeo/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h +441 -0
  539. xtgeo/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h +569 -0
  540. xtgeo/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h +373 -0
  541. xtgeo/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h +705 -0
  542. xtgeo/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h +368 -0
  543. xtgeo/include/eigen3/unsupported/Eigen/src/MatrixFunctions/StemFunction.h +117 -0
  544. xtgeo/include/eigen3/unsupported/Eigen/src/MoreVectorization/MathFunctions.h +95 -0
  545. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h +601 -0
  546. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h +657 -0
  547. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/chkder.h +66 -0
  548. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/covar.h +70 -0
  549. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/dogleg.h +107 -0
  550. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h +79 -0
  551. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/lmpar.h +298 -0
  552. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h +91 -0
  553. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h +30 -0
  554. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/r1updt.h +99 -0
  555. xtgeo/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h +49 -0
  556. xtgeo/include/eigen3/unsupported/Eigen/src/NumericalDiff/NumericalDiff.h +130 -0
  557. xtgeo/include/eigen3/unsupported/Eigen/src/Polynomials/Companion.h +280 -0
  558. xtgeo/include/eigen3/unsupported/Eigen/src/Polynomials/PolynomialSolver.h +428 -0
  559. xtgeo/include/eigen3/unsupported/Eigen/src/Polynomials/PolynomialUtils.h +143 -0
  560. xtgeo/include/eigen3/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h +352 -0
  561. xtgeo/include/eigen3/unsupported/Eigen/src/Skyline/SkylineMatrix.h +862 -0
  562. xtgeo/include/eigen3/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h +212 -0
  563. xtgeo/include/eigen3/unsupported/Eigen/src/Skyline/SkylineProduct.h +295 -0
  564. xtgeo/include/eigen3/unsupported/Eigen/src/Skyline/SkylineStorage.h +259 -0
  565. xtgeo/include/eigen3/unsupported/Eigen/src/Skyline/SkylineUtil.h +89 -0
  566. xtgeo/include/eigen3/unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h +122 -0
  567. xtgeo/include/eigen3/unsupported/Eigen/src/SparseExtra/BlockSparseMatrix.h +1079 -0
  568. xtgeo/include/eigen3/unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h +404 -0
  569. xtgeo/include/eigen3/unsupported/Eigen/src/SparseExtra/MarketIO.h +282 -0
  570. xtgeo/include/eigen3/unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h +247 -0
  571. xtgeo/include/eigen3/unsupported/Eigen/src/SparseExtra/RandomSetter.h +349 -0
  572. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsArrayAPI.h +286 -0
  573. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsBFloat16.h +68 -0
  574. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsFunctors.h +357 -0
  575. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsHalf.h +66 -0
  576. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsImpl.h +1959 -0
  577. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsPacketMath.h +118 -0
  578. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/HipVectorCompatibility.h +67 -0
  579. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsArrayAPI.h +167 -0
  580. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsBFloat16.h +58 -0
  581. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsFunctors.h +330 -0
  582. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsHalf.h +58 -0
  583. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsImpl.h +2045 -0
  584. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsPacketMath.h +79 -0
  585. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/AVX/BesselFunctions.h +46 -0
  586. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/AVX/SpecialFunctions.h +16 -0
  587. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/AVX512/BesselFunctions.h +46 -0
  588. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/AVX512/SpecialFunctions.h +16 -0
  589. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/GPU/SpecialFunctions.h +369 -0
  590. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/NEON/BesselFunctions.h +54 -0
  591. xtgeo/include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/NEON/SpecialFunctions.h +34 -0
  592. xtgeo/include/eigen3/unsupported/Eigen/src/Splines/Spline.h +507 -0
  593. xtgeo/include/eigen3/unsupported/Eigen/src/Splines/SplineFitting.h +431 -0
  594. xtgeo/include/eigen3/unsupported/Eigen/src/Splines/SplineFwd.h +93 -0
  595. xtgeo/interfaces/rms/__init__.py +18 -0
  596. xtgeo/interfaces/rms/_regular_surface.py +460 -0
  597. xtgeo/interfaces/rms/_rms_base.py +100 -0
  598. xtgeo/interfaces/rms/_rmsapi_package.py +69 -0
  599. xtgeo/interfaces/rms/rmsapi_utils.py +438 -0
  600. xtgeo/io/__init__.py +1 -0
  601. xtgeo/io/_file.py +603 -0
  602. xtgeo/metadata/__init__.py +17 -0
  603. xtgeo/metadata/metadata.py +435 -0
  604. xtgeo/roxutils/__init__.py +7 -0
  605. xtgeo/roxutils/_roxar_loader.py +54 -0
  606. xtgeo/roxutils/_roxutils_etc.py +122 -0
  607. xtgeo/roxutils/roxutils.py +207 -0
  608. xtgeo/share/eigen3/cmake/Eigen3Config.cmake +37 -0
  609. xtgeo/share/eigen3/cmake/Eigen3ConfigVersion.cmake +65 -0
  610. xtgeo/share/eigen3/cmake/Eigen3Targets.cmake +106 -0
  611. xtgeo/share/eigen3/cmake/UseEigen3.cmake +6 -0
  612. xtgeo/share/pkgconfig/eigen3.pc +9 -0
  613. xtgeo/surface/__init__.py +20 -0
  614. xtgeo/surface/_regsurf_boundary.py +26 -0
  615. xtgeo/surface/_regsurf_cube.py +210 -0
  616. xtgeo/surface/_regsurf_cube_window.py +391 -0
  617. xtgeo/surface/_regsurf_cube_window_v2.py +297 -0
  618. xtgeo/surface/_regsurf_cube_window_v3.py +360 -0
  619. xtgeo/surface/_regsurf_export.py +388 -0
  620. xtgeo/surface/_regsurf_grid3d.py +275 -0
  621. xtgeo/surface/_regsurf_gridding.py +347 -0
  622. xtgeo/surface/_regsurf_ijxyz_parser.py +278 -0
  623. xtgeo/surface/_regsurf_import.py +347 -0
  624. xtgeo/surface/_regsurf_lowlevel.py +122 -0
  625. xtgeo/surface/_regsurf_oper.py +538 -0
  626. xtgeo/surface/_regsurf_utils.py +81 -0
  627. xtgeo/surface/_surfs_import.py +43 -0
  628. xtgeo/surface/_zmap_parser.py +138 -0
  629. xtgeo/surface/regular_surface.py +3043 -0
  630. xtgeo/surface/surfaces.py +276 -0
  631. xtgeo/well/__init__.py +24 -0
  632. xtgeo/well/_blockedwell_roxapi.py +241 -0
  633. xtgeo/well/_blockedwells_roxapi.py +68 -0
  634. xtgeo/well/_well_aux.py +30 -0
  635. xtgeo/well/_well_io.py +327 -0
  636. xtgeo/well/_well_oper.py +483 -0
  637. xtgeo/well/_well_roxapi.py +304 -0
  638. xtgeo/well/_wellmarkers.py +486 -0
  639. xtgeo/well/_wells_utils.py +158 -0
  640. xtgeo/well/blocked_well.py +220 -0
  641. xtgeo/well/blocked_wells.py +134 -0
  642. xtgeo/well/well1.py +1516 -0
  643. xtgeo/well/wells.py +211 -0
  644. xtgeo/xyz/__init__.py +6 -0
  645. xtgeo/xyz/_polygons_oper.py +272 -0
  646. xtgeo/xyz/_xyz.py +758 -0
  647. xtgeo/xyz/_xyz_data.py +646 -0
  648. xtgeo/xyz/_xyz_io.py +737 -0
  649. xtgeo/xyz/_xyz_lowlevel.py +42 -0
  650. xtgeo/xyz/_xyz_oper.py +613 -0
  651. xtgeo/xyz/_xyz_roxapi.py +766 -0
  652. xtgeo/xyz/points.py +698 -0
  653. xtgeo/xyz/polygons.py +827 -0
  654. xtgeo-4.14.0.dist-info/METADATA +146 -0
  655. xtgeo-4.14.0.dist-info/RECORD +658 -0
  656. xtgeo-4.14.0.dist-info/WHEEL +6 -0
  657. xtgeo-4.14.0.dist-info/licenses/LICENSE.md +165 -0
  658. xtgeo.libs/libgomp-a49a47f9.so.1.0.0 +0 -0
xtgeo/grid3d/grid.py ADDED
@@ -0,0 +1,3010 @@
1
+ """Module/class for 3D grids (corner point geometry) with XTGeo."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import TYPE_CHECKING, Any, Literal
7
+
8
+ import numpy as np
9
+ import numpy.ma as ma
10
+
11
+ import xtgeo
12
+ import xtgeo._internal as _internal # type: ignore
13
+ from xtgeo import _cxtgeo
14
+ from xtgeo.common import XTGDescription, null_logger
15
+ from xtgeo.common.exceptions import InvalidFileFormatError
16
+ from xtgeo.common.sys import generic_hash
17
+ from xtgeo.common.types import Dimensions
18
+ from xtgeo.io._file import FileFormat, FileWrapper
19
+ from xtgeo.surface.regular_surface import surface_from_grid3d
20
+
21
+ from . import (
22
+ _grid3d_fence,
23
+ _grid_boundary,
24
+ _grid_etc1,
25
+ _grid_export,
26
+ _grid_hybrid,
27
+ _grid_import,
28
+ _grid_import_ecl,
29
+ _grid_refine,
30
+ _grid_roxapi,
31
+ _grid_translate_coords,
32
+ _grid_wellzone,
33
+ _gridprop_lowlevel,
34
+ )
35
+ from ._grid3d import _Grid3D
36
+ from .grid_properties import GridProperties
37
+
38
+ if TYPE_CHECKING:
39
+ import pathlib
40
+ from collections.abc import Callable, Hashable
41
+
42
+ import pandas as pd
43
+
44
+ from xtgeo import Polygons, Well
45
+ from xtgeo._internal.grid3d import Grid as GridCPP # type: ignore
46
+ from xtgeo._internal.regsurf import ( # type: ignore
47
+ RegularSurface as RegularSurfaceCPP,
48
+ )
49
+ from xtgeo.common.types import FileLike
50
+ from xtgeo.xyz.points import Points
51
+
52
+ from ._ecl_grid import Units
53
+ from .grid_property import GridProperty
54
+ from .types import METRIC
55
+
56
+ xtg = xtgeo.common.XTGeoDialog()
57
+ logger = null_logger(__name__)
58
+
59
+ # --------------------------------------------------------------------------------------
60
+ # Comment on "asmasked" vs "activeonly:
61
+ #
62
+ # "asmasked"=True will return a np.ma array, while "asmasked" = False will
63
+ # return a np.ndarray
64
+ #
65
+ # The "activeonly" will filter out masked entries, or use None or np.nan
66
+ # if "activeonly" is False.
67
+ #
68
+ # Use word "zerobased" for a bool regarding if startcell basis is 1 or 0
69
+ #
70
+ # For functions with mask=... ,they should be replaced with asmasked=...
71
+ # --------------------------------------------------------------------------------------
72
+
73
+
74
+ def _estimate_grid_ijk_handedness(coordsv: np.array) -> Literal["left", "right"] | None:
75
+ """Helper: estimate the ijk handedness from the coordinates.
76
+
77
+ Args:
78
+ coordsv: The coordinates (coordsv) of the grid.
79
+
80
+ Returns:
81
+ "left" or "right" depending on the handedness, or None if cannot determine
82
+
83
+ Note:
84
+ Z array is always assumed positive downwards
85
+ """
86
+ p0 = coordsv[0, 0, 0:3] # origin
87
+ pz = coordsv[0, 0, 3:6] # layer direction
88
+ px = coordsv[-1, 0, 0:3] # columns direction, aka X
89
+ py = coordsv[0, -1, 0:3] # rows direction, aka Y
90
+
91
+ # sometimes the pillars are collapsed; assume that the pillars are postive down
92
+ if pz[2] <= p0[2]:
93
+ pz[2] = p0[2] + 0.001
94
+
95
+ # multiply z by -1 since system is Z positive down
96
+ p0[2] *= -1
97
+ pz[2] *= -1
98
+ px[2] *= -1
99
+ py[2] *= -1
100
+
101
+ vx = np.array(px) - np.array(p0)
102
+ vy = np.array(py) - np.array(p0)
103
+ vz = np.array(pz) - np.array(p0)
104
+ det = np.dot(np.cross(vx, vy), vz)
105
+
106
+ if det > 0:
107
+ return "right"
108
+
109
+ if det < 0:
110
+ return "left"
111
+
112
+ return None
113
+
114
+
115
+ # METHODS as wrappers to class init + import
116
+ def _handle_import(
117
+ grid_constructor: Callable[..., Grid],
118
+ gfile: FileLike | FileWrapper,
119
+ fformat: str | None = None,
120
+ **kwargs: dict,
121
+ ) -> Grid:
122
+ """Handles the import given a constructor.
123
+
124
+ For backwards compatability we need to call different constructors
125
+ with grid __init__ parameters (As returned by _grid_import.from_file).
126
+ These are generally either the _reset method of an instance or Grid().
127
+
128
+ This function takes such a constructor, remaining arguments are interpreted
129
+ as they are in _grid_import.from_file and calls the constructor with the
130
+ resulting arguments.
131
+
132
+ """
133
+ gfile = FileWrapper(gfile, mode="rb")
134
+ if fformat == "eclipserun":
135
+ ecl_grid = grid_constructor(
136
+ **_grid_import.from_file(
137
+ FileWrapper(gfile.name + ".EGRID", mode="rb"), fformat=FileFormat.EGRID
138
+ )
139
+ )
140
+ _grid_import_ecl.import_ecl_run(gfile.name, ecl_grid=ecl_grid, **kwargs)
141
+ return ecl_grid
142
+
143
+ fmt = gfile.fileformat(fformat)
144
+ return grid_constructor(**_grid_import.from_file(gfile, fmt, **kwargs))
145
+
146
+
147
+ def grid_from_file(
148
+ gfile: FileLike | FileWrapper,
149
+ fformat: str | None = None,
150
+ **kwargs: dict[str, Any],
151
+ ) -> Grid:
152
+ """Read a grid (cornerpoint) from filelike and an returns a Grid() instance.
153
+
154
+ Args:
155
+ gfile: File name to be imported. If fformat="eclipse_run"
156
+ then a fileroot name shall be input here, see example below.
157
+ fformat: File format egrid/roff/grdecl/bgrdecl/eclipserun/xtgcpgeom
158
+ (None is default and means "guess")
159
+ initprops (str list): Optional, and only applicable for file format
160
+ "eclipserun". Provide a list the names of the properties here. A
161
+ special value "all" can be get all properties found in the INIT file
162
+ restartprops (str list): Optional, see initprops
163
+ restartdates (int list): Optional, required if restartprops
164
+ ijkrange (list-like): Optional, only applicable for hdf files, see
165
+ :meth:`Grid.from_hdf`.
166
+ zerobased (bool): Optional, only applicable for hdf files, see
167
+ :meth:`Grid.from_hdf`.
168
+ mmap (bool): Optional, only applicable for xtgf files, see
169
+ :meth:`Grid.from_xtgf`.
170
+
171
+ Example::
172
+
173
+ >>> import xtgeo
174
+ >>> mygrid = xtgeo.grid_from_file(reek_dir + "/REEK.EGRID")
175
+
176
+ Example using "eclipserun"::
177
+
178
+ >>> mycase = "REEK" # meaning REEK.EGRID, REEK.INIT, REEK.UNRST
179
+ >>> xg = xtgeo.grid_from_file(
180
+ ... reek_dir + "/" + mycase,
181
+ ... fformat="eclipserun",
182
+ ... initprops="all",
183
+ ... )
184
+ Grid ... filesrc='.../REEK.EGRID'
185
+
186
+ Raises:
187
+ OSError: if file is not found etc
188
+
189
+ """
190
+ return _handle_import(Grid, gfile, fformat, **kwargs)
191
+
192
+
193
+ def grid_from_roxar(
194
+ project: str,
195
+ gname: str,
196
+ realisation: int = 0,
197
+ info: bool = False,
198
+ ) -> Grid:
199
+ """Read a 3D grid inside a RMS project and return a Grid() instance.
200
+
201
+ Args:
202
+ project (str or special): The RMS project or the project variable
203
+ from inside RMS.
204
+ gname (str): Name of Grid Model in RMS.
205
+ realisation (int): Realisation number.
206
+ dimensions_only (bool): If True, only the ncol, nrow, nlay will
207
+ read. The actual grid geometry will remain empty (None). This will
208
+ be much faster of only grid size info is needed, e.g.
209
+ for initalising a grid property.
210
+ info (bool): If true, only grid info
211
+
212
+ Example::
213
+
214
+ # inside RMS
215
+ import xtgeo
216
+ mygrid = xtgeo.grid_from_roxar(project, "REEK_SIM")
217
+
218
+ """
219
+ return Grid(**_grid_roxapi.load_grid_from_rms(project, gname, realisation, info))
220
+
221
+
222
+ def create_box_grid(
223
+ dimension: Dimensions,
224
+ origin: tuple[float, float, float] = (0.0, 0.0, 0.0),
225
+ oricenter: bool = False,
226
+ increment: tuple[float, float, float] = (1.0, 1.0, 1.0),
227
+ rotation: float = 0.0,
228
+ flip: Literal[1, -1] = 1,
229
+ ) -> Grid:
230
+ """Create a rectangular 'shoebox' grid from spec.
231
+
232
+ Args:
233
+ dimension (NamedTuple of int): A tuple of (NCOL, NROW, NLAY)
234
+ origin (tuple of float): Startpoint of grid (x, y, z)
235
+ oricenter (bool): If False, startpoint is node, if True, use cell center
236
+ increment (tuple of float): Grid increments (xinc, yinc, zinc)
237
+ rotation (float): Rotation in degrees, anticlock from X axis.
238
+ flip (int): If +1, grid origin is lower left and left-handed;
239
+ if -1, origin is upper left and right-handed (row flip).
240
+
241
+ Returns:
242
+ Instance is updated (previous instance content will be erased)
243
+
244
+ .. versionadded:: 2.1
245
+ """
246
+ kwargs = _grid_etc1.create_box(
247
+ dimension=dimension,
248
+ origin=origin,
249
+ oricenter=oricenter,
250
+ increment=increment,
251
+ rotation=rotation,
252
+ flip=flip,
253
+ )
254
+
255
+ return Grid(**kwargs)
256
+
257
+
258
+ def grid_from_cube(
259
+ cube: xtgeo.Cube,
260
+ propname: str | None = "seismics",
261
+ oricenter: bool = True,
262
+ ) -> Grid:
263
+ """Create a rectangular 'shoebox' grid from an existing cube.
264
+
265
+ The cube values itself will then be stored with name given by ``propname`` key.
266
+
267
+ Since the cube actually is node centered, while grids are cell oriented,
268
+ the geometries here are shifted half an increment as default. To avoid this, use
269
+ oricenter=False.
270
+
271
+ Args:
272
+ cube: The xtgeo Cube instance
273
+ propname: Name of seismic property, if None then only the grid geometry
274
+ will be made
275
+ oricenter: Default is True, to treat seismic nodes as cell center values in
276
+ a grid.
277
+
278
+ .. versionadded:: 3.4
279
+ """
280
+
281
+ grd = create_box_grid(
282
+ cube.dimensions,
283
+ (cube.xori, cube.yori, cube.zori),
284
+ oricenter=oricenter,
285
+ increment=(cube.xinc, cube.yinc, cube.zinc),
286
+ rotation=cube.rotation,
287
+ flip=cube.yflip,
288
+ )
289
+ if propname is not None:
290
+ grd.props = [
291
+ xtgeo.GridProperty(
292
+ ncol=cube.ncol,
293
+ nrow=cube.nrow,
294
+ nlay=cube.nlay,
295
+ values=cube.values.copy(),
296
+ name=propname,
297
+ )
298
+ ]
299
+ return grd
300
+
301
+
302
+ def grid_from_surfaces(
303
+ surfaces: xtgeo.Surfaces,
304
+ ij_dimension: tuple[int, int] | None = None,
305
+ ij_origin: tuple[float, float] | None = None,
306
+ ij_increment: tuple[float, float] | None = None,
307
+ rotation: float | None = None,
308
+ tolerance: float | None = None,
309
+ ) -> Grid:
310
+ """Create a simple grid (non-faulted) from a stack of surfaces.
311
+
312
+ The surfaces shall be sorted from top to base, and they should not cross in depth.
313
+ In addition, it is required that they have the same settings (origin, rotation,
314
+ etc).
315
+
316
+ Args:
317
+ surfaces: The Surfaces instance
318
+ ij_dimension: The dimensions of the grid (ncol, nrow), default is to use the
319
+ dimension from the surfaces
320
+ ij_origin: The origin of the grid (x, y)
321
+ ij_increment: The increment of the grid (xinc, yinc), default is to use the
322
+ increment from the surfaces
323
+ rotation: The rotation of the grid in degrees, default is to use the rotation
324
+ from the surfaces
325
+ tolerance: The tolerance for sampling the surfaces. In particualar if the grid
326
+ origin, resolution and rotation are exactly the same as the surfaces,
327
+ the grid may not be able to sample the surfaces exactly at edges.
328
+ Lowering the tolerance may be used to avoid this. Default is 1e-6.
329
+
330
+ Example::
331
+
332
+ import xtgeo
333
+ surf1 = xtgeo.surface_from_file("top.surf")
334
+ surf2 = xtgeo.surface_from_file("base.surf")
335
+ surfaces = xtgeo.Surfaces([surf1, surf2])
336
+
337
+ grid = xtgeo.grid_from_surfaces(surfaces, ij_dimension=(20,30),
338
+ ij_increment=(50, 50), rotation=10)
339
+
340
+ """
341
+
342
+ tolerance = tolerance if tolerance else 1e-6
343
+
344
+ return _grid_etc1.create_grid_from_surfaces(
345
+ surfaces, ij_dimension, ij_origin, ij_increment, rotation, tolerance
346
+ )
347
+
348
+
349
+ class _GridCache:
350
+ """Internal class for caching data related to grid.
351
+
352
+ For example special grid, maps that are applied to speed up certain operations.
353
+
354
+ The "onegrid" is a 3D grid with only one layer, utilizing that a corner point grid
355
+ has straight pillars. The "top" and "base" surfaces are the top and base of the
356
+ onelayer grid, and extracting indices may be useful for some operations.
357
+
358
+ """
359
+
360
+ def __init__(self, grid: Grid) -> None:
361
+ logger.debug("Initialize cache for grid %s", grid.name)
362
+ self.onegrid: Grid | None = None
363
+ self.bbox: tuple[float, float, float, float, float, float] | None = None
364
+ self.top_depth: xtgeo.RegularSurface | None = None
365
+ self.base_depth: xtgeo.RegularSurface | None = None
366
+ self.top_i_index: xtgeo.RegularSurface | None = None
367
+ self.top_j_index: xtgeo.RegularSurface | None = None
368
+ self.base_i_index: xtgeo.RegularSurface | None = None
369
+ self.base_j_index: xtgeo.RegularSurface | None = None
370
+ logger.debug("Initialize cache for grid .. %s", grid.name)
371
+
372
+ self.threshold_magic_1: float = 0.1 # used in a C++ algorithm
373
+
374
+ # cpp (pybind11) objects
375
+ self.onegrid_cpp: GridCPP | None = None
376
+ self.top_depth_cpp: RegularSurfaceCPP | None = None
377
+ self.base_depth_cpp: RegularSurfaceCPP | None = None
378
+ self.top_i_index_cpp: RegularSurfaceCPP | None = None
379
+ self.top_j_index_cpp: RegularSurfaceCPP | None = None
380
+ self.base_i_index_cpp: RegularSurfaceCPP | None = None
381
+ self.base_j_index_cpp: RegularSurfaceCPP | None = None
382
+ logger.debug("Initialize cache for grid .... %s", grid.name)
383
+
384
+ # these are special SWIG arrays kept until necessary SWIG methods are replaced
385
+ # with pypind 11 / C++
386
+ self.top_i_index_carr: Any | None = None
387
+ self.top_j_index_carr: Any | None = None
388
+ self.base_i_index_carr: Any | None = None
389
+ self.base_j_index_carr: Any | None = None
390
+
391
+ self.name: str = grid.name
392
+ self.hash = hash(grid) # to remember the grid
393
+ logger.debug("Initialize cache for grid ...... %s", grid.name)
394
+ # initialize the cache with a one layer grid and surfaces
395
+ self._initialize(grid)
396
+ logger.debug("Initialized cache for grid %s, DONE", grid.name)
397
+
398
+ @staticmethod
399
+ def _get_swig_carr_double(surface: xtgeo.RegularSurface) -> Any:
400
+ carr = _cxtgeo.new_doublearray(surface.ncol * surface.nrow)
401
+ _cxtgeo.swig_numpy_to_carr_1d(surface.get_values1d(), carr)
402
+ return carr
403
+
404
+ def _initialize(self, grid: Grid) -> None:
405
+ """Initialize the cache with a one layer grid and surfaces."""
406
+ grid._set_xtgformat2() # ensure xtgformat 2
407
+ grid_cpp = grid._get_grid_cpp()
408
+
409
+ dz = grid.get_dz()
410
+ self.threshold_magic_1 = dz.values.mean() # cf. get_indices_from_pointset
411
+
412
+ logger.debug("Extracting one layer grid from %s", grid.name)
413
+ coordsv1, zcornsv1, actnumsv1 = grid_cpp.extract_onelayer_grid()
414
+
415
+ one = self.onegrid = Grid(
416
+ coordsv=coordsv1,
417
+ zcornsv=zcornsv1,
418
+ actnumsv=actnumsv1,
419
+ )
420
+
421
+ logger.debug("Created one layer grid in python from %s", grid.name)
422
+
423
+ minv, maxv = one._get_grid_cpp().get_bounding_box()
424
+ self.bbox = (minv.x, minv.y, minv.z, maxv.x, maxv.y, maxv.z)
425
+
426
+ self.top_depth = surface_from_grid3d(
427
+ one, where="top", property="depth", rfactor=4, index_position="top"
428
+ )
429
+ self.base_depth = surface_from_grid3d(
430
+ one, where="base", property="depth", rfactor=4, index_position="base"
431
+ )
432
+ self.top_i_index = surface_from_grid3d(
433
+ one, where="top", property="i", rfactor=4, index_position="top"
434
+ )
435
+ self.top_j_index = surface_from_grid3d(
436
+ one, where="top", property="j", rfactor=4, index_position="top"
437
+ )
438
+ self.base_i_index = surface_from_grid3d(
439
+ one, where="base", property="i", rfactor=4, index_position="base"
440
+ )
441
+ self.base_j_index = surface_from_grid3d(
442
+ one, where="base", property="j", rfactor=4, index_position="base"
443
+ )
444
+
445
+ # need to fill (interpolate) eventual holes in maps
446
+ self.top_depth.fill()
447
+ self.base_depth.fill()
448
+ self.top_i_index.fill()
449
+ self.top_j_index.fill()
450
+ self.base_i_index.fill()
451
+ self.base_j_index.fill()
452
+
453
+ self.onegrid_cpp = one._get_grid_cpp()
454
+ self.top_depth_cpp = _internal.regsurf.RegularSurface(self.top_depth)
455
+ self.base_depth_cpp = _internal.regsurf.RegularSurface(self.base_depth)
456
+ self.top_i_index_cpp = _internal.regsurf.RegularSurface(self.top_i_index)
457
+ self.top_j_index_cpp = _internal.regsurf.RegularSurface(self.top_j_index)
458
+ self.base_i_index_cpp = _internal.regsurf.RegularSurface(self.base_i_index)
459
+ self.base_j_index_cpp = _internal.regsurf.RegularSurface(self.base_j_index)
460
+
461
+ # these are special SWIG array objects kept until necessary SWIG
462
+ # methods are replaced
463
+ self.top_i_index_carr = self._get_swig_carr_double(self.top_i_index)
464
+ self.top_j_index_carr = self._get_swig_carr_double(self.top_j_index)
465
+ self.base_i_index_carr = self._get_swig_carr_double(self.base_i_index)
466
+ self.base_j_index_carr = self._get_swig_carr_double(self.base_j_index)
467
+
468
+ logger.info("Initialized cache for grid %s", grid.name)
469
+
470
+ def clear(self) -> None:
471
+ """Clear the cache."""
472
+ self.threshold_magic_1 = 0.1
473
+ self.onegrid = None
474
+ self.bbox = None
475
+ self.top_depth = None
476
+ self.base_depth = None
477
+ self.top_i_index = None
478
+ self.top_j_index = None
479
+ self.base_i_index = None
480
+ self.base_j_index = None
481
+
482
+ self.onegrid_cpp = None
483
+ self.top_depth_cpp = None
484
+ self.base_depth_cpp = None
485
+ self.top_i_index_cpp = None
486
+ self.top_j_index_cpp = None
487
+ self.base_i_index_cpp = None
488
+ self.base_j_index_cpp = None
489
+
490
+ self.top_i_index_carr = None
491
+ self.top_j_index_carr = None
492
+ self.base_i_index_carr = None
493
+ self.base_j_index_carr = None
494
+
495
+ logger.info("Clear cache for grid %s", self.name)
496
+
497
+
498
+ # --------------------------------------------------------------------------------------
499
+ # Comment on dual porosity grids:
500
+ #
501
+ # Simulation grids may hold a "dual poro" or/and a "dual perm" system. This is
502
+ # supported here for EGRID format (only, so far), which:
503
+ # * Index 5 in FILEHEAD will be 1 if dual poro is True
504
+ # * Index 5 in FILEHEAD will be 2 if dual poro AND dual perm is True
505
+ # * ACTNUM values will be: 0, 1, 2 (inactive) or 3 (active) instead of normal
506
+ # 0 / 1 in the file:
507
+ # * 0 both Fracture and Matrix are inactive
508
+ # * 1 Matrix is active, Fracture is inactive (set to zero)
509
+ # * 2 Matrix is inactive (set to zero), Fracture is active
510
+ # * 3 Both Fracture and Matrix are active
511
+ #
512
+ # However, XTGeo will convert this 0..3 scheme back to 0..1 scheme for ACTNUM!
513
+ # In case of dualporo/perm, a special property holding the initial actnum
514
+ # will be made, which is self._dualactnum
515
+ #
516
+ # The property self._dualporo is True in case of Dual Porosity
517
+ # BOTH self._dualperm AND self._dualporo are True in case of Dual Permeability
518
+ #
519
+ # All properties in a dual p* system will be given a postfix "M" of "F", e.g.
520
+ # PORO --> POROM and POROF
521
+ # --------------------------------------------------------------------------------------
522
+
523
+ IJKRange: tuple[int, int, int, int, int, int]
524
+
525
+
526
+ class Grid(_Grid3D):
527
+ """Class for a 3D grid corner point geometry in XTGeo.
528
+
529
+ I.e. the geometric grid cells and the active cell indicator.
530
+
531
+ The grid geometry class instances are normally created when
532
+ importing a grid from file, as it is normally too complex to create from
533
+ scratch.
534
+
535
+ Args:
536
+ coordsv: numpy array of dtype float64 and dimensions (nx + 1, ny + 1, 6)
537
+ Giving the x,y,z values of the upper and lower corners in the grid.
538
+ zcornsv: numpy array of dtype float32 and dimensions (nx + 1, ny + 1, nz + 1, 4)
539
+ giving the sw, se, nw, ne corners along the i,jth corner line for
540
+ the kth layer.
541
+ actnumsv: numpy array of dtype int32 and dimensions (nx, ny, nz) giving
542
+ the activity number for each cell. 0 means inactive, 1 means
543
+ active. For dualporo=True/dualperm=True grids, value can also be 2
544
+ or 3 meaning rock volume only and pore volume only respectively.
545
+ dualporo (bool): True if dual porosity grid.
546
+ dualperm (bool): True if dual permeability grid.
547
+ subgrids: dictionary giving names to subset of layers. Has name as key and
548
+ list of layer indices as values. Defaults to no names given.
549
+ units: The length units the coordinates are in,
550
+ (either Units.CM, Units.METRES, Units.FEET for cm, metres and
551
+ feet respectively). Default (None) is unitless.
552
+ filesrc: Optional filename of grid.
553
+ props: GridProperties instance containing the properties of the grid, defaults
554
+ to empty instance.
555
+ name: Optional name of the grid.
556
+ roxgrid: Roxar Grid the Grid originates from if any, defaults to no such grid.
557
+ roxindexer: Roxar grid indexer for the roxgrid. Defaults to no such indexer.
558
+
559
+ See Also:
560
+ The :class:`.GridProperty` and the :class:`.GridProperties` classes.
561
+
562
+ """
563
+
564
+ def __init__(
565
+ self,
566
+ coordsv: np.ndarray,
567
+ zcornsv: np.ndarray,
568
+ actnumsv: np.ndarray,
569
+ dualporo: bool = False,
570
+ dualperm: bool = False,
571
+ subgrids: dict | None = None,
572
+ units: Units | None = None,
573
+ filesrc: pathlib.Path | str | None = None,
574
+ props: GridProperties | None = None,
575
+ name: str | None = None,
576
+ roxgrid: Any | None = None,
577
+ roxindexer: Any | None = None,
578
+ ):
579
+ logger.debug("Initialize Grid...")
580
+ coordsv = np.asarray(coordsv)
581
+ zcornsv = np.asarray(zcornsv)
582
+ actnumsv = np.asarray(actnumsv)
583
+ if coordsv.dtype != np.float64:
584
+ raise TypeError(
585
+ f"The dtype of the coordsv array must be float64, got {coordsv.dtype}"
586
+ )
587
+ if zcornsv.dtype != np.float32:
588
+ raise TypeError(
589
+ f"The dtype of the zcornsv array must be float32, got {zcornsv.dtype}"
590
+ )
591
+ if actnumsv.dtype != np.int32:
592
+ raise TypeError(
593
+ f"The dtype of the actnumsv array must be int32, got {actnumsv.dtype}"
594
+ )
595
+ if len(coordsv.shape) != 3 or coordsv.shape[2] != 6:
596
+ raise ValueError(
597
+ f"shape of coordsv should be (nx+1,ny+1,6), got {coordsv.shape}"
598
+ )
599
+ if len(zcornsv.shape) != 4 or zcornsv.shape[3] != 4:
600
+ raise ValueError(
601
+ f"shape of zcornsv should be (nx+1,ny+1,nz+1, 4), got {zcornsv.shape}"
602
+ )
603
+ if zcornsv.shape[0:2] != coordsv.shape[0:2]:
604
+ raise ValueError(
605
+ f"Mismatch between zcornsv and coordsv shape: {zcornsv.shape}"
606
+ f" vs {coordsv.shape}"
607
+ )
608
+ if np.any(np.asarray(zcornsv.shape[0:3]) != np.asarray(actnumsv.shape) + 1):
609
+ raise ValueError(
610
+ f"Mismatch between zcornsv and actnumsv shape: {zcornsv.shape}"
611
+ f" vs {actnumsv.shape}"
612
+ )
613
+
614
+ super().__init__(*actnumsv.shape)
615
+
616
+ self._xtgformat = 2
617
+ self._ncol = actnumsv.shape[0]
618
+ self._nrow = actnumsv.shape[1]
619
+ self._nlay = actnumsv.shape[2]
620
+
621
+ self._coordsv = coordsv
622
+ self._zcornsv = zcornsv
623
+ self._actnumsv = actnumsv
624
+ self._dualporo = dualporo
625
+ self._dualperm = dualperm
626
+
627
+ # this is a reference to the Grid object in C++. Never access this directly,
628
+ # but use self._get_grid_cpp() function which validates against hash
629
+ self._grid_cpp = _internal.grid3d.Grid(self)
630
+ logger.debug("Initialize Grid... grid_cpp initialized")
631
+
632
+ self._filesrc = filesrc
633
+
634
+ self._props: GridProperties | None = (
635
+ GridProperties(props=[]) if props is None else props
636
+ )
637
+
638
+ self._name = name
639
+ self._subgrids = subgrids
640
+ self._ijk_handedness: Literal["left", "right"] | None = None
641
+ logger.debug("Initialize Grid... subgrids initialized")
642
+
643
+ self._dualactnum = None
644
+ if dualporo:
645
+ self._dualactnum = self.get_actnum(name="DUALACTNUM")
646
+ acttmp = self._dualactnum.copy()
647
+ acttmp.values[acttmp.values >= 1] = 1
648
+ self.set_actnum(acttmp)
649
+
650
+ self._metadata = xtgeo.MetaDataCPGeometry()
651
+ self._metadata.required = self
652
+ logger.debug("Initialize Grid... metadata initialized")
653
+
654
+ # Roxar api spesific:
655
+ self._roxgrid = roxgrid
656
+ self._roxindexer = roxindexer
657
+ logger.debug("Initialize Grid... roxar api initialized (if required)")
658
+
659
+ self.units = units
660
+
661
+ self._ijk_handedness = _estimate_grid_ijk_handedness(coordsv.copy())
662
+ logger.debug(
663
+ "Initialize Grid... ijk_handedness set to %s", self._ijk_handedness
664
+ )
665
+
666
+ self._hash = hash(self)
667
+
668
+ self._tmp = {} # TMP!
669
+ self._cache: _GridCache | None = None
670
+ logger.debug("Initialize Grid... DONE!")
671
+
672
+ def __repr__(self) -> str:
673
+ """The __repr__ method."""
674
+ logger.info("Invoke __repr__ for grid")
675
+ return (
676
+ f"{self.__class__.__name__} (id={id(self)}) ncol={self._ncol!r}, "
677
+ f"nrow={self._nrow!r}, nlay={self._nlay!r}, filesrc={self._filesrc!r}"
678
+ )
679
+
680
+ def __str__(self) -> str:
681
+ """The __str__ method for user friendly print."""
682
+ logger.debug("Invoke __str__ for grid", stack_info=True)
683
+
684
+ return self.describe(flush=False) or ""
685
+
686
+ def __hash__(self):
687
+ """The __hash__ method, i.e hash(self)."""
688
+
689
+ return hash(self.generate_hash())
690
+
691
+ # ==================================================================================
692
+ # Public Properties:
693
+ # ==================================================================================
694
+
695
+ @property
696
+ def metadata(self) -> xtgeo.MetaDataCPGeometry:
697
+ """obj: Return or set metadata instance of type MetaDataCPGeometry."""
698
+ return self._metadata
699
+
700
+ @metadata.setter
701
+ def metadata(self, obj: xtgeo.MetaDataCPGeometry) -> None:
702
+ # The current metadata object can be replaced. A bit dangerous so further
703
+ # check must be done to validate. TODO.
704
+ if not isinstance(obj, xtgeo.MetaDataCPGeometry):
705
+ raise ValueError("Input obj not an instance of MetaDataCPGeometry")
706
+
707
+ self._metadata = obj # checking is currently missing! TODO
708
+
709
+ @property
710
+ def filesrc(self) -> str | pathlib.Path | None:
711
+ """str: Source for grid (filepath or name in RMS)."""
712
+ return self._filesrc
713
+
714
+ @property
715
+ def name(self) -> str | None:
716
+ """str: Name attribute of grid."""
717
+ return self._name
718
+
719
+ @name.setter
720
+ def name(self, name: str) -> None:
721
+ if not isinstance(name, str):
722
+ raise ValueError("Input name is not a text string")
723
+ self._name = name
724
+
725
+ @property
726
+ def dimensions(self) -> Dimensions:
727
+ """Dimensions NamedTuple: The grid dimensions (read only)."""
728
+ return Dimensions(self.ncol, self.nrow, self.nlay)
729
+
730
+ @property
731
+ def vectordimensions(self) -> tuple[int, int, int]:
732
+ """3-tuple: The storage grid array dimensions tuple of 3 integers (read only).
733
+
734
+ The tuple is (ncoord, nzcorn, nactnum).
735
+ """
736
+ ncoord = (self.ncol + 1) * (self.nrow + 1) * 2 * 3
737
+ nzcorn = self.ncol * self.nrow * (self.nlay + 1) * 4
738
+ ntot = self.ncol * self.nrow * self.nlay
739
+
740
+ return (ncoord, nzcorn, ntot)
741
+
742
+ @property
743
+ def ijk_handedness(self) -> Literal["left", "right"] | None:
744
+ """str: IJK handedness for grids, "right" or "left".
745
+
746
+ For a non-rotated grid with K increasing with depth, 'left' is corner in
747
+ lower-left, while 'right' is origin in upper-left corner.
748
+
749
+ """
750
+ return self._ijk_handedness
751
+
752
+ @ijk_handedness.setter
753
+ def ijk_handedness(self, value: Literal["left", "right"]) -> None:
754
+ if value not in ("right", "left"):
755
+ raise ValueError("The value must be 'right' or 'left'")
756
+ self.reverse_row_axis(ijk_handedness=value)
757
+
758
+ @property
759
+ def subgrids(self) -> dict[str, range | list[int]] | None:
760
+ """:obj:`list` of :obj:`int`: A dict with subgrid name and an array as value.
761
+
762
+ I.e. a dict on the form ``{"name1": [1, 2, 3, 4], "name2": [5, 6, 7],
763
+ "name3": [8, 9, 10]}``, here meaning 3 subgrids where upper is 4
764
+ cells vertically, then 3, then 3. The numbers must sum to NLAY.
765
+
766
+ The numbering in the arrays are 1 based; meaning uppermost layer is 1
767
+ (not 0).
768
+
769
+ None will be returned if no subgrid indexing is present.
770
+
771
+ See also :meth:`set_subgrids()` and :meth:`get_subgrids()` which
772
+ have a similar function, but differs a bit.
773
+
774
+ Note that this design is a bit different from the Roxar API, where
775
+ repeated sections are allowed, and where indices start from 0,
776
+ not one.
777
+ """
778
+ return None if self._subgrids is None else self._subgrids
779
+
780
+ @subgrids.setter
781
+ def subgrids(
782
+ self,
783
+ sgrids: dict[str, range | list[int]] | None,
784
+ ) -> None:
785
+ if sgrids is None:
786
+ self._subgrids = None
787
+ return
788
+
789
+ if not isinstance(sgrids, dict):
790
+ raise ValueError("Input to subgrids must be an ordered dictionary")
791
+
792
+ lengths = 0
793
+ zarr: list[Hashable] = []
794
+ keys: list[Hashable] = []
795
+
796
+ for key, val in sgrids.items():
797
+ lengths += len(val)
798
+ keys.append(key)
799
+ zarr.extend(val)
800
+
801
+ if lengths != self._nlay:
802
+ raise ValueError(
803
+ f"Subgrids lengths <{lengths}> not equal NLAY <{self.nlay}>"
804
+ )
805
+
806
+ if set(zarr) != set(range(1, self._nlay + 1)):
807
+ raise ValueError(
808
+ f"Arrays are not valid as the do not sum to vertical range, {zarr}"
809
+ )
810
+
811
+ if len(keys) != len(set(keys)):
812
+ raise ValueError(f"Subgrid keys are not unique: {keys}")
813
+
814
+ self._subgrids = sgrids
815
+
816
+ @property
817
+ def nactive(self) -> int:
818
+ """int: Returns the number of active cells (read only)."""
819
+ return len(self.actnum_indices)
820
+
821
+ @property
822
+ def actnum_array(self) -> np.ndarray:
823
+ """Returns the 3D ndarray which for active cells.
824
+
825
+ Values are 1 for active, 0 for inactive, in C order (read only).
826
+
827
+ """
828
+ actnumv = self.get_actnum().values
829
+ return ma.filled(actnumv, fill_value=0)
830
+
831
+ @property
832
+ def actnum_indices(self) -> np.ndarray:
833
+ """:obj:np.ndrarray: Indices (1D array) for active cells (read only).
834
+
835
+ In dual poro/perm systems, this will be the active indices for the
836
+ matrix cells and/or fracture cells (i.e. actnum >= 1).
837
+ """
838
+ actnumv = self.get_actnum()
839
+ actnumv = np.ravel(actnumv.values)
840
+ return np.flatnonzero(actnumv)
841
+
842
+ @property
843
+ def ntotal(self) -> int:
844
+ """Returns the total number of cells (read only)."""
845
+ return self.ncol * self.nrow * self.nlay
846
+
847
+ @property
848
+ def dualporo(self) -> bool:
849
+ """Boolean flag for dual porosity scheme (read only)."""
850
+ return self._dualporo
851
+
852
+ @property
853
+ def dualperm(self) -> bool:
854
+ """Boolean flag for dual porosity scheme (read only)."""
855
+ return self._dualperm
856
+
857
+ @property
858
+ def gridprops(self) -> GridProperties:
859
+ """Return or set a XTGeo GridProperties objects attached to the Grid."""
860
+ # Note, internally, the _props is a GridProperties instance, which is
861
+ # a class that holds a list of properties.
862
+ # Note that the `props` methods below will deal with properties in a
863
+ # list context
864
+
865
+ return self._props
866
+
867
+ @gridprops.setter
868
+ def gridprops(self, gprops: GridProperties) -> None:
869
+ if not isinstance(gprops, GridProperties):
870
+ raise ValueError("Input must be a GridProperties instance")
871
+
872
+ self._props = gprops # self._props is a GridProperties instance
873
+
874
+ @property
875
+ def props(self) -> list[GridProperty] | None:
876
+ """Return or set a list of XTGeo GridProperty objects.
877
+
878
+ When setting, the dimension of the property object is checked,
879
+ and will raise an IndexError if it does not match the grid.
880
+
881
+ When setting props, the current property list is replaced.
882
+
883
+ See also :meth:`append_prop()` method to add a property to the current list.
884
+
885
+ """
886
+ # Note, internally, the _props is a GridProperties instance, which is
887
+ # a class that holds a list of properties.
888
+
889
+ if isinstance(self._props, GridProperties):
890
+ return self._props.props
891
+ if isinstance(self._props, list):
892
+ raise RuntimeError("self._props is a list, not a GridProperties instance")
893
+ return None
894
+
895
+ @props.setter
896
+ def props(self, plist: list[GridProperty]) -> None:
897
+ if not isinstance(plist, list):
898
+ raise ValueError("Input to props must be a list")
899
+
900
+ for gridprop in plist:
901
+ if gridprop.dimensions != self.dimensions:
902
+ raise IndexError(
903
+ f"Property NX NY NZ <{gridprop.name}> does not match grid!"
904
+ )
905
+
906
+ self._props.props = plist # self._props is a GridProperties instance
907
+
908
+ @property
909
+ def propnames(self) -> list[str] | None:
910
+ """Returns a list of property names that are hooked to a grid."""
911
+ return None if self._props is None else self._props.names
912
+
913
+ @property
914
+ def roxgrid(self) -> Any | None:
915
+ """Get the Roxar native proj.grid_models[gname].get_grid() object."""
916
+ return self._roxgrid
917
+
918
+ @property
919
+ def roxindexer(self) -> Any | None:
920
+ """The Roxar native proj.grid_models[gname].get_grid().grid_indexer object."""
921
+ return self._roxindexer
922
+
923
+ # ==================================================================================
924
+ # Private, special
925
+ # TODO: do a threading lock of the cache
926
+ # ==================================================================================
927
+
928
+ def _get_grid_cpp(self) -> GridCPP:
929
+ """Get the C++ grid object, creating or updating if needed."""
930
+ grid_cpp = getattr(self, "_grid_cpp", None)
931
+ current_hash = hash(self)
932
+ if grid_cpp is not None and self._hash == current_hash:
933
+ logger.info("Cache for python Grid is valid, returning current")
934
+ return grid_cpp
935
+
936
+ # update reference to C++ Grid object if hash has changed
937
+ self._grid_cpp = _internal.grid3d.Grid(self)
938
+ self._hash = current_hash
939
+ return self._grid_cpp
940
+
941
+ def _get_cache(self) -> _GridCache:
942
+ """Get the grid cache object, creating or updating if needed."""
943
+ cache = getattr(self, "_cache", None)
944
+ current_hash = hash(self)
945
+ if cache is not None:
946
+ if cache.hash == current_hash:
947
+ logger.info("Cache for python Grid is valid, returning current")
948
+ return cache
949
+ logger.info(
950
+ "Python Grid has changed, current cache is invalid, creating new"
951
+ )
952
+ cache.clear()
953
+ self._cache = _GridCache(self)
954
+ return self._cache
955
+
956
+ def _clear_cache(self) -> None:
957
+ """Clear the grid cache object."""
958
+ cache = getattr(self, "_cache", None)
959
+ if cache is not None:
960
+ cache.clear()
961
+ self._cache = None
962
+ logger.debug("Cache cleared")
963
+ else:
964
+ logger.debug("No cache to clear")
965
+
966
+ # ==================================================================================
967
+ # Other
968
+ # ==================================================================================
969
+ def generate_hash(
970
+ self,
971
+ hashmethod: Literal["md5", "sha256", "blake2b"] = "md5",
972
+ ) -> str:
973
+ """Return a unique hash ID for current instance (for persistance).
974
+
975
+ See :meth:`~xtgeo.common.sys.generic_hash()` for documentation.
976
+
977
+ .. versionadded:: 2.14
978
+ """
979
+ self._set_xtgformat2() # ensure xtgformat 2!
980
+
981
+ required = (
982
+ "_ncol",
983
+ "_nrow",
984
+ "_nlay",
985
+ "_coordsv",
986
+ "_zcornsv",
987
+ "_actnumsv",
988
+ )
989
+
990
+ gid = "".join(str(getattr(self, att)) for att in required)
991
+
992
+ return generic_hash(gid, hashmethod=hashmethod)
993
+
994
+ # ==================================================================================
995
+ # Create/import/export
996
+ # ==================================================================================
997
+
998
+ def to_file(
999
+ self, gfile: FileLike, fformat: str = "roff", rle: bool = False
1000
+ ) -> None:
1001
+ """Export grid geometry to file, various vendor formats.
1002
+
1003
+ Args:
1004
+ gfile (str): Name of output file
1005
+ fformat (str): File format; roff/roff_binary/roff_ascii/
1006
+ grdecl/bgrdecl/egrid.
1007
+ rle (bool): Use run-length encoding (only for grdecl file)
1008
+
1009
+ Raises:
1010
+ OSError: Directory does not exist
1011
+
1012
+ Example::
1013
+ >>> grid = create_box_grid((2,2,2))
1014
+ >>> grid.to_file(outdir + "/myfile.roff")
1015
+ """
1016
+ _gfile = FileWrapper(gfile, mode="wb")
1017
+
1018
+ _gfile.check_folder(raiseerror=OSError)
1019
+
1020
+ if fformat in FileFormat.ROFF_BINARY.value:
1021
+ _grid_export.export_roff(self, _gfile.name, "binary")
1022
+ elif fformat in FileFormat.ROFF_ASCII.value:
1023
+ _grid_export.export_roff(self, _gfile.name, "ascii")
1024
+ elif fformat in FileFormat.GRDECL.value:
1025
+ _grid_export.export_grdecl(self, _gfile.name, 1, rle)
1026
+ elif fformat in FileFormat.BGRDECL.value:
1027
+ _grid_export.export_grdecl(self, _gfile.name, 0)
1028
+ elif fformat in FileFormat.EGRID.value:
1029
+ _grid_export.export_egrid(self, _gfile.name)
1030
+ elif fformat in FileFormat.FEGRID.value:
1031
+ _grid_export.export_fegrid(self, _gfile.name)
1032
+ elif fformat in FileFormat.HDF.value:
1033
+ self.to_hdf(gfile)
1034
+ elif fformat in FileFormat.XTG.value:
1035
+ self.to_xtgf(gfile)
1036
+ else:
1037
+ extensions = FileFormat.extensions_string(
1038
+ [
1039
+ FileFormat.ROFF_BINARY,
1040
+ FileFormat.ROFF_ASCII,
1041
+ FileFormat.EGRID,
1042
+ FileFormat.FEGRID,
1043
+ FileFormat.GRDECL,
1044
+ FileFormat.BGRDECL,
1045
+ FileFormat.XTG,
1046
+ FileFormat.HDF,
1047
+ ]
1048
+ )
1049
+ raise InvalidFileFormatError(
1050
+ f"File format {fformat} is invalid for type Grid. "
1051
+ f"Supported formats are {extensions}."
1052
+ )
1053
+
1054
+ def to_hdf(
1055
+ self,
1056
+ gfile: str | pathlib.Path,
1057
+ compression: str | None = None,
1058
+ chunks: bool | None = False,
1059
+ subformat: int | None = 844,
1060
+ ) -> FileLike:
1061
+ """Export grid geometry to HDF5 storage format (experimental!).
1062
+
1063
+ Args:
1064
+ gfile: Name of output file
1065
+ compression: Compression method, such as "blosc" or "lzf"
1066
+ chunks: chunks settings
1067
+ subformat: Format of output arrays in terms of bytes. E.g. 844 means
1068
+ 8 byte for COORD, 4 byte for ZCORNS, 4 byte for ACTNUM.
1069
+
1070
+ Raises:
1071
+ OSError: Directory does not exist
1072
+
1073
+ Returns:
1074
+ Used file object, or None if memory stream
1075
+
1076
+ Example:
1077
+
1078
+ >>> grid = create_box_grid((2,2,2))
1079
+ >>> filename = grid.to_hdf(outdir + "/myfile_grid.h5")
1080
+ """
1081
+ _gfile = FileWrapper(gfile, mode="wb", obj=self)
1082
+ _gfile.check_folder(raiseerror=OSError)
1083
+
1084
+ _grid_export.export_hdf5_cpgeom(
1085
+ self, _gfile, compression=compression, chunks=chunks, subformat=subformat
1086
+ )
1087
+
1088
+ return _gfile.file
1089
+
1090
+ def to_xtgf(
1091
+ self,
1092
+ gfile: str | pathlib.Path,
1093
+ subformat: int | None = 844,
1094
+ ) -> pathlib.Path:
1095
+ """Export grid geometry to xtgeo native binary file format (experimental!).
1096
+
1097
+ Args:
1098
+ gfile: Name of output file
1099
+ subformat: Format of output arryas in terms of bytes. E.g. 844 means
1100
+ 8 byte for COORD, 4 byte for ZCORNS, 4 byte for ACTNUM.
1101
+
1102
+ Raises:
1103
+ OSError: Directory does not exist
1104
+
1105
+ Returns:
1106
+ gfile (pathlib.Path): Used pathlib.Path file object, or None if
1107
+ memory stream
1108
+
1109
+ Example::
1110
+ >>> grid = create_box_grid((2,2,2))
1111
+ >>> filename = grid.to_xtgf(outdir + "/myfile.xtg")
1112
+ """
1113
+ _gfile = FileWrapper(gfile, mode="wb", obj=self)
1114
+ _gfile.check_folder(raiseerror=OSError)
1115
+
1116
+ _grid_export.export_xtgcpgeom(self, _gfile, subformat=subformat)
1117
+
1118
+ return _gfile.file
1119
+
1120
+ def to_roxar(
1121
+ self,
1122
+ project: str,
1123
+ gname: str,
1124
+ realisation: int = 0,
1125
+ info: bool = False,
1126
+ method: Literal["cpg", "roff"] = "cpg",
1127
+ ) -> None:
1128
+ """Export (upload) a grid from XTGeo to RMS via Roxar API.
1129
+
1130
+ Note:
1131
+ When project is file path (direct access, outside RMS) then
1132
+ ``to_roxar()`` will implicitly do a project save. Otherwise, the project
1133
+ will not be saved until the user do an explicit project save action.
1134
+
1135
+ Args:
1136
+ project (str or roxar._project): Inside RMS use the magic 'project',
1137
+ else use path to RMS project, or a project reference
1138
+ gname (str): Name of grid in RMS
1139
+ realisation (int): Realisation umber, default 0
1140
+ info (bool): TBD
1141
+ method (str): Save approach, the default is 'cpg' which applied the internal
1142
+ RMS API, while 'roff' will do a save to a temporary area, and then load
1143
+ into RMS. For strange reasons, the 'roff' method is per RMS version
1144
+ 14.2 a faster method (strange since file i/o is way more costly than
1145
+ direct API access, in theory).
1146
+
1147
+ Note:
1148
+ When storing grids that needs manipulation of inactive cells, .e.g.
1149
+ ``activate_all()`` method, using method='roff' is recommended. The reason
1150
+ is that saving cells using 'cpg' method will force zero depth values on
1151
+ inactive cells.
1152
+
1153
+ """
1154
+ _grid_roxapi.save_grid_to_rms(
1155
+ self, project, gname, realisation, info=info, method=method
1156
+ )
1157
+
1158
+ def convert_units(self, units: Units) -> None:
1159
+ """
1160
+ Convert the units of the grid.
1161
+ Args:
1162
+ units: The unit to convert to.
1163
+ Raises:
1164
+ ValueError: When the grid is unitless (no initial
1165
+ unit information available).
1166
+ """
1167
+ if self.units is None:
1168
+ raise ValueError("convert_units called on unitless grid.")
1169
+ if self.units == units:
1170
+ return
1171
+ factor = self.units.conversion_factor(units)
1172
+ self._coordsv *= factor
1173
+ self._zcornsv *= factor
1174
+ self.units = units
1175
+
1176
+ # ==================================================================================
1177
+ # Various public methods
1178
+ # ==================================================================================
1179
+
1180
+ def copy(self) -> Grid:
1181
+ """Copy from one existing Grid instance to a new unique instance.
1182
+
1183
+ Note that associated properties will also be copied.
1184
+
1185
+ Example::
1186
+
1187
+ >>> grd = create_box_grid((5,5,5))
1188
+ >>> newgrd = grd.copy()
1189
+ """
1190
+ logger.info("Copy a Grid instance")
1191
+ return _grid_etc1.copy(self)
1192
+
1193
+ def describe(
1194
+ self,
1195
+ details: bool = False,
1196
+ flush: bool = True,
1197
+ ) -> str | None:
1198
+ """Describe an instance by printing to stdout."""
1199
+ logger.info("Print a description...")
1200
+
1201
+ dsc = XTGDescription()
1202
+ dsc.title("Description of Grid instance")
1203
+ dsc.txt("Object ID", id(self))
1204
+ dsc.txt("File source", self._filesrc)
1205
+ dsc.txt("Shape: NCOL, NROW, NLAY", self.ncol, self.nrow, self.nlay)
1206
+ dsc.txt("Number of active cells", self.nactive)
1207
+
1208
+ if details:
1209
+ geom = self.get_geometrics(cellcenter=True, return_dict=True)
1210
+
1211
+ assert isinstance(geom, dict)
1212
+
1213
+ prp1: list[str] = []
1214
+ for prp in ("xmin", "xmax", "ymin", "ymax", "zmin", "zmax"):
1215
+ prp1.append(f"{geom[prp]:10.3f}")
1216
+
1217
+ prp2: list[str] = []
1218
+ for prp in ("avg_dx", "avg_dy", "avg_dz", "avg_rotation"):
1219
+ prp2.append(f"{geom[prp]:7.4f}")
1220
+
1221
+ geox = self.get_geometrics(
1222
+ cellcenter=False, allcells=True, return_dict=True
1223
+ )
1224
+ assert isinstance(geox, dict)
1225
+ prp3: list[str] = []
1226
+ for prp in ("xmin", "xmax", "ymin", "ymax", "zmin", "zmax"):
1227
+ prp3.append(f"{geox[prp]:10.3f}")
1228
+
1229
+ prp4 = []
1230
+ for prp in ("avg_dx", "avg_dy", "avg_dz", "avg_rotation"):
1231
+ prp4.append(f"{geox[prp]:7.4f}")
1232
+
1233
+ dsc.txt("For active cells, using cell centers:")
1234
+ dsc.txt("Xmin, Xmax, Ymin, Ymax, Zmin, Zmax:", *prp1)
1235
+ dsc.txt("Avg DX, Avg DY, Avg DZ, Avg rotation:", *prp2)
1236
+ dsc.txt("For all cells, using cell corners:")
1237
+ dsc.txt("Xmin, Xmax, Ymin, Ymax, Zmin, Zmax:", *prp3)
1238
+ dsc.txt("Avg DX, Avg DY, Avg DZ, Avg rotation:", *prp4)
1239
+
1240
+ dsc.txt("Attached grid props objects (names)", self.propnames)
1241
+
1242
+ if details:
1243
+ dsc.txt("Attached grid props objects (id)", self.props)
1244
+ if self.subgrids:
1245
+ dsc.txt("Number of subgrids", len(list(self.subgrids.keys())))
1246
+ else:
1247
+ dsc.txt("Number of subgrids", "No subgrids")
1248
+ if details:
1249
+ dsc.txt("Subgrids details", json.dumps(self.get_subgrids()))
1250
+ dsc.txt("Subgrids with values array", self.subgrids)
1251
+
1252
+ if flush:
1253
+ dsc.flush()
1254
+ return None
1255
+
1256
+ return dsc.astext()
1257
+
1258
+ def get_bounding_box(self) -> tuple[float, float, float, float, float, float]:
1259
+ """Get the bounding box of the grid.
1260
+
1261
+ Returns:
1262
+ A tuple with the bounding box coordinates (xmin, ymin, zmin, xmax, ymax,
1263
+ zmax).
1264
+
1265
+ Example::
1266
+
1267
+ >>> import xtgeo
1268
+ >>> grd = xtgeo.grid_from_file(reek_dir + "/REEK.EGRID", fformat="egrid")
1269
+ >>> bb = grd.get_bounding_box()
1270
+
1271
+ _versionadded:: 4.9
1272
+ """
1273
+ min_pt, max_pt = self._get_grid_cpp().get_bounding_box()
1274
+ return (min_pt.x, min_pt.y, min_pt.z, max_pt.x, max_pt.y, max_pt.z)
1275
+
1276
+ def get_dataframe(
1277
+ self,
1278
+ activeonly: bool = True,
1279
+ ijk: bool = True,
1280
+ xyz: bool = True,
1281
+ doubleformat: bool = False,
1282
+ ) -> pd.DataFrame:
1283
+ """Returns a Pandas dataframe for the grid and any attached grid properties.
1284
+
1285
+ Note that this dataframe method is rather similar to GridProperties
1286
+ dataframe function, but have other defaults.
1287
+
1288
+ Args:
1289
+ activeonly (bool): If True (default), return only active cells.
1290
+ ijk (bool): If True (default), show cell indices, IX JY KZ columns
1291
+ xyz (bool): If True (default), show cell center coordinates.
1292
+ doubleformat (bool): If True, floats are 64 bit, otherwise 32 bit.
1293
+ Note that coordinates (if xyz=True) is always 64 bit floats.
1294
+
1295
+ Returns:
1296
+ A Pandas dataframe object
1297
+
1298
+ Example::
1299
+
1300
+ >>> import xtgeo
1301
+ >>> grd = xtgeo.grid_from_file(reek_dir + "/REEK.EGRID", fformat="egrid")
1302
+ >>> names = ["SOIL", "SWAT", "PRESSURE"]
1303
+ >>> dates = [19991201]
1304
+ >>> xpr = xtgeo.gridproperties_from_file(
1305
+ ... reek_dir + "/REEK.UNRST",
1306
+ ... fformat="unrst",
1307
+ ... names=names,
1308
+ ... dates=dates,
1309
+ ... grid=grd,
1310
+ ... )
1311
+ >>> grd.gridprops = xpr # attach properties to grid
1312
+
1313
+ >>> df = grd.get_dataframe()
1314
+
1315
+ >>> # save as CSV file
1316
+ >>> df.to_csv(outdir + "/mygrid.csv")
1317
+ """
1318
+ return self.gridprops.get_dataframe(
1319
+ grid=self,
1320
+ activeonly=activeonly,
1321
+ ijk=ijk,
1322
+ xyz=xyz,
1323
+ doubleformat=doubleformat,
1324
+ )
1325
+
1326
+ def get_vtk_esg_geometry_data(
1327
+ self,
1328
+ ) -> tuple[
1329
+ np.ndarray,
1330
+ np.ndarray,
1331
+ np.ndarray,
1332
+ np.ndarray,
1333
+ ]:
1334
+ """Get grid geometry data suitable for use with VTK's vtkExplicitStructuredGrid.
1335
+
1336
+ Builds and returns grid geometry data in a format tailored for use with VTK's
1337
+ explicit structured grid (ESG). Essentially this entails building an
1338
+ unstructured grid representation where all the grid cells are represented as
1339
+ hexahedrons with explicit connectivities. The cell connectivity array refers
1340
+ into the accompanying vertex array.
1341
+
1342
+ In VTK, cell order increases in I fastest, then J, then K.
1343
+
1344
+ The returned tuple contains:
1345
+ - numpy array with dimensions in terms of points (not cells)
1346
+ - vertex array, numpy array with vertex coordinates
1347
+ - connectivity array for all the cells, numpy array with integer indices
1348
+ - inactive cell indices, numpy array with integer indices
1349
+
1350
+ This function also tries to remove/weld duplicate vertices, but this is still
1351
+ a work in progress.
1352
+
1353
+ Example usage with VTK::
1354
+
1355
+ dims, vert_arr, conn_arr, inact_arr = xtg_grid.get_vtk_esg_geometry_data()
1356
+
1357
+ vert_arr = vert_arr.reshape(-1, 3)
1358
+ vtk_points = vtkPoints()
1359
+ vtk_points.SetData(numpy_to_vtk(vert_arr, deep=1))
1360
+
1361
+ vtk_cell_array = vtkCellArray()
1362
+ vtk_cell_array.SetData(8, numpy_to_vtkIdTypeArray(conn_arr, deep=1))
1363
+
1364
+ vtk_esgrid = vtkExplicitStructuredGrid()
1365
+ vtk_esgrid.SetDimensions(dims)
1366
+ vtk_esgrid.SetPoints(vtk_points)
1367
+ vtk_esgrid.SetCells(vtk_cell_array)
1368
+
1369
+ vtk_esgrid.ComputeFacesConnectivityFlagsArray()
1370
+
1371
+ ghost_arr_vtk = vtk_esgrid.AllocateCellGhostArray()
1372
+ ghost_arr_np = vtk_to_numpy(ghost_arr_vtk)
1373
+ ghost_arr_np[inact_arr] = vtkDataSetAttributes.HIDDENCELL
1374
+
1375
+ .. versionadded:: 2.20
1376
+ """
1377
+ return _grid_etc1.get_vtk_esg_geometry_data(self)
1378
+
1379
+ def get_vtk_geometries(self) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
1380
+ """Get necessary arrays on correct layout for VTK ExplicitStructuredGrid usage.
1381
+
1382
+ Example::
1383
+
1384
+ import pyvista as pv
1385
+ dim, crn, inactind = grd.get_vtk_geometries()
1386
+ grid = pv.ExplicitStructuredGrid(dim, crn)
1387
+ grid.flip_z(inplace=True)
1388
+ grid.hide_cells(inactind, inplace=True)
1389
+ grid.plot(show_edges=True)
1390
+
1391
+ Returns:
1392
+ dims, corners, inactive_indices
1393
+
1394
+ .. versionadded:: 2.18
1395
+ """
1396
+
1397
+ return _grid_etc1.get_vtk_geometries(self)
1398
+
1399
+ def append_prop(self, prop: GridProperty) -> None:
1400
+ """Append a single property to the grid."""
1401
+ if prop.dimensions != self.dimensions:
1402
+ raise ValueError(
1403
+ f"Dimensions does not match, got: {prop.dimensions} "
1404
+ f"expected: {self.dimensions}."
1405
+ )
1406
+
1407
+ self._props.append_props([prop])
1408
+
1409
+ def set_subgrids(self, sdict: dict[str, int] | None) -> None:
1410
+ """Set the subgrid from a simplified ordered dictionary.
1411
+
1412
+ The simplified dictionary is on the form
1413
+ {"name1": 3, "name2": 5}
1414
+
1415
+ Note that the input must be an dict!
1416
+
1417
+ """
1418
+ if sdict is None:
1419
+ return
1420
+
1421
+ if not isinstance(sdict, dict):
1422
+ raise ValueError("Input sdict is not an dict")
1423
+
1424
+ newsub: dict[str, range | list[int]] = {}
1425
+
1426
+ inn1 = 1
1427
+ for name, nsub in sdict.items():
1428
+ inn2 = inn1 + nsub
1429
+ newsub[name] = range(inn1, inn2)
1430
+ inn1 = inn2
1431
+
1432
+ self.subgrids = newsub
1433
+
1434
+ def get_subgrids(self) -> dict[str, int] | None:
1435
+ """Get the subgrids on a simplified ordered dictionary.
1436
+
1437
+ The simplified dictionary is on the form {"name1": 3, "name2": 5}
1438
+ """
1439
+ if not self.subgrids:
1440
+ return None
1441
+
1442
+ return {name: len(subb) for name, subb in self.subgrids.items()}
1443
+
1444
+ def rename_subgrids(self, names: list[str] | tuple[str, ...]) -> None:
1445
+ """Rename the names in the subgrids with the new names.
1446
+
1447
+ Args:
1448
+ names (list): List of new names, length of list must be same as length of
1449
+ subgrids
1450
+
1451
+
1452
+ Example::
1453
+
1454
+ >>> grd = create_box_grid((3, 3, 3))
1455
+ >>> grd.subgrids = dict(
1456
+ ... [("1", range(1,2)), ("2", range(2,3)), ("3", range(3,4))]
1457
+ ... )
1458
+ >>> grd.rename_subgrids(["Inky", "Tinky", "Pinky"])
1459
+
1460
+ Raises:
1461
+ ValueError: Input names not a list or a tuple
1462
+ ValueError: Lenght of names list not same as number of subgrids
1463
+
1464
+ .. versionadded:: 2.12
1465
+ """
1466
+ if not isinstance(names, (list, tuple)):
1467
+ raise ValueError("Input names not a list or a tuple")
1468
+
1469
+ assert self.subgrids is not None
1470
+ if len(names) != len(list(self.subgrids.keys())):
1471
+ raise ValueError("Lenght of names list not same as number of subgrids")
1472
+
1473
+ subs = self.get_subgrids()
1474
+ assert subs is not None
1475
+ subs_copy = subs.copy()
1476
+ for num, oldname in enumerate(self.subgrids.keys()):
1477
+ subs_copy[str(names[num])] = subs_copy.pop(oldname)
1478
+
1479
+ self.set_subgrids(subs_copy)
1480
+
1481
+ def estimate_design(
1482
+ self,
1483
+ nsub: str | int | None = None,
1484
+ ) -> dict[str, str | float] | None:
1485
+ """Estimate design and simbox thickness of the grid or a subgrid.
1486
+
1487
+ If the grid consists of several subgrids, and nsub is not specified, then
1488
+ a failure should be raised.
1489
+
1490
+ Args:
1491
+ nsub (int or str): Subgrid index to check, either as a number (starting
1492
+ with 1) or as subgrid name. If set to None, the whole grid will
1493
+ examined.
1494
+
1495
+ Returns:
1496
+ result (dict): where key "design" gives one letter in(P, T, B, X, M)
1497
+ P=proportional, T=topconform, B=baseconform,
1498
+ X=underdetermined, M=Mixed conform. Key "dzsimbox" is simbox thickness
1499
+ estimate per cell. None if nsub is given, but subgrids are missing, or
1500
+ nsub (name or number) is out of range.
1501
+
1502
+ Example::
1503
+
1504
+ >>> import xtgeo
1505
+ >>> grd = xtgeo.grid_from_file(emerald_dir + "/emerald_hetero_grid.roff")
1506
+ >>> print(grd.subgrids)
1507
+ dict([('subgrid_0', range(1, 17)), ('subgrid_1', range(17, 47))])
1508
+ >>> res = grd.estimate_design(nsub="subgrid_0")
1509
+ >>> print("Subgrid design is", res["design"])
1510
+ Subgrid design is P
1511
+ >>> print("Subgrid simbox thickness is", res["dzsimbox"])
1512
+ Subgrid simbox thickness is 2.548...
1513
+
1514
+
1515
+
1516
+ """
1517
+ nsubname = None
1518
+
1519
+ if nsub is None and self.subgrids:
1520
+ raise ValueError("Subgrids exists, nsub cannot be None")
1521
+
1522
+ if nsub is not None:
1523
+ if not self.subgrids:
1524
+ return None
1525
+
1526
+ if isinstance(nsub, int):
1527
+ try:
1528
+ nsubname = list(self.subgrids.keys())[nsub - 1]
1529
+ except IndexError:
1530
+ return None
1531
+
1532
+ elif isinstance(nsub, str):
1533
+ nsubname = nsub
1534
+ else:
1535
+ raise ValueError("Key nsub of wrong type, must be a number or a name")
1536
+
1537
+ if nsubname not in self.subgrids:
1538
+ return None
1539
+
1540
+ return _grid_etc1.estimate_design(self, nsubname)
1541
+
1542
+ def estimate_flip(self) -> Literal[1, -1]:
1543
+ """Estimate flip (handedness) of grid returns as 1 or -1.
1544
+
1545
+ The flip numbers are 1 for left-handed and -1 for right-handed.
1546
+
1547
+ .. seealso:: :py:attr:`~ijk_handedness`
1548
+ """
1549
+ self._set_xtgformat2() # ensure xtgformat 2!
1550
+ handedness = _estimate_grid_ijk_handedness(self._coordsv.copy())
1551
+ return -1 if handedness == "right" else 1
1552
+
1553
+ def subgrids_from_zoneprop(self, zoneprop: GridProperty) -> dict[str, int] | None:
1554
+ """Estimate subgrid index from a zone property.
1555
+
1556
+ The new will estimate which will replace the current if any.
1557
+
1558
+ Args:
1559
+ zoneprop(GridProperty): a XTGeo GridProperty instance.
1560
+
1561
+ Returns:
1562
+ Will also return simplified dictionary is on the form
1563
+ {"name1": 3, "name2": 5}
1564
+ """
1565
+ _, _, k_index = self.get_ijk()
1566
+ kval = k_index.values
1567
+ zprval = zoneprop.values
1568
+ minzone = int(zprval.min())
1569
+ maxzone = int(zprval.max())
1570
+
1571
+ newd: dict[str, range] = {}
1572
+ for izone in range(minzone, maxzone + 1):
1573
+ mininzn = int(kval[zprval == izone].min()) # 1 base
1574
+ maxinzn = int(kval[zprval == izone].max()) # 1 base
1575
+
1576
+ newd[zoneprop.codes.get(izone, "zone" + str(izone))] = range(
1577
+ mininzn, maxinzn + 1
1578
+ )
1579
+
1580
+ self.subgrids = newd # type: ignore
1581
+
1582
+ return self.get_subgrids()
1583
+
1584
+ def get_zoneprop_from_subgrids(self) -> xtgeo.GridProperty | None:
1585
+ """
1586
+ Create a discrete GridProperty encoding subgrid indices as zone values.
1587
+
1588
+ Returns:
1589
+ A GridProperty where each layer belonging to a subgrid is assigned a unique
1590
+ integer zone index (starting from 1). The property codes map these indices
1591
+ to subgrid names. Returns None if no subgrids are defined.
1592
+ """
1593
+ if not self.subgrids:
1594
+ return None
1595
+
1596
+ zoneprop = xtgeo.GridProperty(
1597
+ ncol=self.ncol,
1598
+ nrow=self.nrow,
1599
+ nlay=self.nlay,
1600
+ name="Zone",
1601
+ discrete=True,
1602
+ values=0,
1603
+ )
1604
+ for i, (name, layers) in enumerate(self.subgrids.items()):
1605
+ zoneprop.codes[i + 1] = name
1606
+ zoneprop.values[:, :, min(layers) - 1 : max(layers)] = i + 1
1607
+ return zoneprop
1608
+
1609
+ def get_boundary_polygons(
1610
+ self: Grid,
1611
+ alpha_factor: float = 1.0,
1612
+ convex: bool = False,
1613
+ simplify: bool | dict[str, Any] = True,
1614
+ filter_array: np.ndarray | None = None,
1615
+ ) -> Polygons:
1616
+ """Extract boundary polygons from the grid cell centers.
1617
+
1618
+ A ``filter_array`` can be applied to extract boundaries around specific
1619
+ parts of the grid e.g. a region or a zone.
1620
+
1621
+ The concavity and precision of the boundaries are controlled by the
1622
+ ``alpha_factor``. A low ``alpha_factor`` makes more precise boundaries,
1623
+ while a larger value makes more rough polygons.
1624
+
1625
+ Note that the ``alpha_factor`` is a multiplier (default value 1) on top
1626
+ of an auto estimated value, derived from the maximum xinc and yinc from
1627
+ the grid cells. Dependent on the regularity of the grid, tuning of the
1628
+ alpha_factor (up/down) is sometimes necessary to get satisfactory results.
1629
+
1630
+ Args:
1631
+ alpha_factor: An alpha multiplier, which controls the precision of the
1632
+ boundaries. A higher number will produce smoother and less accurate
1633
+ polygons. Not applied if convex is set to True.
1634
+ convex: The default is False, which means that a "concave hull" algorithm
1635
+ is used. If convex is True, the alpha factor is overridden to a large
1636
+ number, producing a 'convex' shape boundary instead.
1637
+ simplify: If True, a simplification is done in order to reduce the number
1638
+ of points in the polygons, where tolerance is 0.1. Another
1639
+ alternative to True is to input a Dict on the form
1640
+ ``{"tolerance": 2.0, "preserve_topology": True}``, cf. the
1641
+ :func:`Polygons.simplify()` method. For details on e.g. tolerance, see
1642
+ Shapely's simplify() method.
1643
+ filter_array: An numpy boolean array with equal shape as the grid dimension,
1644
+ used to filter the grid cells and define where to extract boundaries.
1645
+
1646
+ Returns:
1647
+ A XTGeo Polygons instance
1648
+
1649
+ Example::
1650
+
1651
+ grid = xtgeo.grid_from_roxar(project, "Simgrid")
1652
+ # extract polygon for a specific region, here region 3
1653
+ region = xtgeo.gridproperty_from_roxar(project, "Simgrid", "Regions")
1654
+ filter_array = (region.values==3)
1655
+ boundary = grid.get_boundary_polygons(filter_array=filter_array)
1656
+
1657
+ See also:
1658
+ The :func:`Polygons.boundary_from_points()` class method.
1659
+
1660
+ """
1661
+ return _grid_boundary.create_boundary(
1662
+ self, alpha_factor, convex, simplify, filter_array
1663
+ )
1664
+
1665
+ def get_actnum_indices(
1666
+ self,
1667
+ order: Literal["C", "F", "A", "K"] = "C",
1668
+ inverse: bool = False,
1669
+ ) -> np.ndarray:
1670
+ """Returns the 1D ndarray which holds the indices for active cells.
1671
+
1672
+ Args:
1673
+ order (str): "Either 'C' (default) or 'F' order).
1674
+ inverse (bool): Default is False, returns indices for inactive cells
1675
+ if True.
1676
+
1677
+ .. versionchanged:: 2.18 Added inverse option
1678
+ """
1679
+ actnumv = self.get_actnum().values.copy(order=order)
1680
+ actnumv = np.ravel(actnumv, order=order)
1681
+ if inverse:
1682
+ actnumv -= 1
1683
+ return np.flatnonzero(actnumv)
1684
+ return np.flatnonzero(actnumv)
1685
+
1686
+ def get_dualactnum_indices(
1687
+ self,
1688
+ order: Literal["C", "F", "A", "K"] = "C",
1689
+ fracture: bool = False,
1690
+ ) -> np.ndarray | None:
1691
+ """Returns the 1D ndarray which holds the indices for matrix/fracture cases.
1692
+
1693
+ Args:
1694
+ order (str): "Either 'C' (default) or 'F' order).
1695
+ fracture (bool): If True use Fracture properties.
1696
+ """
1697
+ if not self._dualporo:
1698
+ return None
1699
+
1700
+ assert self._dualactnum is not None
1701
+ actnumv = self._dualactnum.values.copy(order=order)
1702
+ actnumv = np.ravel(actnumv, order=order)
1703
+
1704
+ if fracture:
1705
+ actnumvf = actnumv.copy()
1706
+ actnumvf[(actnumv == 3) | (actnumv == 2)] = 1
1707
+ actnumvf[(actnumv == 1) | (actnumv == 0)] = 0
1708
+ return np.flatnonzero(actnumvf)
1709
+
1710
+ actnumvm = actnumv.copy()
1711
+ actnumvm[(actnumv == 3) | (actnumv == 1)] = 1
1712
+ actnumvm[(actnumv == 2) | (actnumv == 0)] = 0
1713
+ return np.flatnonzero(actnumvm)
1714
+
1715
+ def get_prop_by_name(self, name: str) -> GridProperty | None:
1716
+ """Gets a property object by name lookup, return None if not present."""
1717
+
1718
+ if self.props is None:
1719
+ raise RuntimeError(
1720
+ f"{self.__class__.__name__} has no gird "
1721
+ "property objects (self.props is None)"
1722
+ )
1723
+
1724
+ for obj in self.props:
1725
+ if obj.name == name:
1726
+ return obj
1727
+
1728
+ return None
1729
+
1730
+ def get_actnum(
1731
+ self,
1732
+ name: str = "ACTNUM",
1733
+ asmasked: bool = False,
1734
+ dual: bool = False,
1735
+ ) -> GridProperty:
1736
+ """Return an ACTNUM GridProperty object.
1737
+
1738
+ Args:
1739
+ name (str): name of property in the XTGeo GridProperty object.
1740
+ asmasked (bool): Actnum is returned with all cells shown
1741
+ as default. Use asmasked=True to make 0 entries masked.
1742
+ dual (bool): If True, and the grid is a dualporo/perm grid, an
1743
+ extended ACTNUM is applied (numbers 0..3)
1744
+
1745
+ Example::
1746
+
1747
+ >>> import xtgeo
1748
+ >>> mygrid = xtgeo.create_box_grid((2,2,2))
1749
+ >>> act = mygrid.get_actnum()
1750
+ >>> print("{}% of cells are active".format(act.values.mean() * 100))
1751
+ 100.0% of cells are active
1752
+
1753
+ .. versionchanged:: 2.6 Added ``dual`` keyword
1754
+ """
1755
+ if dual and self._dualactnum:
1756
+ act = self._dualactnum.copy()
1757
+ else:
1758
+ act = xtgeo.grid3d.GridProperty(
1759
+ ncol=self._ncol,
1760
+ nrow=self._nrow,
1761
+ nlay=self._nlay,
1762
+ values=np.zeros((self._ncol, self._nrow, self._nlay), dtype=np.int32),
1763
+ name=name,
1764
+ discrete=True,
1765
+ )
1766
+
1767
+ if self._xtgformat == 1:
1768
+ values = _gridprop_lowlevel.f2c_order(self, self._actnumsv)
1769
+ else:
1770
+ values = self._actnumsv
1771
+
1772
+ act.values = values
1773
+ act.mask_undef()
1774
+
1775
+ if asmasked:
1776
+ act.values = ma.masked_equal(act.values, 0)
1777
+
1778
+ act.codes = {0: "0", 1: "1"}
1779
+ if dual and self._dualactnum:
1780
+ act.codes = {0: "0", 1: "1", 2: "2", 3: "3"}
1781
+
1782
+ return act
1783
+
1784
+ def set_actnum(self, actnum: GridProperty) -> None:
1785
+ """Modify the existing active cell index, ACTNUM.
1786
+
1787
+ Args:
1788
+ actnum (GridProperty): a gridproperty instance with 1 for active
1789
+ cells, 0 for inactive cells
1790
+
1791
+ Example::
1792
+ >>> mygrid = create_box_grid((5,5,5))
1793
+ >>> act = mygrid.get_actnum()
1794
+ >>> act.values[:, :, :] = 1
1795
+ >>> act.values[:, :, 4] = 0
1796
+ >>> mygrid.set_actnum(act)
1797
+ """
1798
+ val1d = actnum.values.ravel()
1799
+
1800
+ if self._xtgformat == 1:
1801
+ self._actnumsv = _gridprop_lowlevel.c2f_order(self, val1d)
1802
+ else:
1803
+ self._actnumsv = np.ma.filled(actnum.values, fill_value=0).astype(np.int32)
1804
+
1805
+ def get_dz(
1806
+ self,
1807
+ name: str = "dZ",
1808
+ flip: bool = True,
1809
+ asmasked: bool = True,
1810
+ metric: METRIC = "z projection",
1811
+ ) -> GridProperty:
1812
+ """Return the dZ as GridProperty object.
1813
+
1814
+ Returns the average length of z direction edges for each
1815
+ cell as a GridProperty. The length is by default the
1816
+ z delta, ie. projected onto the z dimension (see the metric parameter).
1817
+
1818
+ Args:
1819
+ name (str): name of property
1820
+ flip (bool): Use False for Petrel grids were Z is negative down
1821
+ (experimental)
1822
+ asmasked (bool): True if only for active cells, False for all cells.
1823
+ With `False` the inactive cells are included, but the numpy
1824
+ array is still a MaskedArray instance.
1825
+ metric (str): One of the following metrics:
1826
+ * "euclid": sqrt(dx^2 + dy^2 + dz^2)
1827
+ * "horizontal": sqrt(dx^2 + dy^2)
1828
+ * "east west vertical": sqrt(dy^2 + dz^2)
1829
+ * "north south vertical": sqrt(dx^2 + dz^2)
1830
+ * "x projection": dx
1831
+ * "y projection": dy
1832
+ * "z projection": dz
1833
+
1834
+ Returns:
1835
+ A XTGeo GridProperty object dZ
1836
+ """
1837
+ return _grid_etc1.get_dz(
1838
+ self,
1839
+ name=name,
1840
+ flip=flip,
1841
+ asmasked=asmasked,
1842
+ metric=metric,
1843
+ )
1844
+
1845
+ def get_dx(
1846
+ self,
1847
+ name: str = "dX",
1848
+ asmasked: bool = True,
1849
+ metric: METRIC = "horizontal",
1850
+ ) -> GridProperty:
1851
+ """Return the dX as GridProperty object.
1852
+
1853
+ Returns the average length of x direction edges for each
1854
+ cell as a GridProperty. The length is by default horizontal
1855
+ vector length (see the metric parameter).
1856
+
1857
+ Args:
1858
+ name (str): names of properties
1859
+ asmasked (bool). If True, make a np.ma array where inactive cells
1860
+ are masked. Otherwise the inactive cells are included, but the numpy
1861
+ array is still a MaskedArray instance.
1862
+ metric (str): One of the following metrics:
1863
+ * "euclid": sqrt(dx^2 + dy^2 + dz^2)
1864
+ * "horizontal": sqrt(dx^2 + dy^2)
1865
+ * "east west vertical": sqrt(dy^2 + dz^2)
1866
+ * "north south vertical": sqrt(dx^2 + dz^2)
1867
+ * "x projection": dx
1868
+ * "y projection": dy
1869
+ * "z projection": dz
1870
+
1871
+ Returns:
1872
+ XTGeo GridProperty objects containing dx.
1873
+ """
1874
+ return _grid_etc1.get_dx(self, name=name, asmasked=asmasked, metric=metric)
1875
+
1876
+ def get_dy(
1877
+ self,
1878
+ name: str = "dY",
1879
+ asmasked: bool = True,
1880
+ metric: METRIC = "horizontal",
1881
+ ) -> GridProperty:
1882
+ """Return the dY as GridProperty object.
1883
+
1884
+ Returns the average length of y direction edges for each
1885
+ cell as a GridProperty. The length is by default horizontal
1886
+ vector length (see the metric parameter).
1887
+
1888
+ Args:
1889
+ name (str): names of properties
1890
+ asmasked (bool). If True, make a np.ma array where inactive cells
1891
+ are masked. Otherwise the inactive cells are included, but the numpy
1892
+ array is still a MaskedArray instance.
1893
+ metric (str): One of the following metrics:
1894
+ * "euclid": sqrt(dx^2 + dy^2 + dz^2)
1895
+ * "horizontal": sqrt(dx^2 + dy^2)
1896
+ * "east west vertical": sqrt(dy^2 + dz^2)
1897
+ * "north south vertical": sqrt(dx^2 + dz^2)
1898
+ * "x projection": dx
1899
+ * "y projection": dy
1900
+ * "z projection": dz
1901
+
1902
+ Returns:
1903
+ Two XTGeo GridProperty objects (dx, dy).
1904
+ """
1905
+ return _grid_etc1.get_dy(self, name=name, asmasked=asmasked, metric=metric)
1906
+
1907
+ def get_cell_volume(
1908
+ self,
1909
+ ijk: tuple[int, int, int] = (1, 1, 1),
1910
+ activeonly: bool = True,
1911
+ zerobased: bool = False,
1912
+ precision: Literal[1, 2, 4] = 2,
1913
+ ) -> float:
1914
+ """Return the bulk volume for a given cell.
1915
+
1916
+ This method is currently *experimental*.
1917
+
1918
+ A bulk volume of a cornerpoint cell is actually a non-trivial and a non-unique
1919
+ entity. The volume is approximated by dividing the cell (hexahedron) into
1920
+ 6 tetrehedrons; there is however a large number of ways to do this division.
1921
+
1922
+ As default (precision=2) an average of two different ways to divide the cell
1923
+ into tetrahedrons is averaged.
1924
+
1925
+ Args:
1926
+ ijk (tuple): A tuple of I J K (NB! cell counting starts from 1
1927
+ unless zerobased is True).
1928
+ activeonly (bool): Skip undef cells if True; return None for inactive.
1929
+ precision (int): An even number indication precision level,where
1930
+ a higher number means increased precision but also increased computing
1931
+ time. Currently 1, 2, 4 are supported.
1932
+
1933
+ Returns:
1934
+ Cell total bulk volume
1935
+
1936
+ Example::
1937
+
1938
+ >>> import xtgeo
1939
+ >>> grid = xtgeo.grid_from_file(reek_dir + "/REEK.EGRID")
1940
+ >>> print(grid.get_cell_volume(ijk=(10,13,2)))
1941
+ 107056...
1942
+
1943
+ .. versionadded:: 2.13 (as experimental)
1944
+ """
1945
+ return _grid_etc1.get_cell_volume(
1946
+ self,
1947
+ ijk=ijk,
1948
+ activeonly=activeonly,
1949
+ zerobased=zerobased,
1950
+ precision=precision,
1951
+ )
1952
+
1953
+ def get_bulk_volume(
1954
+ self,
1955
+ name: str = "bulkvol",
1956
+ asmasked: bool = True,
1957
+ precision: Literal[1, 2, 4] = 2,
1958
+ ) -> GridProperty:
1959
+ """Return the geometric cell volume for all cells as a GridProperty object.
1960
+
1961
+ This method is currently *experimental*.
1962
+
1963
+ A bulk volume of a cornerpoint cell is actually a non-trivial and a non-unique
1964
+ entity. The volume is approximated by dividing the cell (hexahedron) into
1965
+ 6 tetrehedrons; there is however a large number of ways to do this division.
1966
+
1967
+ As default (precision=2) an average of two different ways to divide the cell
1968
+ into tetrahedrons is averaged.
1969
+
1970
+ Args:
1971
+ name (str): name of property, default to "bulkvol"
1972
+ asmasked (bool). If True, make a np.ma array where inactive cells
1973
+ are masked. Otherwise a numpy array will all bulk for all cells is
1974
+ returned
1975
+ precision (int): Not applied!
1976
+
1977
+ Returns:
1978
+ XTGeo GridProperty object
1979
+
1980
+ .. versionadded:: 2.13 (as experimental)
1981
+
1982
+ """
1983
+ return _grid_etc1.get_bulk_volume(
1984
+ self, name=name, precision=precision, asmasked=asmasked
1985
+ )
1986
+
1987
+ def get_phase_volumes(
1988
+ self,
1989
+ water_contact: float | GridProperty,
1990
+ gas_contact: float | GridProperty,
1991
+ boundary: Polygons | None = None,
1992
+ asmasked: bool = True,
1993
+ precision: Literal[1, 2, 4] = 2,
1994
+ ) -> tuple[GridProperty, GridProperty, GridProperty]:
1995
+ """Return the geometric phase cell volume for all cells as three
1996
+ GridProperty objects, namely gas_bulkvol, oil_bulkvol and water_bulkvol.
1997
+
1998
+ The volume calculation is constrained to the area within the provided
1999
+ boundary polygon. In case of multiple polygons, only the first polygon
2000
+ will be used.
2001
+
2002
+ A bulk volume of a cornerpoint cell is a non-trivial and non-unique
2003
+ quantity. The volume is approximated by dividing the cell (hexahedron)
2004
+ into six tetrahedrons; there are multiple ways to perform this division.
2005
+
2006
+ By default (precision=2) an average of two different tetrahedral
2007
+ decompositions is used.
2008
+
2009
+ Args:
2010
+ water_contact: Water-oil contact, in most cases refers to free water level.
2011
+ gas_contact: Gas-oil contact, in most cases refers to free gas level.
2012
+ boundary: Boundary area. If multiple polygons are present, only the
2013
+ first polygon is used.
2014
+ asmasked: If True, make a numpy.ma array where inactive cells are
2015
+ masked. Otherwise a numpy array with bulk volumes for all cells
2016
+ is returned.
2017
+ precision (int): An even number indicating precision level, where a
2018
+ higher number increases precision and computing time. Currently
2019
+ 1, 2 and 4 are supported.
2020
+ Returns:
2021
+ Three XTGeo GridProperty objects: gas, oil and water volumes.
2022
+
2023
+ Example::
2024
+
2025
+ >>> grid = xtgeo.grid_from_file("myGrid.roff")
2026
+ >>> gas, oil, water = grid.get_phase_volumes(
2027
+ ... water_contact=1700.0, gas_contact=1650.0
2028
+ ... )
2029
+ >>> print(f"Total gas volume: {gas.values.sum()}")
2030
+ """
2031
+ return _grid_etc1.get_phase_bulk_volumes(
2032
+ self,
2033
+ water_contact=water_contact,
2034
+ gas_contact=gas_contact,
2035
+ boundary=boundary,
2036
+ precision=precision,
2037
+ asmasked=asmasked,
2038
+ )
2039
+
2040
+ def get_heights_above_ffl(
2041
+ self,
2042
+ ffl: GridProperty,
2043
+ option: str = "cell_center_above_ffl",
2044
+ ) -> tuple[GridProperty, GridProperty, GridProperty]:
2045
+ """Returns 3 properties: htop, hbot and hmid, primarely for use in Sw models."
2046
+
2047
+ Args:
2048
+ ffl: Free fluid level e.g. FWL (or level whatever is required; a level from
2049
+ which cells above will be shown as delta heights (positive), while
2050
+ cells below will have 0.0 values.
2051
+ option: How to compute values, as either "cell_center_above_ffl",
2052
+ "cell_corners_above_ffl" or "truncated_cell_corners_above_ffl".
2053
+ The first one looks at cell Z centerlines, and compute the top,
2054
+ the bottom and the midpoint. The second will look at cell corners,
2055
+ using the uppermost corner for top, and the lowermost corner for bottom.
2056
+ The third will truncate all cell corners above ffl and compute cell Z
2057
+ centerlines. In all cases, values are modified if cell is intersected
2058
+ with the provided ffl.
2059
+
2060
+ Returns:
2061
+ (htop, hbot, hmid) delta heights, as xtgeo GridProperty objects
2062
+
2063
+ .. versionadded:: 3.9
2064
+
2065
+ """
2066
+ return _grid_etc1.get_heights_above_ffl(self, ffl=ffl, option=option)
2067
+
2068
+ def get_property_between_surfaces(
2069
+ self,
2070
+ top: xtgeo.RegularSurface,
2071
+ base: xtgeo.RegularSurface,
2072
+ value: int = 1,
2073
+ name: str = "between_surfaces",
2074
+ ) -> GridProperty:
2075
+ """Returns a 3D GridProperty object with <value> between two surfaces."
2076
+
2077
+ Args:
2078
+ top: The bounding top surface (RegularSurface object)
2079
+ base: The bounding base surface (RegularSurface object)
2080
+ value: An integer > 0 to assign to cells between surfaces, 1 as default
2081
+ name: Name of the property, default is "between_surfaces"
2082
+
2083
+ Returns:
2084
+ xtgeo GridProperty object with <value> if cell center is between surfaces,
2085
+ otherwise 0. Note that the property wil be discrete if input value is an
2086
+ integer, otherwise it will be continuous.
2087
+
2088
+ .. versionadded:: 4.5
2089
+
2090
+ """
2091
+ return _grid_etc1.get_property_between_surfaces(self, top, base, value, name)
2092
+
2093
+ def get_ijk(
2094
+ self,
2095
+ names: tuple[str, str, str] = ("IX", "JY", "KZ"),
2096
+ asmasked: bool = True,
2097
+ zerobased: bool = False,
2098
+ ) -> tuple[GridProperty, GridProperty, GridProperty]:
2099
+ """Returns 3 xtgeo.grid3d.GridProperty objects: I counter, J counter, K counter.
2100
+
2101
+ Args:
2102
+ names: a 3 x tuple of names per property (default IX, JY, KZ).
2103
+ asmasked: If True, UNDEF cells are masked, default is True
2104
+ zerobased: If True, counter start from 0, otherwise 1 (default=1).
2105
+ """
2106
+ ixc, jyc, kzc = _grid_etc1.get_ijk(
2107
+ self, names=names, asmasked=asmasked, zerobased=zerobased
2108
+ )
2109
+
2110
+ # return the objects
2111
+ return ixc, jyc, kzc
2112
+
2113
+ def get_ijk_from_points(
2114
+ self,
2115
+ points: Points,
2116
+ activeonly: bool = True,
2117
+ zerobased: bool = False,
2118
+ dataframe: bool = True,
2119
+ includepoints: bool = True,
2120
+ columnnames: tuple[str, str, str] = ("IX", "JY", "KZ"),
2121
+ fmt: Literal["int", "float"] = "int",
2122
+ undef: int = -1,
2123
+ ) -> pd.DataFrame | list:
2124
+ """Returns a list/dataframe of cell indices based on a Points() instance.
2125
+
2126
+ If a point is outside the grid, -1 values are returned
2127
+
2128
+ Args:
2129
+ points (Points): A XTGeo Points instance
2130
+ activeonly (bool): If True, UNDEF cells are not included
2131
+ zerobased (bool): If True, counter start from 0, otherwise 1 (default=1).
2132
+ dataframe (bool): If True result is Pandas dataframe, otherwise a list
2133
+ of tuples
2134
+ includepoints (bool): If True, include the input points in result
2135
+ columnnames (tuple): Name of columns if dataframe is returned
2136
+ fmt (str): Format of IJK arrays (int/float). Default is "int"
2137
+ undef (int or float): Value to assign to undefined (outside) entries.
2138
+
2139
+ .. versionadded:: 2.6
2140
+ .. versionchanged:: 2.8 Added keywords `columnnames`, `fmt`, `undef`
2141
+ """
2142
+ return _grid_etc1.get_ijk_from_points(
2143
+ self,
2144
+ points,
2145
+ activeonly=activeonly,
2146
+ zerobased=zerobased,
2147
+ dataframe=dataframe,
2148
+ includepoints=includepoints,
2149
+ columnnames=columnnames,
2150
+ fmt=fmt,
2151
+ undef=undef,
2152
+ )
2153
+
2154
+ def get_xyz(
2155
+ self,
2156
+ names: tuple[str, str, str] = ("X_UTME", "Y_UTMN", "Z_TVDSS"),
2157
+ asmasked: bool = True,
2158
+ ) -> tuple[
2159
+ GridProperty,
2160
+ GridProperty,
2161
+ GridProperty,
2162
+ ]:
2163
+ """Returns 3 xtgeo.grid3d.GridProperty objects for x, y, z coordinates.
2164
+
2165
+ The values are mid cell values. Note that ACTNUM is
2166
+ ignored, so these is also extracted for UNDEF cells (which may have
2167
+ weird coordinates). However, the option asmasked=True will mask
2168
+ the numpies for undef cells.
2169
+
2170
+ Args:
2171
+ names: a 3 x tuple of names per property (default is X_UTME,
2172
+ Y_UTMN, Z_TVDSS).
2173
+ asmasked: If True, then inactive cells is masked (numpy.ma).
2174
+ """
2175
+ return _grid_etc1.get_xyz(self, names=tuple(names), asmasked=asmasked)
2176
+
2177
+ def get_xyz_cell_corners(
2178
+ self,
2179
+ ijk: tuple[int, int, int] = (1, 1, 1),
2180
+ activeonly: bool = True,
2181
+ zerobased: bool = False,
2182
+ ) -> tuple[int, ...]:
2183
+ """Return a 8 * 3 tuple x, y, z for each corner.
2184
+
2185
+ .. code-block:: none
2186
+
2187
+ 2 3
2188
+ !~~~~~~~!
2189
+ ! top !
2190
+ !~~~~~~~! Listing corners with Python index (0 base)
2191
+ 0 1
2192
+
2193
+ 6 7
2194
+ !~~~~~~~!
2195
+ ! base !
2196
+ !~~~~~~~!
2197
+ 4 5
2198
+
2199
+ Args:
2200
+ ijk (tuple): A tuple of I J K (NB! cell counting starts from 1
2201
+ unless zerobased is True)
2202
+ activeonly (bool): Skip undef cells if set to True.
2203
+
2204
+ Returns:
2205
+ A tuple with 24 elements (x1, y1, z1, ... x8, y8, z8)
2206
+ for 8 corners. None if cell is inactive and activeonly=True.
2207
+
2208
+ Example::
2209
+
2210
+ >>> grid = grid_from_file(reek_dir + "REEK.EGRID")
2211
+ >>> print(grid.get_xyz_cell_corners(ijk=(10,13,2)))
2212
+ (458704.10..., 1716.969970703125)
2213
+
2214
+ Raises:
2215
+ RuntimeWarning if spesification is invalid.
2216
+ """
2217
+
2218
+ return _grid_etc1.get_xyz_cell_corners_internal(
2219
+ self, ijk=ijk, activeonly=activeonly, zerobased=zerobased
2220
+ )
2221
+
2222
+ def get_xyz_corners(
2223
+ self, names: tuple[str, str, str] = ("X_UTME", "Y_UTMN", "Z_TVDSS")
2224
+ ) -> tuple[GridProperty, ...]:
2225
+ """Returns 8*3 (24) xtgeo.grid3d.GridProperty objects, x, y, z for each corner.
2226
+
2227
+ The values are cell corner values. Note that ACTNUM is
2228
+ ignored, so these is also extracted for UNDEF cells (which may have
2229
+ weird coordinates).
2230
+
2231
+ .. code-block:: none
2232
+
2233
+ 2 3
2234
+ !~~~~~~~!
2235
+ ! top !
2236
+ !~~~~~~~! Listing corners with Python index (0 base)
2237
+ 0 1
2238
+
2239
+ 6 7
2240
+ !~~~~~~~!
2241
+ ! base !
2242
+ !~~~~~~~!
2243
+ 4 5
2244
+
2245
+ Args:
2246
+ names (list): Generic name of the properties, will have a
2247
+ number added, e.g. X0, X1, etc.
2248
+
2249
+ Example::
2250
+
2251
+ >>> import xtgeo
2252
+ >>> grid = xtgeo.create_box_grid((2,2,2))
2253
+ >>> gps = grid.get_xyz_corners() # list of 24 grid properties
2254
+ >>> len(gps)
2255
+ 24
2256
+ >>> gps[0].values.tolist()
2257
+ [[[0.0, 0.0], ... [[1.0, 1.0], [1.0, 1.0]]]
2258
+
2259
+
2260
+ Raises:
2261
+ RunetimeError if corners has wrong spesification
2262
+ """
2263
+ # return the 24 objects in a long tuple (x1, y1, z1, ... x8, y8, z8)
2264
+ return _grid_etc1.get_xyz_corners(self, names=names)
2265
+
2266
+ def get_layer_slice(
2267
+ self, layer: int, top: bool = True, activeonly: bool = True
2268
+ ) -> tuple[np.ndarray, np.ndarray]:
2269
+ """Get numpy arrays for cell coordinates e.g. for plotting.
2270
+
2271
+ In each cell there are 5 XY pairs, making a closed polygon as illustrated here:
2272
+
2273
+ XY3 < XY2
2274
+ !~~~~~~~!
2275
+ ! ! ^
2276
+ !~~~~~~~!
2277
+ XY0 -> XY1
2278
+ XY4
2279
+
2280
+ Note that cell ordering is C ordering (row is fastest)
2281
+
2282
+ Args:
2283
+ layer (int): K layer, starting with 1 as topmost
2284
+ tip (bool): If True use top of cell, otherwise use base
2285
+ activeonly (bool): If True, only return active cells
2286
+
2287
+ Returns:
2288
+ layerarray (np): [[[X0, Y0], [X1, Y1]...[X4, Y4]], [[..][..]]...]
2289
+ icarray (np): On the form [ic1, ic2, ...] where ic is cell count (C order)
2290
+
2291
+ Example:
2292
+
2293
+ Return two arrays forr cell corner for bottom layer::
2294
+
2295
+ grd = xtgeo.grid_from_file(REEKFILE)
2296
+
2297
+ parr, ibarr = grd.get_layer_slice(grd.nlay, top=False)
2298
+
2299
+ .. versionadded:: 2.3
2300
+ """
2301
+ return _grid_etc1.get_layer_slice(self, layer, top=top, activeonly=activeonly)
2302
+
2303
+ def get_geometrics(
2304
+ self,
2305
+ allcells: bool = False,
2306
+ cellcenter: bool = True,
2307
+ return_dict: bool = False,
2308
+ _ver: Literal[1, 2] = 1,
2309
+ ) -> dict | tuple:
2310
+ """Get a list of grid geometrics such as origin, min, max, etc.
2311
+
2312
+ This returns a tuple: (xori, yori, zori, xmin, xmax, ymin, ymax, zmin,
2313
+ zmax, avg_rotation, avg_dx, avg_dy, avg_dz, grid_regularity_flag)
2314
+
2315
+ If a dictionary is returned, the keys are as in the list above.
2316
+
2317
+ Args:
2318
+ allcells (bool): If True, return also for inactive cells
2319
+ cellcenter (bool): If True, use cell center, otherwise corner
2320
+ coords
2321
+ return_dict (bool): If True, return a dictionary instead of a
2322
+ list, which is usually more convinient.
2323
+ _ver (int): Private option; only for developer!
2324
+
2325
+ Raises: Nothing
2326
+
2327
+ Example::
2328
+
2329
+ >>> mygrid = grid_from_file(reek_dir + "REEK.EGRID")
2330
+ >>> gstuff = mygrid.get_geometrics(return_dict=True)
2331
+ >>> print(f"X min/max is {gstuff['xmin']:.2f} {gstuff['xmax']:.2f}")
2332
+ X min/max is 456620.79 467106.33
2333
+
2334
+ """
2335
+ # TODO(JB): _grid_etc1.get_geometrics(False, False, True): Looks like it will
2336
+ # fail due to glist and gkeys will be out of sync (lengths will be differnt)
2337
+ return _grid_etc1.get_geometrics(
2338
+ self,
2339
+ allcells=allcells,
2340
+ cellcenter=cellcenter,
2341
+ return_dict=return_dict,
2342
+ _ver=_ver,
2343
+ )
2344
+
2345
+ def get_adjacent_cells(
2346
+ self,
2347
+ prop: GridProperty,
2348
+ val1: int,
2349
+ val2: int,
2350
+ activeonly: bool = True,
2351
+ ) -> GridProperty:
2352
+ """Get a discrete property which reports val1 properties vs neighbouring val2.
2353
+
2354
+ The result will be a new gridproperty, which in general has value 0
2355
+ but 1 if criteria is met, and 2 if criteria is met but cells are
2356
+ faulted.
2357
+
2358
+ Args:
2359
+ prop (xtgeo.GridProperty): A discrete grid property, e.g region
2360
+ val1 (int): Primary value to evaluate
2361
+ val2 (int): Neighbourung value
2362
+ activeonly (bool): If True, do not look at inactive cells
2363
+
2364
+ Raises: Nothing
2365
+
2366
+ """
2367
+ return _grid_etc1.get_adjacent_cells(
2368
+ self, prop, val1, val2, activeonly=activeonly
2369
+ )
2370
+
2371
+ def get_gridquality_properties(self) -> GridProperties:
2372
+ """Return a GridProperties() instance with grid quality measures.
2373
+
2374
+ These measures are currently:
2375
+
2376
+ * minangle_topbase (degrees) - minimum angle of top and base
2377
+ * maxangle_topbase (degrees) - maximum angle of top and base
2378
+ * minangle_topbase_proj (degrees) min angle projected (bird view)
2379
+ * maxangle_topbase_proj (degrees) max angle projected (bird view)
2380
+ * minangle_sides (degress) minimum angle, all side surfaces
2381
+ * maxangle_sides (degress) maximum angle, all side surfaces
2382
+ * collapsed (int) Integer, 1 of one or more corners are collapsed in Z
2383
+ * faulted (int) Integer, 1 if cell is faulted (one or more neighbours offset)
2384
+ * negative_thickness (int) Integer, 1 if cell has negative thickness
2385
+ * concave_proj (int) 1 if cell is concave seen from projected bird view
2386
+
2387
+ Example::
2388
+
2389
+ # store grid quality measures in RMS
2390
+ gprops = grd.gridquality()
2391
+ for gprop in gprops:
2392
+ gprop.to_roxar(project, "MyGrid", gprop.name)
2393
+
2394
+
2395
+ """
2396
+ return _grid_etc1.get_gridquality_properties(self)
2397
+
2398
+ # =========================================================================
2399
+ # Some more special operations that changes the grid or actnum
2400
+ # =========================================================================
2401
+ def activate_all(self) -> None:
2402
+ """Activate all cells in the grid, by manipulating ACTNUM."""
2403
+ self._actnumsv = np.ones(self.dimensions, dtype=np.int32)
2404
+
2405
+ if self._xtgformat == 1:
2406
+ self._actnumsv = self._actnumsv.flatten()
2407
+
2408
+ def inactivate_by_dz(self, threshold: float) -> None:
2409
+ """Inactivate cells thinner than a given threshold."""
2410
+ _grid_etc1.inactivate_by_dz(self, threshold)
2411
+
2412
+ def inactivate_inside(
2413
+ self,
2414
+ poly: Polygons,
2415
+ layer_range: tuple[int, int] | None = None,
2416
+ inside: bool = True,
2417
+ force_close: bool = False,
2418
+ ) -> None:
2419
+ """Inactivate grid inside a polygon.
2420
+
2421
+ The Polygons instance may consist of several polygons. If a polygon
2422
+ is open, then the flag force_close will close any that are not open
2423
+ when doing the operations in the grid.
2424
+
2425
+ Args:
2426
+ poly(Polygons): A polygons object
2427
+ layer_range (tuple): A tuple of two ints, upper layer = 1, e.g.
2428
+ (1, 14). Note that base layer count is 1 (not zero)
2429
+ inside (bool): True if remove inside polygon
2430
+ force_close (bool): If True then force polygons to be closed.
2431
+
2432
+ Raises:
2433
+ RuntimeError: If a problems with one or more polygons.
2434
+ ValueError: If Polygon is not a XTGeo object
2435
+ """
2436
+ _grid_etc1.inactivate_inside(
2437
+ self, poly, layer_range=layer_range, inside=inside, force_close=force_close
2438
+ )
2439
+
2440
+ def inactivate_outside(
2441
+ self,
2442
+ poly: Polygons,
2443
+ layer_range: tuple[int, int] | None = None,
2444
+ force_close: bool = False,
2445
+ ) -> None:
2446
+ """Inactivate grid outside a polygon."""
2447
+ self.inactivate_inside(
2448
+ poly, layer_range=layer_range, inside=False, force_close=force_close
2449
+ )
2450
+
2451
+ def collapse_inactive_cells(self, internal: bool = True) -> None:
2452
+ """Collapse inactive layers per I J column (~vertically).
2453
+
2454
+ Seen by I,J column, the inactive cells are collapsed to the first active cell in
2455
+ the column. First transversed from top, then from bottom. If no active cells in
2456
+ the column, the (invisible) Z coordinates are averaged to one common location.
2457
+
2458
+ If `internal` is True (default), then also internal inactive cells (i.e.
2459
+ inactive "hole" surrounded by active cells) are collapsed. In this case the Z
2460
+ coordinates of the adjacent active cells are moved to fill the gap.
2461
+
2462
+ The current grid instance will be updated.
2463
+
2464
+ Args:
2465
+ internal: If True (default), then the internal collapse is also done.
2466
+
2467
+ .. versionchanged:: 4.11 Added ``internal option``, algorithm is improved
2468
+ """
2469
+ _grid_etc1.collapse_inactive_cells(self, internal=internal)
2470
+
2471
+ def crop(
2472
+ self,
2473
+ colcrop: tuple[int, int],
2474
+ rowcrop: tuple[int, int],
2475
+ laycrop: tuple[int, int],
2476
+ props: Literal["all"] | list[GridProperty] | None = None,
2477
+ ) -> None:
2478
+ """Reduce the grid size by cropping.
2479
+
2480
+ The new grid will get new dimensions.
2481
+
2482
+ If props is "all" then all properties assosiated (linked) to then
2483
+ grid are also cropped, and the instances are updated.
2484
+
2485
+ Args:
2486
+ colcrop (tuple): A tuple on the form (i1, i2)
2487
+ where 1 represents start number, and 2 represent end. The range
2488
+ is inclusive for both ends, and the number start index is 1 based.
2489
+ rowcrop (tuple): A tuple on the form (j1, j2)
2490
+ laycrop (tuple): A tuple on the form (k1, k2)
2491
+ props (list or str): None is default, while properties can be listed.
2492
+ If "all", then all GridProperty objects which are linked to the
2493
+ Grid instance are updated.
2494
+
2495
+ Returns:
2496
+ The instance is updated (cropped)
2497
+
2498
+ Example::
2499
+
2500
+ >>> import xtgeo
2501
+ >>> mygrid = xtgeo.grid_from_file(reek_dir + "/REEK.EGRID")
2502
+ >>> mygrid.crop((3, 6), (4, 20), (1, 10))
2503
+ >>> mygrid.to_file(outdir + "/gf_reduced.roff")
2504
+
2505
+ """
2506
+ _grid_etc1.crop(self, (colcrop, rowcrop, laycrop), props=props)
2507
+
2508
+ def reduce_to_one_layer(self) -> None:
2509
+ """Reduce the grid to one single layer.
2510
+
2511
+ Example::
2512
+
2513
+ >>> import xtgeo
2514
+ >>> grid = xtgeo.grid_from_file(reek_dir + "/REEK.EGRID")
2515
+ >>> grid.nlay
2516
+ 14
2517
+ >>> grid.reduce_to_one_layer()
2518
+ >>> grid.nlay
2519
+ 1
2520
+
2521
+ """
2522
+ _grid_etc1.reduce_to_one_layer(self)
2523
+
2524
+ def get_onelayer_grid(self) -> Grid:
2525
+ """Return a copy of the grid with only one layer."""
2526
+
2527
+ new_grid_cpp = self._get_grid_cpp().extract_onelayer_grid()
2528
+ return Grid(
2529
+ coordsv=new_grid_cpp.coordsv,
2530
+ zcornsv=new_grid_cpp.zcornsv,
2531
+ actnumsv=new_grid_cpp.actnumsv,
2532
+ )
2533
+
2534
+ def translate_coordinates(
2535
+ self,
2536
+ translate: tuple[float, float, float] = (0.0, 0.0, 0.0),
2537
+ target_coordinates: tuple[float, float, float] | None = None,
2538
+ flip: tuple[int, int, int] = (1, 1, 1),
2539
+ add_rotation: float = 0.0,
2540
+ rotation_point: tuple[float, float] | None = None,
2541
+ ) -> Grid | None:
2542
+ """Translate (move), flip and rotate the 3D grid geometry.
2543
+
2544
+ By 'flip' here, it means that the full coordinate arrays are inverted.
2545
+
2546
+ Args:
2547
+ translate: Translation distance in X, Y, Z coordinates; these
2548
+ values will be added to the current coordinates.
2549
+ target_coordinates: Position for the centerpoint of the active grid cells.
2550
+ Note that key ``translate`` cannot be used with this key; i.e. use
2551
+ either ``translate`` or ``target_coordinates``
2552
+ flip: Flip array. The flip values must be 1 or -1, meaning 1 for
2553
+ keeping the current, and -1 for activating an axis flip.
2554
+ add_rotation: The grid geometry will get an additional rotation by this
2555
+ value, in degrees and counter clock wise.
2556
+ rotation_point: Which (x, y) coordiate to be set as origin when adding
2557
+ rotation. Default is the corner of the first cell number.
2558
+
2559
+ Note:
2560
+ Grid properties attached to the grid will also be transformed
2561
+
2562
+ Example::
2563
+ import xtgeo
2564
+ grd = xtgeo.grid_from_roxar(project, "simpleb8")
2565
+ poro = xtgeo.gridproperty_from_roxar(project, "simpleb8", "PORO")
2566
+ grd.props = [poro]
2567
+
2568
+ grd.translate_coordinates(translate=(10,10, 20), flip=(1,1,-1),
2569
+ add_rotation=30)
2570
+
2571
+ grd.to_roxar(project, "simpleb8_translated")
2572
+ poro1 = grd.get_prop_by_name("PORO")
2573
+ poro1.to_roxar(project, "simpleb8_translated", "PORO")
2574
+
2575
+ """
2576
+ _grid_translate_coords.translate_coordinates(
2577
+ self, translate, flip, add_rotation, rotation_point, target_coordinates
2578
+ )
2579
+
2580
+ def reverse_row_axis(
2581
+ self, ijk_handedness: Literal["left", "right"] | None = None
2582
+ ) -> None:
2583
+ """Reverse the row axis (J indices).
2584
+
2585
+ This means that IJK system will switched between a left vs right handed system.
2586
+ It is here (by using ijk_handedness key), possible to set a wanted handedness.
2587
+
2588
+ Note that properties that are assosiated with the grid (through the
2589
+ :py:attr:`~gridprops` or :py:attr:`~props` attribute) will also be
2590
+ reversed (which is desirable).
2591
+
2592
+ Args:
2593
+ ijk_handedness (str): If set to "right" or "left", do only reverse rows if
2594
+ handedness is not already achieved.
2595
+
2596
+ Example::
2597
+
2598
+ grd = xtgeo.grid_from_file("somefile.roff")
2599
+ prop1 = xtgeo.gridproperty_from_file("somepropfile1.roff")
2600
+ prop2 = xtgeo.gridproperty_from_file("somepropfile2.roff")
2601
+
2602
+ grd.props = [prop1, prop2]
2603
+
2604
+ # secure that the grid geometry is IJK right-handed
2605
+ grd.reverse_row_axis(ijk_handedness="right")
2606
+
2607
+ .. versionadded:: 2.5
2608
+
2609
+ """
2610
+ _grid_etc1.reverse_row_axis(self, ijk_handedness=ijk_handedness)
2611
+
2612
+ def reverse_column_axis(
2613
+ self, ijk_handedness: Literal["left", "right"] | None = None
2614
+ ) -> None:
2615
+ """Reverse the column axis (I indices).
2616
+
2617
+ This means that IJK system will switched between a left vs right handed system.
2618
+ It is here (by using ijk_handedness key), possible to set a wanted handedness.
2619
+
2620
+ Note that properties that are assosiated with the grid (through the
2621
+ :py:attr:`~gridprops` or :py:attr:`~props` attribute) will also be
2622
+ reversed (which is desirable).
2623
+
2624
+ Args:
2625
+ ijk_handedness (str): If set to "right" or "left", do only reverse columns
2626
+ if handedness is not already achieved.
2627
+
2628
+ Example::
2629
+
2630
+ grd = xtgeo.grid_from_file("somefile.roff")
2631
+ prop1 = xtgeo.gridproperty_from_file("somepropfile1.roff")
2632
+ prop2 = xtgeo.gridproperty_from_file("somepropfile2.roff")
2633
+
2634
+ grd.props = [prop1, prop2]
2635
+
2636
+ # secure that the grid geometry is IJK right-handed
2637
+ grd.reverse_column_axis(ijk_handedness="right")
2638
+
2639
+ .. versionadded:: 4.14
2640
+
2641
+ """
2642
+ _grid_etc1.reverse_column_axis(self, ijk_handedness=ijk_handedness)
2643
+
2644
+ def make_zconsistent(self, zsep: float | int = 1e-5) -> None:
2645
+ """Make the 3D grid consistent in Z, by a minimal gap (zsep).
2646
+
2647
+ Args:
2648
+ zsep (float): Minimum gap
2649
+ """
2650
+ _grid_etc1.make_zconsistent(self, zsep)
2651
+
2652
+ def convert_to_hybrid(
2653
+ self,
2654
+ nhdiv: int = 10,
2655
+ toplevel: float = 1000.0,
2656
+ bottomlevel: float = 1100.0,
2657
+ region: GridProperty | None = None,
2658
+ region_number: int | None = None,
2659
+ ) -> None:
2660
+ """Convert to hybrid grid, either globally or in a selected region.
2661
+
2662
+ This function will convert the internal structure in the corner point grid,
2663
+ so that the cells between two levels ``toplevel`` and ``bottomlevel`` become
2664
+ horizontal, which can be useful in flow simulators when e.g. liquid
2665
+ contact movements are dominating. See example on `usage in the Troll field`_.
2666
+
2667
+ Note that the resulting hybrid will have an increased number of layers.
2668
+ If the initial grid has N layers, and the number of horizontal layers
2669
+ is NHDIV, then the result grid will have N * 2 + NHDIV layers.
2670
+
2671
+ .. image:: images/hybridgrid2.jpg
2672
+ :width: 600
2673
+ :align: center
2674
+
2675
+ Args:
2676
+ nhdiv: Number of hybrid layers.
2677
+ toplevel: Top of hybrid grid.
2678
+ bottomlevel: Base of hybrid grid.
2679
+ region: Region property (if needed). Note that the region will only be
2680
+ applied in a lateral sense: i.e. if a column is in the region, then
2681
+ the full column will be converted to hybrid.
2682
+ region_number: Which region to apply hybrid grid in if region.
2683
+
2684
+ Example:
2685
+ Create a hybridgrid from file, based on a GRDECL file (no region)::
2686
+
2687
+ import xtgeo
2688
+ grd = xtgeo.grid_from_file("simgrid.grdecl", fformat="grdecl")
2689
+ grd.convert_to_hybrid(nhdiv=12, toplevel=2200, bottomlevel=2250)
2690
+ # save in binary GRDECL fmt:
2691
+ grd.to_file("simgrid_hybrid.bgrdecl", fformat="bgrdecl")
2692
+
2693
+ See Also:
2694
+ :ref:`hybrid` example.
2695
+
2696
+ .. _usage in the Troll field: https://doi.org/10.2118/148023-MS
2697
+
2698
+ """
2699
+
2700
+ _grid_hybrid.make_hybridgrid(
2701
+ self,
2702
+ nhdiv=nhdiv,
2703
+ toplevel=toplevel,
2704
+ bottomlevel=bottomlevel,
2705
+ region=region,
2706
+ region_number=region_number,
2707
+ )
2708
+
2709
+ def refine(
2710
+ self,
2711
+ refine_col: int | dict[int, int],
2712
+ refine_row: int | dict[int, int],
2713
+ refine_layer: int | dict,
2714
+ zoneprop: GridProperty | None = None,
2715
+ ) -> None:
2716
+ """Refine grid in all direction, proportionally.
2717
+
2718
+ The refine_layer can be a scalar or a dictionary.
2719
+
2720
+ If refine_layer is a dict and zoneprop is None, then the current
2721
+ subgrids array is used. If zoneprop is defined, the
2722
+ current subgrid index will be redefined for the case. A warning will
2723
+ be issued if subgrids are defined, but the give zone
2724
+ property is inconsistent with this.
2725
+
2726
+ Also, if a zoneprop is defined but no current subgrids in the grid,
2727
+ then subgrids will be added to the grid, if more than 1 subgrid.
2728
+
2729
+ Args:
2730
+ self (object): A grid XTGeo object
2731
+ refine_col (scalar or dict): Refinement factor for each column.
2732
+ refine_row (scalar or dict): Refinement factor for each row.
2733
+ refine_layer (scalar or dict): Refinement factor for layer, if dict, then
2734
+ the dictionary must be consistent with self.subgrids if this is
2735
+ present.
2736
+ zoneprop (GridProperty): Zone property; must be defined if refine_layer
2737
+ is a dict
2738
+
2739
+ Returns:
2740
+ ValueError: if..
2741
+ RuntimeError: if mismatch in dimensions for refine_layer and zoneprop
2742
+
2743
+ """
2744
+ _grid_refine.refine(
2745
+ self, refine_col, refine_row, refine_layer, zoneprop=zoneprop
2746
+ )
2747
+ self._tmp = {}
2748
+
2749
+ def refine_vertically(
2750
+ self,
2751
+ rfactor: int | dict,
2752
+ zoneprop: GridProperty | None = None,
2753
+ ) -> None:
2754
+ """Refine vertically, proportionally.
2755
+
2756
+ The rfactor can be a scalar or a dictionary.
2757
+
2758
+ If rfactor is a dict and zoneprop is None, then the current
2759
+ subgrids array is used. If zoneprop is defined, the
2760
+ current subgrid index will be redefined for the case. A warning will
2761
+ be issued if subgrids are defined, but the give zone
2762
+ property is inconsistent with this.
2763
+
2764
+ Also, if a zoneprop is defined but no current subgrids in the grid,
2765
+ then subgrids will be added to the grid, if more than 1 subgrid.
2766
+
2767
+ Args:
2768
+ self (object): A grid XTGeo object
2769
+ rfactor (scalar or dict): Refinement factor, if dict, then the
2770
+ dictionary must be consistent with self.subgrids if this is
2771
+ present.
2772
+ zoneprop (GridProperty): Zone property; must be defined if rfactor
2773
+ is a dict
2774
+
2775
+ Returns:
2776
+ ValueError: if..
2777
+ RuntimeError: if mismatch in dimensions for rfactor and zoneprop
2778
+
2779
+
2780
+ Examples::
2781
+
2782
+ # refine vertically all by factor 3
2783
+
2784
+ grd.refine_vertically(3)
2785
+
2786
+ # refine by using a dictionary; note that subgrids must exist!
2787
+ # and that subgrids that are not mentioned will have value 1
2788
+ # in refinement (1 is meaning no refinement)
2789
+
2790
+ grd.refine_vertically({1: 3, 2: 4, 4: 1})
2791
+
2792
+ # refine by using a a dictionary and a zonelog. If subgrids exists
2793
+ # but are inconsistent with the zonelog; the current subgrids will
2794
+ # be redefined, and a warning will be issued! Note also that ranges
2795
+ # in the dictionary rfactor and the zone property must be aligned.
2796
+
2797
+ grd.refine_vertically({1: 3, 2: 4, 4: 0}, zoneprop=myzone)
2798
+
2799
+ """
2800
+ _grid_refine.refine_vertically(self, rfactor, zoneprop=zoneprop)
2801
+
2802
+ def report_zone_mismatch(
2803
+ self,
2804
+ well: Well | None = None,
2805
+ zonelogname: str = "ZONELOG",
2806
+ zoneprop: GridProperty | None = None,
2807
+ zonelogrange: tuple[int, int] = (0, 9999),
2808
+ zonelogshift: int = 0,
2809
+ depthrange: tuple | None = None,
2810
+ perflogname: str | None = None,
2811
+ perflogrange: tuple[int, int] = (1, 9999),
2812
+ filterlogname: str | None = None,
2813
+ filterlogrange: tuple[float, float] = (1e-32, 9999.0),
2814
+ resultformat: Literal[1, 2] = 1,
2815
+ ) -> tuple | dict | None:
2816
+ """Reports mismatch between wells and a zone.
2817
+
2818
+ Approaches on matching:
2819
+ 1. Use the well zonelog as basis, and compare sampled zone with that
2820
+ interval. This means that zone cells outside well range will not be
2821
+ counted
2822
+ 2. Compare intervals with wellzonation in range or grid zonations in
2823
+ range. This gives a wider comparison, and will capture cases
2824
+ where grid zonations is outside well zonation
2825
+
2826
+ .. image:: images/zone-well-mismatch-plain.svg
2827
+ :width: 200
2828
+ :align: center
2829
+
2830
+ Note if `zonelogname` and/or `filterlogname` and/or `perflogname` is given,
2831
+ and such log(s) are not present, then this function will return ``None``.
2832
+
2833
+ Args:
2834
+ well (Well): a XTGeo well object
2835
+ zonelogname (str): Name of the zone logger
2836
+ zoneprop (GridProperty): Grid property instance to use for
2837
+ zonation
2838
+ zonelogrange (tuple): zone log range, from - to (inclusive)
2839
+ zonelogshift (int): Deviation (numerical shift) between grid and zonelog,
2840
+ e.g. if Zone property starts with 1 and this corresponds to a zonelog
2841
+ index of 3 in the well, the shift shall be -2.
2842
+ depthrange (tuple): Interval for search in TVD depth, to speed up
2843
+ perflogname (str): Name of perforation log to filter on (> 0 default).
2844
+ perflogrange (tuple): Range of values where perforations are present.
2845
+ filterlogname (str): General filter, work as perflog, filter on values > 0
2846
+ filterlogrange (tuple): Range of values where filter shall be present.
2847
+ resultformat (int): If 1, consider the zonelogrange in the well as
2848
+ basis for match ratio, return (percent, match count, total count).
2849
+ If 2 then a dictionary is returned with various result members
2850
+
2851
+ Returns:
2852
+ res (tuple or dict): report dependent on `resultformat`
2853
+ * A tuple with 3 members:
2854
+ (match_as_percent, number of matches, total count) approach 1
2855
+ * A dictionary with keys:
2856
+ * MATCH1 - match as percent, approach 1
2857
+ * MCOUNT1 - number of match samples approach 1
2858
+ * TCOUNT1 - total number of samples approach 1
2859
+ * MATCH2 - match as percent, approach 2
2860
+ * MCOUNT2 - a.a for option 2
2861
+ * TCOUNT2 - a.a. for option 2
2862
+ * WELLINTV - a Well() instance for the actual interval
2863
+ * None, if perflogname or zonelogname of filtername is given, but
2864
+ the log does not exists for the well
2865
+
2866
+ Example::
2867
+
2868
+ g1 = xtgeo.grid_from_file("gullfaks2.roff")
2869
+
2870
+ z = xtgeo.gridproperty_from_file(gullfaks2_zone.roff", name="Zone")
2871
+
2872
+ w2 = xtgeo.well_from_file("34_10-1.w", zonelogname="Zonelog")
2873
+
2874
+ w3 = xtgeo.well_from_file("34_10-B-21_B.w", zonelogname="Zonelog"))
2875
+
2876
+ wells = [w2, w3]
2877
+
2878
+ for w in wells:
2879
+ response = g1.report_zone_mismatch(
2880
+ well=w, zonelogname="ZONELOG", zoneprop=z,
2881
+ zonelogrange=(0, 19), depthrange=(1700, 9999))
2882
+
2883
+ print(response)
2884
+
2885
+ .. versionchanged:: 2.8 Added several new keys and better precision in result
2886
+ .. versionchanged:: 2.11 Added ``perflogrange`` and ``filterlogrange``
2887
+ """
2888
+ return _grid_wellzone.report_zone_mismatch(
2889
+ self,
2890
+ well=well,
2891
+ zonelogname=zonelogname,
2892
+ zoneprop=zoneprop,
2893
+ zonelogrange=zonelogrange,
2894
+ zonelogshift=zonelogshift,
2895
+ depthrange=depthrange,
2896
+ perflogname=perflogname,
2897
+ perflogrange=perflogrange,
2898
+ filterlogname=filterlogname,
2899
+ filterlogrange=filterlogrange,
2900
+ resultformat=resultformat,
2901
+ )
2902
+
2903
+ # ==================================================================================
2904
+ # Extract a fence/randomline by sampling, ready for plotting with e.g. matplotlib
2905
+ # ==================================================================================
2906
+ def get_randomline(
2907
+ self,
2908
+ fencespec: np.ndarray | Polygons,
2909
+ prop: str | GridProperty,
2910
+ zmin: float | None = None,
2911
+ zmax: float | None = None,
2912
+ zincrement: float = 1.0,
2913
+ hincrement: float | None = None,
2914
+ atleast: int = 5,
2915
+ nextend: int = 2,
2916
+ ) -> tuple[float, float, float, float, np.ndarray]:
2917
+ """Get a sampled randomline from a fence spesification.
2918
+
2919
+ This randomline will be a 2D numpy with depth on the vertical
2920
+ axis, and length along as horizontal axis. Undefined values will have
2921
+ the np.nan value.
2922
+
2923
+ The input fencespec is either a 2D numpy where each row is X, Y, Z, HLEN,
2924
+ where X, Y are UTM coordinates, Z is depth/time, and HLEN is a
2925
+ length along the fence, or a Polygons instance.
2926
+
2927
+ If input fencspec is a numpy 2D, it is important that the HLEN array
2928
+ has a constant increment and ideally a sampling that is less than the
2929
+ Grid resolution. If a Polygons() instance, this will be automated if
2930
+ hincrement is None.
2931
+
2932
+ Args:
2933
+ fencespec (:obj:`~numpy.ndarray` or :class:`~xtgeo.xyz.polygons.Polygons`):
2934
+ 2D numpy with X, Y, Z, HLEN as rows or a xtgeo Polygons() object.
2935
+ prop (GridProperty or str): The grid property object, or name, which shall
2936
+ be plotted.
2937
+ zmin (float): Minimum Z (default is Grid Z minima/origin)
2938
+ zmax (float): Maximum Z (default is Grid Z maximum)
2939
+ zincrement (float): Sampling vertically, default is 1.0
2940
+ hincrement (float): Resampling horizontally. This applies only
2941
+ if the fencespec is a Polygons() instance. If None (default),
2942
+ the distance will be deduced automatically.
2943
+ atleast (int): Minimum number of horizontal samples This applies
2944
+ only if the fencespec is a Polygons() instance.
2945
+ nextend (int): Extend with nextend * hincrement in both ends.
2946
+ This applies only if the fencespec is a Polygons() instance.
2947
+
2948
+ Returns:
2949
+ A tuple: (hmin, hmax, vmin, vmax, ndarray2d)
2950
+
2951
+ Raises:
2952
+ ValueError: Input fence is not according to spec.
2953
+
2954
+ Example::
2955
+
2956
+ mygrid = xtgeo.grid_from_file("somegrid.roff")
2957
+ poro = xtgeo.gridproperty_from_file("someporo.roff")
2958
+ mywell = xtgeo.well_from_file("somewell.rmswell")
2959
+ fence = mywell.get_fence_polyline(sampling=5, tvdmin=1750, asnumpy=True)
2960
+ (hmin, hmax, vmin, vmax, arr) = mygrid.get_randomline(
2961
+ fence, poro, zmin=1750, zmax=1850, zincrement=0.5,
2962
+ )
2963
+ # matplotlib ...
2964
+ plt.imshow(arr, cmap="rainbow", extent=(hmin1, hmax1, vmax1, vmin1))
2965
+
2966
+ .. versionadded:: 2.1
2967
+
2968
+ .. seealso::
2969
+ Class :class:`~xtgeo.xyz.polygons.Polygons`
2970
+ The method :meth:`~xtgeo.xyz.polygons.Polygons.get_fence()` which can be
2971
+ used to pregenerate `fencespec`
2972
+
2973
+ """
2974
+ if not isinstance(fencespec, (np.ndarray, xtgeo.Polygons)):
2975
+ raise ValueError("fencespec must be a numpy or a Polygons() object")
2976
+ logger.info("Getting randomline...")
2977
+
2978
+ res = _grid3d_fence.get_randomline(
2979
+ self,
2980
+ fencespec,
2981
+ prop,
2982
+ zmin=zmin,
2983
+ zmax=zmax,
2984
+ zincrement=zincrement,
2985
+ hincrement=hincrement,
2986
+ atleast=atleast,
2987
+ nextend=nextend,
2988
+ )
2989
+ logger.info("Getting randomline... DONE")
2990
+ return res
2991
+
2992
+ # ----------------------------------------------------------------------------------
2993
+ # Special private functions; these may only live for while
2994
+ # ----------------------------------------------------------------------------------
2995
+
2996
+ def _convert_xtgformat2to1(self) -> None:
2997
+ """Convert arrays from new structure xtgformat=2 to legacy xtgformat=1."""
2998
+ _grid_etc1._convert_xtgformat2to1(self)
2999
+
3000
+ def _convert_xtgformat1to2(self) -> None:
3001
+ """Convert arrays from old structure xtgformat=1 to new xtgformat=2."""
3002
+ _grid_etc1._convert_xtgformat1to2(self)
3003
+
3004
+ def _set_xtgformat1(self) -> None:
3005
+ """Shortform... arrays from new structure xtgformat=2 to legacy xtgformat=1."""
3006
+ self._convert_xtgformat2to1()
3007
+
3008
+ def _set_xtgformat2(self) -> None:
3009
+ """Shortform... arrays from old structure xtgformat=1 to new xtgformat=2."""
3010
+ self._convert_xtgformat1to2()