Skip to content

Commit

Permalink
Merge pull request #167 from AngRodrigues/master
Browse files Browse the repository at this point in the history
adding option in the fold builder to invert the fold norm
  • Loading branch information
lachlangrose authored Jan 29, 2024
2 parents 0c5f59d + 87cd782 commit c3a7221
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion LoopStructural/modelling/core/geological_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ def create_and_add_folded_foliation(
fold_frame=None,
svario=True,
tol=None,
invert_fold_norm = False,
**kwargs,
):
"""
Expand Down Expand Up @@ -859,7 +860,9 @@ def create_and_add_folded_foliation(
logger.info("Using last feature as fold frame")
fold_frame = self.features[-1]
assert type(fold_frame) == FoldFrame, "Please specify a FoldFrame"
fold = FoldEvent(fold_frame, name=f"Fold_{foliation_data}")

fold = FoldEvent(fold_frame, name=f"Fold_{foliation_data}", invert_norm=invert_fold_norm)

if "fold_weights" not in kwargs:
kwargs["fold_weights"] = {}
if interpolatortype != "DFI":
Expand Down
18 changes: 15 additions & 3 deletions LoopStructural/modelling/features/fold/_fold.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(
fold_axis_rotation=None,
fold_limb_rotation=None,
fold_axis=None,
invert_norm = False,
name="Fold",
):
"""
Expand All @@ -33,6 +34,7 @@ def __init__(
self.fold_axis_rotation = fold_axis_rotation
self.fold_limb_rotation = fold_limb_rotation
self.fold_axis = fold_axis
self.invert_norm = invert_norm
self.name = name

def get_fold_axis_orientation(self, points):
Expand Down Expand Up @@ -99,17 +101,27 @@ def get_deformed_orientation(self, points):
dgz = np.zeros_like(dgx)
dgz[:] = np.nan
dgz[mask, :] = np.cross(dgx[mask, :], fold_axis[mask, :], axisa=1, axisb=1)

# dgz = self.foldframe.features[2].evaluate_gradient(points)
dgz[mask, :] /= np.linalg.norm(dgz[mask, :], axis=1)[:, None]

R2 = self.rot_mat(fold_axis, self.fold_limb_rotation(gx))
fold_direction = np.einsum("ijk,ki->kj", R2, dgx)
fold_direction /= np.sum(fold_direction, axis=1)[:, None]
# calculate dot product between fold_direction and axis
# if its less than 0 then inverse dgz
d = np.einsum("ij,ik->i", fold_direction, fold_axis)
dgz[mask][d[mask] < 0] = -dgz[mask][d[mask] < 0]
return fold_direction, fold_axis, dgz

if self.invert_norm == True:
new_dgz = -dgz[mask][d[mask] <0]
return fold_direction, fold_axis, new_dgz

elif self.invert_norm == False:
return fold_direction, fold_axis, dgz
else:
logger.warning("invert fold frame param not valid. Defaulting to false.")
return fold_direction, fold_axis, dgz

# return fold_direction, fold_axis, dgz

# def get_regularisation_direction(self, points):
# self.foldframe.features[2].evaluate_gradient(points)
Expand Down

0 comments on commit c3a7221

Please sign in to comment.