Enhance get_tilt and get_azpl functions and tests#861
Merged
Conversation
…tests for accuracy
Replace the (Ty-Gy)/(Gx-Tx) strike formulation with a vector form S = (Dy, -Dx, 0)/|Dh| that handles all horizontal projections of (G - T). Add a guard for the degenerate case where G and T differ only in z. Refresh the TestGetAzpl class docstring to reflect the analytical inverse and add a regression test for the equal-x case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the correctness, clarity, and test coverage of the
pmag.get_tiltandpmag.get_azplfunctions inpmagpy/pmag.py. The implementations of both functions have been rewritten, their docstrings have been expanded to explain their behavior and edge cases, and regression and round-trip tests have been added. Several minor code cleanups were also made.Key changes:
Core logic and mathematical correctness:
get_tiltto correctly compute the bedding orientation (dip direction and dip) that maps a geographic direction to a tilt-corrected direction, including proper handling of edge cases and improved documentation. [1] [2]get_azplto accurately recover the sample orientation (azimuth and plunge) that maps a specimen direction to a given geographic direction, with detailed notes on ambiguity and edge cases.Testing and validation:
get_tiltandget_azpl, including regression checks, round-trip property validation, and edge case handling, intest_pmag_transforms.py. [1] [2]Documentation and code clarity:
get_tiltandget_azpl, including parameter/return value descriptions, usage notes, and examples. [1] [2]Code cleanup: