Skip to content

Commit

Permalink
fix: basal unconformities cropping lowest surface
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Aug 1, 2022
1 parent 6ebdf84 commit 5c47ef6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
15 changes: 9 additions & 6 deletions LoopStructural/modelling/core/geological_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def __init__(
reuse_supports=False,
logfile=None,
loglevel="info",
epsilon=0.04,
):
"""
Parameters
Expand All @@ -125,7 +126,8 @@ def __init__(
specifying the maximum extent of the model
rescale : bool
whether to rescale the model to between 0/1
epsion : float
a fudge factor for isosurfacing, used to make sure surfaces appear
Examples
--------
Demo data
Expand Down Expand Up @@ -184,6 +186,7 @@ def __init__(
)

self.bounding_box /= self.scale_factor
self.epsilon = epsilon * float(np.max(lengths)) / self.scale_factor
self.support = {}
self.reuse_supports = reuse_supports
if self.reuse_supports:
Expand Down Expand Up @@ -1252,7 +1255,7 @@ def _add_unconformity_above(self, feature):

for f in reversed(self.features):
if f.type == FeatureType.UNCONFORMITY and f.name != feature.name:
feature.add_region(lambda pos: f.evaluate(pos))
feature.add_region(f)
break

def create_and_add_unconformity(self, unconformity_surface_data, **kwargs):
Expand Down Expand Up @@ -1327,7 +1330,7 @@ def add_unconformity(
logger.debug(f"Adding {uc_feature.name} as unconformity to {f.name}")
if f.type == FeatureType.FAULT:
continue
f.add_region(lambda pos: ~uc_feature.evaluate(pos))
f.add_region(uc_feature.inverse())
# now add the unconformity to the feature list
self._add_feature(uc_feature)
return uc_feature
Expand All @@ -1353,12 +1356,12 @@ def add_onlap_unconformity(
"""

uc_feature = UnconformityFeature(feature, value, True)
feature.add_region(lambda pos: ~uc_feature.evaluate(pos))
feature.add_region(uc_feature.inverse())
for f in reversed(self.features):
if f.type == FeatureType.UNCONFORMITY:
break
if f != feature:
f.add_region(lambda pos: uc_feature.evaluate(pos))
f.add_region(uc_feature)
self._add_feature(uc_feature)

return uc_feature
Expand Down Expand Up @@ -1593,7 +1596,7 @@ def create_and_add_fault(

for f in reversed(self.features):
if f.type == FeatureType.UNCONFORMITY:
fault.add_region(lambda pos: f.evaluate_value(pos) <= 0)
fault.add_region(f)
break
if displacement == 0:
fault.type = "fault_inactive"
Expand Down
18 changes: 14 additions & 4 deletions LoopStructural/modelling/features/_unconformity_feature.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from LoopStructural.modelling.features import GeologicalFeature
from LoopStructural.modelling.features import FeatureType

import numpy as np


class UnconformityFeature(GeologicalFeature):
""" """
Expand Down Expand Up @@ -28,7 +30,12 @@ def __init__(self, feature: GeologicalFeature, value: float, sign=True):
self.type = FeatureType.UNCONFORMITY
self.sign = sign

def evaluate(self, pos):
def inverse(self):
uc = UnconformityFeature(self, self.value, sign=not self.sign)
uc.name = self.name + "_inverse"
return uc

def evaluate(self, pos: np.ndarray) -> np.ndarray:
"""
Parameters
Expand All @@ -38,10 +45,13 @@ def evaluate(self, pos):
Returns
-------
boolean
np.ndarray.dtype(bool)
true if above the unconformity, false if below
"""
if self.sign:
return self.evaluate_value(pos) < self.value
return self.evaluate_value(pos) < self.value + self.model.epsilon
if not self.sign:
return self.evaluate_value(pos) > self.value
return self.evaluate_value(pos) > self.value - self.model.epsilon

def __call__(self, pos) -> np.ndarray:
return self.evaluate(pos)

0 comments on commit 5c47ef6

Please sign in to comment.