Exclude unpopulated lag bins from plateau and half-power lag - #40
Merged
Conversation
calculate_modal_power unpacked two values from the stack's fit_spiral, which returns three (popts, perrs, model_fns), so every call raised "too many values to unpack (expected 2)". The method had no test coverage and no in-repo caller, so the breakage went unnoticed when fit_spiral gained its per-ring model_fns return. Discard the third element; behaviour is otherwise unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`_s2_kernel` leaves a lag bin with no finite pairs at its initialized
0.0, which is indistinguishable from a genuine S2 = 0. `plateau()`
pooled those bins into its outer-lag median, so any annulus whose lag
range runs off the grid -- or into a deprojection mask -- reported a
plateau pulled towards zero, and with it a correspondingly short
half-power lag.
Adds `counts_x`/`counts_y` and a `_populated_slice(axis)` helper that
masks zero-count bins to NaN, routed through `plateau()` and
`half_power_lag()` so `plateaus`, `half_power_lags`,
`reliability_weight('neff')` and `measure_heuristics` all inherit it.
`half_power_lag` also guards the interpolation when the bin below the
crossing is itself empty.
`fit_GRF` has always masked the same bins (`counts > 0`), so this only
brings the model-free path into line with the fitted one; GRF fits are
unchanged.
Measured on a 60-annulus polar grid where 30 annuli carry empty radial
bins, the noise-free heuristic bias against truth goes
ell_r -0.022 -> +0.016
ell_s -0.024 -> +0.015
alpha_r -0.465 -> +0.007
alpha_phi -0.499 -> +0.014
The residual on ell_r is the sqrt(2 ln 2) = 1.177 half-power factor.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Unpopulated lag bins were being treated as real measurements when locating the
structure-function plateau and the half-power lag, biasing both heuristics.
This excludes empty bins from those calculations.
Also includes the fix from #37 (
ValueErrorinStructureFunction2DStack.calculate_modal_power, which this branch builds on— merging this supersedes that PR.
🤖 Generated with Claude Code
EOF
)