Skip to content

fix(mask): exclude NaN GSC magnitudes from halo/spike mean magnitude - #824

Merged
cailmdaley merged 1 commit into
developfrom
pr/mask-halo-nan-magnitude
Jul 14, 2026
Merged

cailmdaley merged 1 commit into
developfrom
pr/mask-halo-nan-magnitude

Conversation

@cailmdaley

@cailmdaley cailmdaley commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

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.py computes 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

  • On the affected Nibi tile, the halo star count goes from 57 to 118, now including very bright objects in the mag 5.7–9.5 range; all 57 originally-selected halo stars are unchanged.
  • End-to-end mask rerun on exposure 2586338-11 completes with the corrected halo set.
  • Honesty note: the poster-child "bright object" recovered here is actually the galaxy NGC 5949, shredded by GSC into a Class-0 entry — the fix is still correct (NaN magnitudes must not poison the mean), but that particular object is a catalogue artefact rather than a bright star.

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.

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>

@martinkilbinger martinkilbinger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cailmdaley
cailmdaley merged commit d5f70a7 into develop Jul 14, 2026
3 checks passed
@cailmdaley
cailmdaley deleted the pr/mask-halo-nan-magnitude branch July 14, 2026 11:10
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.

2 participants