Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plane from trace #17

Merged
merged 27 commits into from
Feb 4, 2025
Merged

Plane from trace #17

merged 27 commits into from
Feb 4, 2025

Conversation

claudio525
Copy link
Contributor

Build on top of #14, so that needs to be merged first.

  • Adds function to create a Plane object from a fault trace definition. Useful for the old NSHM fault definitions.
  • Increase tolerance in orientation check to prevent flipping when dip is very close to 90 (
    if not np.isclose(orientation, 0, atol=1e-3) and orientation < 0:
    )

@claudio525 claudio525 marked this pull request as draft December 4, 2024 01:39
@claudio525
Copy link
Contributor Author

claudio525 commented Jan 28, 2025

The latest commit has two changes:

  • The order of the trace points is no longer important. The dip direction is used to determine the strike, which is all handled by the post_init. Made this change as my initial interpretation of the NHM fault definitions was incorrect, i.e. I had assumed that the order of the trace points has meaning, however turns out it does not.
  • It now operates on nztm data instead of lat,lon to ensure a consistent dip direction, which is required for creating a Fault object.

@claudio525 claudio525 marked this pull request as ready for review January 28, 2025 20:24
source_modelling/sources.py Outdated Show resolved Hide resolved
tests/test_sources.py Outdated Show resolved Hide resolved
tests/test_sources.py Outdated Show resolved Hide resolved
source_modelling/sources.py Outdated Show resolved Hide resolved
@lispandfound
Copy link
Contributor

@claudio525 I have made a few changes:

  1. Vectorised the mathematics,
  2. Updated the docstrings,
  3. Improved the tests to use pytest.approx (and also modify the tests for the failure cases on fault construction),
  4. Changed the dip direction consistency check to work directly on the NZTM corner representation (actually checking the dip direction vectors are parallel). This should remove the numerical issues related to the calculation of dip direction in this method.

@lispandfound lispandfound self-requested a review January 29, 2025 02:02
@claudio525
Copy link
Contributor Author

@lispandfound I was working on this last night and this morning without realising that you had made changes, so have just combined our changes.

@lispandfound
Copy link
Contributor

lispandfound commented Jan 30, 2025

@claudio525 I made a couple of changes:

  1. I move the dip direction check to after the plane rearrangement for strike. For really long faults (such as the alpine fault), dip direction is not quite consistent because it's a measured bearing from north and the relative location of north changes ever so slightly over really long faults -- like the Alpine fault for example. Now dip direction is checked after rearranging the planes into a line, and then only adjacent faults are checked. This is the only way I've been able to get the alpine fault nshm examples to load properly.
  2. Improve the fault construction failure tests by making them use from_centroid_strike_dip instead of corners so we can understand their behaviour better.

Copy link
Contributor

@lispandfound lispandfound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one small change left!

source_modelling/sources.py Outdated Show resolved Hide resolved
lispandfound
lispandfound previously approved these changes Feb 3, 2025
tests/test_sources.py Outdated Show resolved Hide resolved
plane = Plane.from_nztm_trace(
trace_points_nztm, dtop, dtop + depth, dip, dip_dir_nztm=dip_dir_nztm
)
assert pytest.approx(plane.top_m, abs=1e-3) == dtop * 1000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of abs varies from 1e-6 (strike_nztm, dip) to 10 (dip_dir). Was it determined empirically?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of abs varies from 1e-6 (strike_nztm, dip) to 10 (dip_dir). Was it determined empirically?

The tolerance on dip direction is 0.1. Yes some of these values have higher tolerances because they are subject to greater variation and numerical error. The great circle bearings in particular are very finicky to get right.

plane = Plane.from_nztm_trace(
trace_points_nztm, dtop, dtop + depth, dip, dip_dir_nztm=dip_dir_nztm
)
assert pytest.approx(plane.top_m, abs=1e-3) == dtop * 1000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of abs varies from 1e-6 (strike_nztm, dip) to 10 (dip_dir). Was it determined empirically?

The tolerance on dip direction is 0.1. Yes some of these values have higher tolerances because they are subject to greater variation and numerical error. The great circle bearings in particular are very finicky to get right.

tests/test_sources.py Outdated Show resolved Hide resolved
@lispandfound lispandfound merged commit 07e6e03 into main Feb 4, 2025
5 checks passed
@claudio525 claudio525 deleted the plane_from_trace branch February 4, 2025 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants