resqpy 5.1.5__py3-none-any.whl → 5.1.6__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
resqpy/__init__.py CHANGED
@@ -28,6 +28,6 @@
28
28
 
29
29
  import logging
30
30
 
31
- __version__ = "5.1.5" # Set at build time
31
+ __version__ = "5.1.6" # Set at build time
32
32
  log = logging.getLogger(__name__)
33
33
  log.info(f"Imported resqpy version {__version__}")
@@ -445,7 +445,12 @@ def extract_stratigraphy(grid):
445
445
  object = grid,
446
446
  array_attribute = 'stratigraphic_units',
447
447
  dtype = 'int')
448
- assert len(grid.stratigraphic_units) == grid.nk_plus_k_gaps
448
+ if (len(grid.stratigraphic_units) != grid.nk_plus_k_gaps):
449
+ log.error("Unable to load Stratigraphy," +
450
+ f" the number of stratigraphic units {len(grid.stratigraphic_units)}" +
451
+ f" does not equal the number of layers plus gaps {grid.nk_plus_k_gaps}")
452
+ grid.stratigraphic_column_rank_uuid = None
453
+ grid.stratigraphic_units = None
449
454
 
450
455
 
451
456
  def extract_children(grid):
@@ -1167,68 +1167,6 @@ def find_faces_to_represent_surface_regular_optimised(grid,
1167
1167
  else:
1168
1168
  return None
1169
1169
 
1170
- log.debug("converting face sets into grid connection set")
1171
- # NB: kji0 arrays in internal face protocol: used as cell_kji0 with polarity of 1
1172
- # property lists have elements replaced with sorted and filtered equivalents
1173
- gcs = rqf.GridConnectionSet.from_faces_indices(grid = grid,
1174
- k_faces_kji0 = k_faces_kji0,
1175
- j_faces_kji0 = j_faces_kji0,
1176
- i_faces_kji0 = i_faces_kji0,
1177
- remove_duplicates = not patchwork,
1178
- k_properties = k_props,
1179
- j_properties = j_props,
1180
- i_properties = i_props,
1181
- feature_name = name,
1182
- feature_type = feature_type,
1183
- create_organizing_objects_where_needed = True,
1184
- title = title)
1185
- # log.debug('finished coversion to gcs')
1186
-
1187
- # NB. following assumes faces have been added to gcs in a particular order!
1188
- all_tris = None
1189
- if return_triangles:
1190
- # log.debug('preparing triangles array')
1191
- k_triangles = np.empty((0,), dtype = np.int32) if k_props is None else k_props.pop(0)
1192
- j_triangles = np.empty((0,), dtype = np.int32) if j_props is None else j_props.pop(0)
1193
- i_triangles = np.empty((0,), dtype = np.int32) if i_props is None else i_props.pop(0)
1194
- all_tris = np.concatenate((k_triangles, j_triangles, i_triangles), axis = 0)
1195
- # log.debug(f'gcs count: {gcs.count}; all triangles shape: {all_tris.shape}')
1196
- assert all_tris.shape == (gcs.count,)
1197
-
1198
- # NB. following assumes faces have been added to gcs in a particular order!
1199
- all_depths = None
1200
- if return_depths:
1201
- # log.debug('preparing depths array')
1202
- k_depths = np.empty((0,), dtype = np.float64) if k_props is None else k_props.pop(0)
1203
- j_depths = np.empty((0,), dtype = np.float64) if j_props is None else j_props.pop(0)
1204
- i_depths = np.empty((0,), dtype = np.float64) if i_props is None else i_props.pop(0)
1205
- all_depths = np.concatenate((k_depths, j_depths, i_depths), axis = 0)
1206
- # log.debug(f'gcs count: {gcs.count}; all depths shape: {all_depths.shape}')
1207
- assert all_depths.shape == (gcs.count,)
1208
-
1209
- # NB. following assumes faces have been added to gcs in a particular order!
1210
- all_offsets = None
1211
- if return_offsets:
1212
- # log.debug('preparing offsets array')
1213
- k_offsets = np.empty((0,), dtype = np.float64) if k_props is None else k_props[0]
1214
- j_offsets = np.empty((0,), dtype = np.float64) if j_props is None else j_props[0]
1215
- i_offsets = np.empty((0,), dtype = np.float64) if i_props is None else i_props[0]
1216
- all_offsets = _all_offsets(grid.crs, k_offsets, j_offsets, i_offsets)
1217
- # log.debug(f'gcs count: {gcs.count}; all offsets shape: {all_offsets.shape}')
1218
- assert all_offsets.shape == (gcs.count,)
1219
-
1220
- all_flange = None
1221
- if return_flange_bool:
1222
- # log.debug('preparing flange array')
1223
- flange_bool_uuid = surface.model.uuid(title = "flange bool",
1224
- obj_type = "DiscreteProperty",
1225
- related_uuid = surface.uuid)
1226
- assert (flange_bool_uuid is not None), f"No flange bool property found for surface: {surface.title}"
1227
- flange_bool = rqp.Property(surface.model, uuid = flange_bool_uuid)
1228
- flange_array = flange_bool.array_ref(dtype = bool)
1229
- all_flange = np.take(flange_array, all_tris)
1230
- assert all_flange.shape == (gcs.count,)
1231
-
1232
1170
  # note: following is a grid cells property, not a gcs property
1233
1171
  bisector = None
1234
1172
  if return_bisector:
@@ -1245,6 +1183,15 @@ def find_faces_to_represent_surface_regular_optimised(grid,
1245
1183
  bisector = column_bisector_from_face_indices((grid.nj, grid.ni), j_faces_ji0, i_faces_ji0)
1246
1184
  # log.debug('finished preparing columns bisector')
1247
1185
  elif patchwork:
1186
+ # NB. following assumes faces have been added to gcs in a particular order!
1187
+ all_tris = None
1188
+ assert return_triangles
1189
+ # log.debug('preparing triangles array')
1190
+ k_triangles = np.empty((0,), dtype = np.int32) if k_props is None else k_props[0]
1191
+ j_triangles = np.empty((0,), dtype = np.int32) if j_props is None else j_props[0]
1192
+ i_triangles = np.empty((0,), dtype = np.int32) if i_props is None else i_props[0]
1193
+ all_tris = np.concatenate((k_triangles, j_triangles, i_triangles), axis = 0)
1194
+ # log.debug(f'gcs count: {gcs.count}; all triangles shape: {all_tris.shape}')
1248
1195
  n_patches = surface.number_of_patches()
1249
1196
  log.info(f'preparing composite cells bisector for surface: {surface.title}; number of patches: {n_patches}')
1250
1197
  nkf = 0 if k_faces_kji0 is None else len(k_faces_kji0)
@@ -1328,6 +1275,98 @@ def find_faces_to_represent_surface_regular_optimised(grid,
1328
1275
  if is_curtain:
1329
1276
  bisector = bisector[0] # reduce to a columns property
1330
1277
 
1278
+ # if using patchwork, filter all faces (and properties) to those within (or on boundary of) volume corresponding to patch
1279
+ if patchwork:
1280
+ if k_faces_kji0 is not None:
1281
+ selection = filter_faces(k_faces_kji0, patch_indices_k, patch_indices, 0)
1282
+ if np.any(selection):
1283
+ k_faces_kji0 = k_faces_kji0[selection]
1284
+ if k_props is not None:
1285
+ k_props = [prop[selection] for prop in k_props]
1286
+ else:
1287
+ k_faces_kji0 = None
1288
+ k_props = None
1289
+ if j_faces_kji0 is not None:
1290
+ selection = filter_faces(j_faces_kji0, patch_indices_j, patch_indices, 1)
1291
+ if np.any(selection):
1292
+ j_faces_kji0 = j_faces_kji0[selection]
1293
+ if j_props is not None:
1294
+ j_props = [prop[selection] for prop in j_props]
1295
+ else:
1296
+ j_faces_kji0 = None
1297
+ j_props = None
1298
+ if i_faces_kji0 is not None:
1299
+ selection = filter_faces(i_faces_kji0, patch_indices_i, patch_indices, 2)
1300
+ if np.any(selection):
1301
+ i_faces_kji0 = i_faces_kji0[selection]
1302
+ if i_props is not None:
1303
+ i_props = [prop[selection] for prop in i_props]
1304
+ else:
1305
+ i_faces_kji0 = None
1306
+ i_props = None
1307
+
1308
+ log.debug("converting face sets into grid connection set")
1309
+ # NB: kji0 arrays in internal face protocol: used as cell_kji0 with polarity of 1
1310
+ # property lists have elements replaced with sorted and filtered equivalents
1311
+ gcs = rqf.GridConnectionSet.from_faces_indices(grid = grid,
1312
+ k_faces_kji0 = k_faces_kji0,
1313
+ j_faces_kji0 = j_faces_kji0,
1314
+ i_faces_kji0 = i_faces_kji0,
1315
+ remove_duplicates = not patchwork,
1316
+ k_properties = k_props,
1317
+ j_properties = j_props,
1318
+ i_properties = i_props,
1319
+ feature_name = name,
1320
+ feature_type = feature_type,
1321
+ create_organizing_objects_where_needed = True,
1322
+ title = title)
1323
+ # log.debug('finished coversion to gcs')
1324
+
1325
+ # NB. following assumes faces have been added to gcs in a particular order!
1326
+ all_tris = None
1327
+ if return_triangles:
1328
+ # log.debug('preparing triangles array')
1329
+ k_triangles = np.empty((0,), dtype = np.int32) if k_props is None else k_props.pop(0)
1330
+ j_triangles = np.empty((0,), dtype = np.int32) if j_props is None else j_props.pop(0)
1331
+ i_triangles = np.empty((0,), dtype = np.int32) if i_props is None else i_props.pop(0)
1332
+ all_tris = np.concatenate((k_triangles, j_triangles, i_triangles), axis = 0)
1333
+ # log.debug(f'gcs count: {gcs.count}; all triangles shape: {all_tris.shape}')
1334
+ assert all_tris.shape == (gcs.count,)
1335
+
1336
+ # NB. following assumes faces have been added to gcs in a particular order!
1337
+ all_depths = None
1338
+ if return_depths:
1339
+ # log.debug('preparing depths array')
1340
+ k_depths = np.empty((0,), dtype = np.float64) if k_props is None else k_props.pop(0)
1341
+ j_depths = np.empty((0,), dtype = np.float64) if j_props is None else j_props.pop(0)
1342
+ i_depths = np.empty((0,), dtype = np.float64) if i_props is None else i_props.pop(0)
1343
+ all_depths = np.concatenate((k_depths, j_depths, i_depths), axis = 0)
1344
+ # log.debug(f'gcs count: {gcs.count}; all depths shape: {all_depths.shape}')
1345
+ assert all_depths.shape == (gcs.count,)
1346
+
1347
+ # NB. following assumes faces have been added to gcs in a particular order!
1348
+ all_offsets = None
1349
+ if return_offsets:
1350
+ # log.debug('preparing offsets array')
1351
+ k_offsets = np.empty((0,), dtype = np.float64) if k_props is None else k_props[0]
1352
+ j_offsets = np.empty((0,), dtype = np.float64) if j_props is None else j_props[0]
1353
+ i_offsets = np.empty((0,), dtype = np.float64) if i_props is None else i_props[0]
1354
+ all_offsets = _all_offsets(grid.crs, k_offsets, j_offsets, i_offsets)
1355
+ # log.debug(f'gcs count: {gcs.count}; all offsets shape: {all_offsets.shape}')
1356
+ assert all_offsets.shape == (gcs.count,)
1357
+
1358
+ all_flange = None
1359
+ if return_flange_bool:
1360
+ # log.debug('preparing flange array')
1361
+ flange_bool_uuid = surface.model.uuid(title = "flange bool",
1362
+ obj_type = "DiscreteProperty",
1363
+ related_uuid = surface.uuid)
1364
+ assert (flange_bool_uuid is not None), f"No flange bool property found for surface: {surface.title}"
1365
+ flange_bool = rqp.Property(surface.model, uuid = flange_bool_uuid)
1366
+ flange_array = flange_bool.array_ref(dtype = bool)
1367
+ all_flange = np.take(flange_array, all_tris)
1368
+ assert all_flange.shape == (gcs.count,)
1369
+
1331
1370
  # note: following is a grid cells property, not a gcs property
1332
1371
  shadow = None
1333
1372
  if return_shadow:
@@ -2475,7 +2514,7 @@ def _bitwise_count_njit(a: np.ndarray) -> np.int64:
2475
2514
  return c
2476
2515
 
2477
2516
 
2478
- @njit
2517
+ @njit # pragma: no cover
2479
2518
  def box_intersection(box_a: np.ndarray, box_b: np.ndarray) -> np.ndarray:
2480
2519
  """Return a box which is the intersection of two boxes, python protocol; all zeros if no intersection."""
2481
2520
  box = np.zeros((2, 3), dtype = np.int32)
@@ -2486,8 +2525,8 @@ def box_intersection(box_a: np.ndarray, box_b: np.ndarray) -> np.ndarray:
2486
2525
  return box
2487
2526
 
2488
2527
 
2489
- @njit
2490
- def get_box(mask: np.ndarray) -> Tuple[np.ndarray, int]: # pragma: no cover
2528
+ @njit # pragma: no cover
2529
+ def get_box(mask: np.ndarray) -> Tuple[np.ndarray, int]:
2491
2530
  """Returns a python protocol box enclosing True elements of 3D boolean mask, and count which is zero if all False."""
2492
2531
  box = np.full((2, 3), -1, dtype = np.int32)
2493
2532
  count = 0
@@ -2517,3 +2556,28 @@ def get_box(mask: np.ndarray) -> Tuple[np.ndarray, int]: # pragma: no cover
2517
2556
  box[1, 2] = i + 1
2518
2557
  count += 1
2519
2558
  return box, count
2559
+
2560
+
2561
+ @njit # pragma: no cover
2562
+ def filter_faces(faces_kji0: np.ndarray, face_patches: np.ndarray, cell_patches: np.ndarray, axis: int) -> np.ndarray:
2563
+ """Return 1D boolean selection array indicating subset of faces that are applicable to cells with matching patch."""
2564
+ n: int = len(faces_kji0)
2565
+ assert len(face_patches) == n
2566
+ selection = np.zeros(n, dtype = np.bool_)
2567
+ for f in range(n):
2568
+ k: int = faces_kji0[f, 0]
2569
+ j: int = faces_kji0[f, 1]
2570
+ i: int = faces_kji0[f, 2]
2571
+ if face_patches[f] == cell_patches[k, j, i]:
2572
+ selection[f] = True
2573
+ else:
2574
+ if axis == 0:
2575
+ if face_patches[f] == cell_patches[k + 1, j, i]:
2576
+ selection[f] = True
2577
+ elif axis == 1:
2578
+ if face_patches[f] == cell_patches[k, j + 1, i]:
2579
+ selection[f] = True
2580
+ else:
2581
+ if face_patches[f] == cell_patches[k, j, i + 1]:
2582
+ selection[f] = True
2583
+ return selection
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: resqpy
3
- Version: 5.1.5
3
+ Version: 5.1.6
4
4
  Summary: Python API for working with RESQML models
5
5
  License: MIT
6
6
  Keywords: RESQML
@@ -1,4 +1,4 @@
1
- resqpy/__init__.py,sha256=9OUOfmvTwC90nqrnAXAqmHSuL_COKkd2jhWcHGcMyLs,555
1
+ resqpy/__init__.py,sha256=cnR7ZBD-Sv8zdt5JWWw7n0iqZIaIhsYS7akdPjFzG10,555
2
2
  resqpy/crs.py,sha256=R7DfcTP5xGv5pu9Y8RHA2WVM9DjBCSVMoHcz4RmQ7Yw,27646
3
3
  resqpy/derived_model/__init__.py,sha256=NFvMSOKI3cxmH7lAbddV43JjoUj-r2G7ExEfOqinD1I,1982
4
4
  resqpy/derived_model/_add_edges_per_column_property_array.py,sha256=cpW3gwp6MSYIrtvFmCjoJXcyUsgGuCDbgmwlJCJebUs,6410
@@ -31,7 +31,7 @@ resqpy/grid/_cell_properties.py,sha256=pbyAK2eV9n4teOxm2q5hyBinohEbevFPrCfMcpGiq
31
31
  resqpy/grid/_connection_sets.py,sha256=-277bh9pMoeESSzy9oZehL-vc82aMGZuSLQs2KJ4Wfg,10120
32
32
  resqpy/grid/_create_grid_xml.py,sha256=p-jKo1BZ-DlhEYixVzadtY-QsqA8ygcXvMYS_TvQCjg,22837
33
33
  resqpy/grid/_defined_geometry.py,sha256=QYQ3wLbPrlPobgUi9R1izTD4JD9qMGf5eyqbM68Hg-0,32297
34
- resqpy/grid/_extract_functions.py,sha256=pOVC2vv4dJ9G7e6p3uh2mz4QPb6W7_pKiaq8HAWeyzg,28263
34
+ resqpy/grid/_extract_functions.py,sha256=zfB8rLnt1qdz627BOiM4igXQKbCnsM8fV0HMbnLusTk,28585
35
35
  resqpy/grid/_face_functions.py,sha256=0I7O6DDz7nJWczi_G2bE3L2XUr4acxREwKygXWEp6F4,16516
36
36
  resqpy/grid/_faults.py,sha256=OmukVoLpdrndqDxwE6Rj7Ul5tj3FUQVPhE0raH2FHpg,12236
37
37
  resqpy/grid/_grid.py,sha256=-OhJpi9x8r74_7_CBrQsanqhFiZQcCiJkvbnhPRq2qQ,135758
@@ -47,7 +47,7 @@ resqpy/grid/_write_nexus_corp.py,sha256=yEVfiObsedEAXX6UG6ZTf56kZnQVkd3lLqE2NpL-
47
47
  resqpy/grid/_xyz.py,sha256=RLQWOdM_DRoCj4JypwB5gUJ78HTdk5JnZHSeAzuU634,13087
48
48
  resqpy/grid_surface/__init__.py,sha256=zSbyDwUH_p0UXd9PAcAXvcS1wrmRVnZvXXa1zQSQBlY,2925
49
49
  resqpy/grid_surface/_blocked_well_populate.py,sha256=Lme1AR-nLWOUlNnmHMVThk6jEg_lAZxWWtL82Yksppw,35867
50
- resqpy/grid_surface/_find_faces.py,sha256=cvxtMaHM5NENdMFdyeHzMEr_WOLWxh1YeVEtaLAla1Q,117517
50
+ resqpy/grid_surface/_find_faces.py,sha256=sBzy9mWQZNU41kE5v3taVNDKnqzTcvnOT2FVAXABP0c,120573
51
51
  resqpy/grid_surface/_grid_skin.py,sha256=D0cjHkcuT5KCKb-8EZfXgh0GgJj3kzOBS2wVNXg4bfY,26056
52
52
  resqpy/grid_surface/_grid_surface.py,sha256=l2NJo7Kiucolbb_TlLPC7NGdksg_JahkihfsrJVq99w,14379
53
53
  resqpy/grid_surface/_trajectory_intersects.py,sha256=Och9cZYU9Y7ofovhPzsLyIblRUl2xj9_5nHH3fMZp-A,22498
@@ -193,7 +193,7 @@ resqpy/well/_wellbore_marker_frame.py,sha256=xvYH2_2Ie3a18LReFymbUrZboOx7Rhv5DOD
193
193
  resqpy/well/blocked_well_frame.py,sha256=Rx8jwkCjchseDZaTttPkA1-f6l7W6vRGrxWtDHlEPx8,22560
194
194
  resqpy/well/well_object_funcs.py,sha256=1O4EVPuTn-kN3uT_V4TbSwehnMUMY0TX36XOUgasTcc,24689
195
195
  resqpy/well/well_utils.py,sha256=-g_pg2v5XD9g4SQz9sk7KK-x2xEQZHzWehCQqiEGo6M,7627
196
- resqpy-5.1.5.dist-info/LICENSE,sha256=2duHPIkKQyESMdQ4hKjL8CYEsYRHXaYxt0YQkzsUYE4,1059
197
- resqpy-5.1.5.dist-info/METADATA,sha256=q-3olpPpXHhKu34E49vbo7WTdmBh9MmDgfsvWHZcDBw,3986
198
- resqpy-5.1.5.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
199
- resqpy-5.1.5.dist-info/RECORD,,
196
+ resqpy-5.1.6.dist-info/LICENSE,sha256=2duHPIkKQyESMdQ4hKjL8CYEsYRHXaYxt0YQkzsUYE4,1059
197
+ resqpy-5.1.6.dist-info/METADATA,sha256=ixIzugCD9ZynPEJP_6VZiiUrn042oJmOx8HoilUgePw,3986
198
+ resqpy-5.1.6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
199
+ resqpy-5.1.6.dist-info/RECORD,,
File without changes