Skip to content

Commit ffdb3b4

Browse files
lachlangroseclaude
andcommitted
fix(features): keep restored points finite on a younger fault, clip arccos, document fault_pitch
A point on a younger fault now has a NaN gradient of that fault. An older fault's apply_to_points added that NaN to the point, so the restored point became NaN. Do not move points with a non-finite gradient. Clip the cosine of the fold axis rotation angle to [-1, 1], so rounding does not give NaN. Say in the fault_pitch docstring that pitch is measured from strike and that 90 is the down-dip slip vector. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2eaf43c commit ffdb3b4

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎LoopStructural/modelling/features/builders/_fault_builder.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ def create_data_from_geometry(
292292
fault_dip_anisotropy : float, default=1.0
293293
Anisotropy factor for the fault dip.
294294
fault_pitch : float, optional
295-
Pitch angle of the fault.
295+
Angle in degrees, in the fault plane, of the slip vector from the strike
296+
direction (down_dip x normal). 90 gives the down-dip slip vector, which
297+
with a positive displacement is a reverse fault.
296298
"""
297299
# Suspend automatic rebuilds while we populate internal attributes to avoid recursion
298300
self._fault_buffer = fault_buffer

‎LoopStructural/modelling/features/fault/_fault_segment.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ def apply_to_points(
593593
# hanging wall should be > 0
594594
mask2 = np.logical_and(~np.isnan(gx), ~np.isnan(gy))
595595
mask2 = np.logical_and(mask2, ~np.isnan(gz))
596+
# the gradient is NaN for points on a younger fault: do not move those points
597+
mask2 &= np.all(np.isfinite(g), axis=1)
598+
g[~mask2] = 0.0
596599
d = self._displacement_fraction(gx, gy, gz, block)
597600
d *= self.displacement
598601
if reverse:

‎LoopStructural/modelling/features/fold/_foldframe.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def calculate_fold_axis_rotation(self, feature_builder, fold_axis=None):
8787

8888
# einsum dot product
8989
far = np.einsum("ij,ij->i", projected_l1, projected_s1gyg)
90-
far = np.rad2deg(np.arccos(far))
90+
far = np.rad2deg(np.arccos(np.clip(far, -1.0, 1.0)))
9191
# scalar triple product
9292
# np.einsum("ij,ij->i", np.cross(l1, s1gyg, axisa=1, axisb=1), s1g)
9393
# check bounds

‎tests/unit/modelling/test_fault_block_fields.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,10 @@ def test_displaced_fault_block_frame_equals_the_frame_on_its_side(displaced):
253253
inside = side * young_gx > 1e-6
254254
block_gx = old.evaluate_frame_value(pts, block={"young": side})
255255
np.testing.assert_array_equal(block_gx[inside], gx[inside])
256+
257+
258+
def test_restoring_points_on_a_younger_fault_gives_finite_points(displaced):
259+
# Points on the young fault get a NaN young-fault gradient; the old fault must not spread it.
260+
on_young, _, _ = plane_points(YOUNG["center"], YOUNG["dip"], YOUNG["dip_azimuth"], n=7, half=0.3)
261+
restored = displaced["old"].apply_to_points(on_young)
262+
assert np.isfinite(restored).all()

0 commit comments

Comments
 (0)