GEOPY-3046: Implement borehole EM inversion - #220
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #220 +/- ##
===========================================
+ Coverage 85.78% 86.09% +0.30%
===========================================
Files 18 18
Lines 950 971 +21
Branches 126 128 +2
===========================================
+ Hits 815 836 +21
Misses 99 99
Partials 36 36
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds utilities and tests for working with borehole/curve orientation (azimuth/dip) derived from Cartesian vectors/segments, and updates a KD-tree query to use multi-threading.
Changes:
- Added
cartesian_to_azimuth_diptransformation and corresponding unit tests. - Added
azimuth_dip_from_segmentsforCurveobjects with tests validating angle ranges and reverse-direction behavior. - Updated
weighted_averageto querycKDTreewithworkers=-1.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/transformations_test.py | Adds parametrized test coverage for the new Cartesian→(azimuth,dip) conversion. |
| tests/locations_test.py | Adds integration-style test for segment-based azimuth/dip on Curve vertices (including reverse flag). |
| geoapps_utils/utils/transformations.py | Introduces cartesian_to_azimuth_dip built on existing spherical conversion and azimuth convention helpers. |
| geoapps_utils/utils/numerical.py | Enables parallel KD-tree queries via workers=-1 in weighted_average. |
| geoapps_utils/utils/locations.py | Adds azimuth_dip_from_segments for deriving vertex orientations from curve segment deltas. |
Suppressed comments (1)
geoapps_utils/utils/locations.py:258
- The azimuth “wrap-around” handling uses a modulo’d positive difference, which can pick the long way around the circle (e.g., averaging 10° and 350° yields ~180°). This will produce incorrect vertex directions when segment azimuths straddle 0/2π in the opposite ordering.
# Deal with (-pi, pi) or (0, 2pi) transition
d_azm = np.diff(azimuth, axis=1) % (2 * np.pi)
direction = azimuth[:, 0] + d_azm.flatten() / 2.0
end_lines = np.where(np.isnan(azimuth).sum(axis=1))
direction[end_lines] = np.nansum(azimuth, axis=1)[end_lines]
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
geoapps_utils/utils/locations.py:254
- The modulo always selects the positive arc between the two segment azimuths, not the shortest arc. For example, azimuth columns of 10° and 350° produce 180° here rather than the correct circular midpoint of 0°, so curves turning through north in that ordering get a reversed local direction. Normalize the delta to
[-pi, pi)and normalize the resulting direction; the test should also cover this wrap ordering.
tests/locations_test.py:225 - Use “except” here: the assertion intentionally excludes the first and last points.
GEOPY-3046 - Implement borehole EM inversion