Skip to content
This repository was archived by the owner on Sep 21, 2026. It is now read-only.

fix: use circular mean for collocated dip direction aggregation - #249

Closed
lachlangrose wants to merge 1 commit into
masterfrom
fix/circular-mean-dip-direction
Closed

lachlangrose wants to merge 1 commit into
masterfrom
fix/circular-mean-dip-direction

Conversation

@lachlangrose

Copy link
Copy Markdown
Member

Summary

  • DipDipDirectionInterpolator.setup_interpolation clusters structure points that are within cell_size of each other (DBSCAN) and averages X, Y, DIP and DIPDIR within each cluster with a plain .mean().
  • DIPDIR is a compass bearing (wraps at 360°). A plain arithmetic mean is wrong whenever a cluster straddles due north: averaging 350° and 10° gives 180° — the exact opposite direction — instead of the correct 0°.
  • DIPDIR is now aggregated with a circular mean (mean of unit vectors, converted back to an angle). X, Y and DIP are ordinary numeric quantities and are unaffected.

Note: this fixes aggregation of collocated points only. The RBF interpolation step across the full grid still blends raw DIPDIR values without circular awareness, so it can still produce artifacts near a 0°/360° discontinuity — that's a separate, larger change (e.g. interpolating sin/cos components independently) and out of scope here.

Test plan

  • pytest tests/thickness tests/project/test_thickness_calculations.py — passes unchanged (exercises InterpolatedStructure, which uses this interpolator)
  • Manually verified _circular_mean_degrees([350, 10]) == 0 (mod float precision) vs the old mean([350, 10]) == 180

…urements

DipDipDirectionInterpolator.setup_interpolation averages collocated
structure points (within one DBSCAN cluster) with a plain arithmetic
mean. DIPDIR is a compass bearing, so this is wrong near due north:
averaging 350 and 10 degrees gives 180 (the opposite direction) instead
of 0. DIPDIR is now aggregated with a circular mean; X, Y and DIP
(not a wrapping quantity) are unaffected.
@lachlangrose

Copy link
Copy Markdown
Member Author

Closing — map2loop now lives in packages/map2loop of Loop3D/LoopStructural, and this repository is being archived. Ported to Loop3D/LoopStructural#328

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant