Skip to content

Commit 47b88b8

Browse files
committed
- [DOC/WIP] Adapting code to new solution data class
1 parent 36d0b64 commit 47b88b8

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

gempy_plugins/topology_analysis/topology.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,40 @@
1515
along with gempy. If not, see <http://www.gnu.org/licenses/>.
1616
1717
18-
@author: Alexander Schaaf
18+
@author: Alexander Schaaf and Miguel de la Varga
1919
"""
20+
import gempy as gp
2021
import numpy as np
2122
from typing import List, Set, Tuple, Dict, Union, Optional
2223
import matplotlib.pyplot as plt
2324

2425

2526
def _get_nunconf(geo_model) -> int:
26-
return np.count_nonzero(
27-
geo_model._stack.df.BottomRelation == "Erosion"
28-
) - 2 # TODO -2 n other lith series
27+
return np.count_nonzero( geo_model._stack.df.BottomRelation == "Erosion" ) - 2 # TODO -2 n other lith series
2928

3029

3130
def _get_nfaults(geo_model) -> int:
3231
return np.count_nonzero(geo_model._faults.df.isFault)
3332

3433

35-
def _get_fb(geo_model) -> np.ndarray:
36-
n_unconf = _get_nunconf(geo_model)
37-
n_faults = _get_nfaults(geo_model)
38-
return np.round(
39-
geo_model.solutions.block_matrix[n_unconf:n_faults + n_unconf, 0, :]
40-
).astype(int).sum(axis=0).reshape(*geo_model._grid.regular_grid.resolution)
34+
def _get_fault_blocks(geo_model: gp.data.GeoModel) -> np.ndarray:
35+
# n_unconf = _get_nunconf(geo_model)
36+
# n_faults = _get_nfaults(geo_model)
4137

38+
fault_blocks = geo_model.solutions.raw_arrays.block_matrix[geo_model.structural_frame.group_is_fault]
39+
resolution = geo_model.solutions.octrees_output[-1].grid_centers.regular_grid.resolution
4240

43-
def _get_lb(geo_model) -> np.ndarray:
44-
return np.round(
45-
geo_model.solutions.lith_block
46-
).astype(int).reshape(*geo_model._grid.regular_grid.resolution)
41+
int__sum_axis__reshape = np.round(fault_blocks).astype(int).sum(axis=0).reshape(*resolution)
42+
return int__sum_axis__reshape
43+
44+
45+
def _get_lith_blocks(geo_model: gp.data.GeoModel) -> np.ndarray:
46+
47+
lith_blocks = geo_model.solutions.raw_arrays.block_matrix[[not x for x in geo_model.structural_frame.group_is_fault]]
48+
resolution = geo_model.solutions.octrees_output[-1].grid_centers.regular_grid.resolution
49+
50+
int__sum_axis__reshape = np.round(lith_blocks).astype(int).sum(axis=0).reshape(*resolution)
51+
return int__sum_axis__reshape
4752

4853

4954
def compute_topology(
@@ -65,9 +70,9 @@ def compute_topology(
6570
Returns:
6671
edges, centroids [numpy array]: edges and centroids of the topology graph
6772
"""
68-
res = geo_model._grid.regular_grid.resolution
69-
fb = _get_fb(geo_model)
70-
lb = _get_lb(geo_model)
73+
res = geo_model.grid.regular_grid.resolution
74+
fb = _get_fault_blocks(geo_model)
75+
lb = _get_lith_blocks(geo_model)
7176
n_lith = len(np.unique(lb)) # ? quicker looking it up in geomodel?
7277

7378
if cell_number is None or direction is None:
@@ -431,8 +436,7 @@ def _get_centroids(labels: np.ndarray) -> dict:
431436
labels (Array[int, ..., ..., ...]): Uniquely labeled block.
432437
433438
Returns:
434-
dict: Geobody node keys yield centroid coordinate tuples in array
435-
coordinates.
439+
dict: Geobody node keys yield centroid coordinate tuples in array coordinates.
436440
"""
437441
node_locs = []
438442
ulabels = np.unique(labels)

0 commit comments

Comments
 (0)