StructureFunction2DStack.fit_spiral / calculate_modal_power has no per-annulus fault tolerance
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 78/100
Research direction
Start in structurefunction.py at StructureFunction2D.fit_spiral around lines 2066-2101, then inspect StructureFunction2DStack.fit_spiral and calculate_modal_power around lines 2852-2882. Use test_structurefunction.py as the test entry point and add a case with insufficient azimuthal coverage. Done means an unfit ring contributes a NaN row without aborting the stack, while fully covered results remain unchanged.
Written by the indexing model from the issue text.
Description
Problem
StructureFunction2D.fit_spiral (structurefunction.py:2066) raises ValueError
when a ring has fewer than len(modes) + 1 finite azimuthal S_2 points
(line ~2101: "Not enough finite points to fit {} modes."). StructureFunction2DStack.fit_spiral
(structurefunction.py:2852) loops over self.results calling this per-ring with no
try/except, so one masked/incomplete annulus aborts the whole stack fit rather
than just that ring. calculate_modal_power (structurefunction.py:2882) inherits
the same gap, since it calls self.fit_spiral directly.
This is exactly the kind of thing real interferometric data hits: masked pixels,
partial azimuthal coverage at the inner/outer edge of the analysis annulus, etc.
Clean, full-coverage synthetic fields (the only case in test_structurefunction.py
today) never trigger it, so it went unnoticed.
Context: calculate_modal_power had no in-repo caller until now (see
a00a695's commit message on fix-modal-power-unpack, which fixed an unrelated
tuple-unpacking bug in the same method). It now has a real one -- Paper 2's
"Modal Power" analysis (StructureFunction/paper2/notebooks/run_s2_modal_power.py)
-- which is what surfaced this.
Suggested fix
Catch the per-ring failure in StructureFunction2DStack.fit_spiral (and by
extension calculate_modal_power) and fill a NaN row instead of propagating,
matching the censoring-free convention already used elsewhere in this project
(e.g. noise_mc._accumulate_null, spiral_null._SpiralNull.build_null in
StructureFunction/paper2/notebooks): a draw/ring that can't be fit contributes
NaN, not a crash.
Reference implementation
run_s2_modal_power.robust_modal_power in the StructureFunction repo
reproduces calculate_modal_power's reduction with this fix (per-ring
try/except around r.fit_spiral), and has been checked bit-identical to
calculate_modal_power on a fully-covered synthetic stack
(max abs diff frac_of_data == 0.0). Worth pulling that fault-tolerance
into eddy directly rather than leaving it as a local workaround, along with
a test case that exercises a ring with insufficient azimuthal coverage
(currently untested).
- Dominant language
- Python
- Stars
- 23
- Forks
- 10
- Avg merge
- 28m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PlanetFormationLab/eddy
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
PlanetFormationLab/eddy#36 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
PlanetFormationLab/eddy#35 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
PlanetFormationLab/eddy#34 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
PlanetFormationLab/eddy#33 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
PlanetFormationLab/eddy#32 ·
All issues in PlanetFormationLab/eddy
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·