Repository navigation
fix(mask): exclude NaN GSC magnitudes from halo/spike mean magnitude - #824
Merged
Merged
Conversation
The halo/spike star selection averages the four GSC 2.3 bands (Fmag, jmag, Vmag, Nmag) guarded only by 'is not None'. Missing GSC bands are NaN, which passes that guard, makes the mean NaN, and silently fails the 'mag < mag_limit' test - so stars with incomplete photometry are never masked. The brightest stars are the most likely to have missing/saturated bands, so this bias hits exactly the stars that most need halo masks. Average only finite bands; a star with no finite band is skipped with a log line instead of silently. On CFIS exposure 2586338 the number of halo-masked stars in the field rises from 57 to 118, including the field's brightest (mean mag 5.7 to 9.5) - among them a mag 9.5 star whose unmasked scattered-light halo on CCD 11 was full of spurious detections. All 57 previously masked stars are selected unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 14, 2026
martinkilbinger
self-requested a review
July 14, 2026 07:50
martinkilbinger
approved these changes
Jul 14, 2026
martinkilbinger
left a comment
Contributor
There was a problem hiding this comment.
Another bug that might have been introduced when transitioning from shell command findgsc to python astroquery. Also, luckily or accidentally not severe due to structural masks in post-processing.
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.
Problem
During the Nibi test run in #808, the mask module produced halo/spike masks that silently omitted some of the brightest objects in the field. The GSC catalogue used to seed halo masks contains entries with NaN magnitudes; these poisoned the mean-magnitude computation used to scale halo sizes, so bright stars near NaN entries were mishandled and dropped from the mask.
Root cause
mask.pycomputes a mean over GSC magnitudes without excluding NaNs, so any NaN entry propagates and corrupts the halo-magnitude logic.Fix
Exclude NaN GSC magnitudes from the halo/spike mean-magnitude computation in
shapepipe/modules/mask_package/mask.py(+18/-19 lines vs develop).Evidence / testing
Found during the Nibi test run in #808.
— Claude (Fable) on behalf of Cail.
🤖 Generated with Claude Code
Related: #662 — bright stars with missing GSC bands silently received no halo mask at all, which presents exactly as the under-masked bright stars reported there (on the test CCD, the halo-star count went 57 → 118 with this fix, and the recovered objects are the brightest in the field, mag 5.7–9.5). Worth re-assessing #662 once this is in; any residual contamination would then point at halo radius scaling rather than missing masks.