fix(map2loop): use circular mean for collocated dip direction aggregation - #328
Merged
Merged
Conversation
…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).
2 tasks
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.
Summary
Ported from Loop3D/map2loop#249 (closing that PR / archiving the standalone repo now that map2loop lives at
packages/map2loop).DipDipDirectionInterpolator.setup_interpolationclusters structure points that are withincell_sizeof each other (DBSCAN) and averages X, Y, DIP and DIPDIR within each cluster with a plain.mean().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 (exercisesInterpolatedStructure, which uses this interpolator)_circular_mean_degrees([350, 10]) == 0(mod float precision) vs the oldmean([350, 10]) == 180