Skip to content

Enhance get_tilt and get_azpl functions and tests#861

Merged
Swanson-Hysell merged 2 commits into
masterfrom
get_tilt_improvements
May 8, 2026
Merged

Enhance get_tilt and get_azpl functions and tests#861
Swanson-Hysell merged 2 commits into
masterfrom
get_tilt_improvements

Conversation

@Swanson-Hysell

Copy link
Copy Markdown
Member

This pull request improves the correctness, clarity, and test coverage of the pmag.get_tilt and pmag.get_azpl functions in pmagpy/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:

  • Rewrote get_tilt to 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]
  • Rewrote get_azpl to 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:

  • Added comprehensive tests for get_tilt and get_azpl, including regression checks, round-trip property validation, and edge case handling, in test_pmag_transforms.py. [1] [2]

Documentation and code clarity:

  • Expanded and clarified docstrings for both get_tilt and get_azpl, including parameter/return value descriptions, usage notes, and examples. [1] [2]

Code cleanup:

  • Removed unnecessary comment lines and extraneous section markers for better readability. [1] [2] [3] [4] [5] [6] [7]

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.
@Swanson-Hysell Swanson-Hysell merged commit 0703429 into master May 8, 2026
2 checks passed
@Swanson-Hysell Swanson-Hysell deleted the get_tilt_improvements branch May 8, 2026 22:13
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.

1 participant