Skip to content

fix(map2loop): use circular mean for collocated dip direction aggregation - #328

Merged
lachlangrose merged 1 commit into
masterfrom
fix/circular-mean-dip-direction
Sep 21, 2026
Merged

lachlangrose merged 1 commit into
masterfrom
fix/circular-mean-dip-direction

Conversation

@lachlangrose

Copy link
Copy Markdown
Member

Summary

Ported from Loop3D/map2loop#249 (closing that PR / archiving the standalone repo now that map2loop lives at packages/map2loop).

  • 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 packages/map2loop/tests/thickness packages/map2loop/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.

Ported from Loop3D/map2loop#249 (that repository is being archived now
that map2loop lives in packages/map2loop of this monorepo).
@lachlangrose
lachlangrose merged commit 21f0390 into master Sep 21, 2026
45 checks passed
@lachlangrose
lachlangrose deleted the fix/circular-mean-dip-direction branch September 21, 2026 15:59
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