Skip to content

Commit 728fc5f

Browse files
author
Lachlan Grose
committed
fix: unconformities causing nan slicing due to recurvsive error
1 parent bad53a0 commit 728fc5f

File tree

1 file changed

+26
-34
lines changed

1 file changed

+26
-34
lines changed

LoopStructural/modelling/core/geological_model.py

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,29 +1260,6 @@ def _add_unconformity_above(self, feature):
12601260
feature.add_region(lambda pos: f.evaluate(pos))
12611261
break
12621262

1263-
def _add_unconformity_below(self, feature):
1264-
"""
1265-
Adds a region to the features that represents the
1266-
unconformity so it is not evaluated below the unconformity
1267-
1268-
Parameters
1269-
----------
1270-
feature
1271-
1272-
Returns
1273-
-------
1274-
1275-
"""
1276-
# for f in self.features:
1277-
# if f.type == FeatureType.INTERPOLATED and feature.name != f.name:
1278-
# feature.add_region(lambda pos: f.evaluate(pos))
1279-
# for f in reversed(self.features):
1280-
# if f.type == FeatureType.UNCONFORMITY:
1281-
# feature.add_region(lambda pos: f.evaluate(pos))
1282-
# break
1283-
# feature.add_region(lambda pos: ~feature.evaluate(pos))
1284-
pass
1285-
12861263
def create_and_add_unconformity(self, unconformity_surface_data, **kwargs):
12871264
"""
12881265
Parameters
@@ -1321,7 +1298,9 @@ def create_and_add_unconformity(self, unconformity_surface_data, **kwargs):
13211298
# evaluated where the unconformity is positive
13221299
return self.add_unconformity(uc_feature_base, 0)
13231300

1324-
def add_unconformity(self, feature, value):
1301+
def add_unconformity(
1302+
self, feature: GeologicalFeature, value: float
1303+
) -> UnconformityFeature:
13251304
"""
13261305
Use an existing feature to add an unconformity to the model.
13271306
@@ -1338,22 +1317,27 @@ def add_unconformity(self, feature, value):
13381317
unconformity feature
13391318
13401319
"""
1320+
logger.debug(f"Adding {feature.name} as unconformity at {value}")
13411321
if feature is None:
13421322
logger.warning(f"Cannot add unconformtiy, base feature is None")
13431323
return
1324+
# look backwards through features and add the unconformity as a region until
1325+
# we get to an unconformity
13441326
uc_feature = UnconformityFeature(feature, value)
13451327

1346-
for f in self.features:
1328+
for f in reversed(self.features):
1329+
if f.type == FeatureType.UNCONFORMITY:
1330+
logger.debug(f"Reached unconformity {f.name}")
1331+
break
1332+
logger.debug(f"Adding {uc_feature.name} as unconformity to {f.name}")
13471333
f.add_region(lambda pos: ~uc_feature.evaluate(pos))
1348-
# feature.add_region(lambda pos: ~uc_feature.evaluate(pos))
1349-
# see if any unconformities are above this feature if so add region
1350-
# self._add_unconformity_above(uc_feature)
1351-
# self._add_unconformity_below(uc_feature) # , uc_feature)
1334+
# now add the unconformity to the feature list
13521335
self._add_feature(uc_feature)
1353-
13541336
return uc_feature
13551337

1356-
def add_onlap_unconformity(self, feature, value):
1338+
def add_onlap_unconformity(
1339+
self, feature: GeologicalFeature, value: float
1340+
) -> GeologicalFeature:
13571341
"""
13581342
Use an existing feature to add an unconformity to the model.
13591343
@@ -1371,14 +1355,19 @@ def add_onlap_unconformity(self, feature, value):
13711355
13721356
"""
13731357

1374-
uc_feature = UnconformityFeature(feature, value)
1375-
1358+
uc_feature = UnconformityFeature(feature, value, True)
1359+
feature.add_region(lambda pos: ~uc_feature.evaluate(pos))
1360+
for f in reversed(self.features):
1361+
if f.type == FeatureType.UNCONFORMITY:
1362+
break
1363+
if f != feature:
1364+
f.add_region(lambda pos: uc_feature.evaluate(pos))
13761365
# for f in self.features:
13771366
# f.add_region(lambda pos: uc_feature.evaluate(pos))
13781367

13791368
# see if any unconformities are above this feature if so add region
13801369
# self._add_unconformity_above(uc_feature)
1381-
self._add_unconformity_below(uc_feature) # , uc_feature)
1370+
# self._add_unconformity_below(uc_feature) # , uc_feature)
13821371
self._add_feature(uc_feature)
13831372

13841373
return uc_feature
@@ -1901,12 +1890,15 @@ def update(self, verbose=False, progressbar=True):
19011890
if f.type == FeatureType.FAULT:
19021891
nfeatures += 3
19031892
total_dof += f[0].interpolator.nx * 3
1893+
continue
19041894
if isinstance(f, StructuralFrame):
19051895
nfeatures += 3
19061896
total_dof += f[0].interpolator.nx * 3
1897+
continue
19071898
if f.type == FeatureType.INTERPOLATED:
19081899
nfeatures += 1
19091900
total_dof += f.interpolator.nx
1901+
continue
19101902
if verbose == True:
19111903
print(
19121904
f"Updating geological model. There are: \n {nfeatures} geological features that need to be interpolated\n"

0 commit comments

Comments
 (0)