Skip to content

fix(mask): footprint-based NGC/Messier overlap test - #827

Merged
cailmdaley merged 1 commit into
developfrom
pr/mask-dso-footprint-overlap
Jul 14, 2026
Merged

cailmdaley merged 1 commit into
developfrom
pr/mask-dso-footprint-overlap

Conversation

@cailmdaley

@cailmdaley cailmdaley commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

mask_dso selects an NGC/Messier object only if an image corner lies within the object's radius of its centre. Objects smaller than the CCD that sit mid-image — i.e. most catalogued galaxies — never satisfy this and are silently skipped. On CFIS P3 exposure 2586338 CCD 11, NGC 5949 sits 3′ from the CCD centre, is present in ngc_cat.fits, and the log reads Found 0 NGC objects overlapping with image.

Root cause

if np.any(self._corners_sc.separation(m_sc[idx]) < r_deg):

tests corner proximity, which is an overlap test only for objects larger than the image.

Fix

Footprint overlap using the existing _fieldcenter / _img_radius: select when the object centre is within (object radius + image half-diagonal) of the image centre. Catches objects anywhere on or overlapping the CCD, scales with the per-object catalogue size, and strictly contains the old criterion (corner within r ⇒ centre within r + half-diagonal), so nothing previously selected is lost.

Evidence

  • Unit (2586338-11 WCS × full ngc_cat.fits, 11,454 objects): old criterion 0 → new 1; the selected object is NGC 5949 (sep 3.0′, inside footprint, size 2.2′×1.0′). Nearest non-selected object is 151′ away.
  • End-to-end mask_runner rerun on 2586338-11: Found 1 NGC objects overlapping with image; NGC-bit pixels 0 → 930,704, mask centred on the galaxy. Before/after figure:

NGC 5949 before/after

  • Control (DSO-free CCD 2254867-10): flag map bit-for-bit identical to develop.

Found during the Nibi test run in #808 — this completes that comment's NGC 5949 story (the bright glow there is the galaxy; its GSC counterpart 0.3′ away is likely its nucleus) and complements #824/#662.

— Claude (Fable) on behalf of Cail.

🤖 Generated with Claude Code

mask_dso selected a deep-sky object only if an image CORNER lay within
the object's radius of its centre. Objects smaller than the image that
sit mid-CCD - i.e. most catalogued galaxies - never satisfy this and
were silently skipped ('Found 0 NGC objects overlapping with image').

Replace the corner-proximity criterion with a footprint-overlap test:
the object centre within (object radius + image half-diagonal) of the
image centre, using the existing _fieldcenter and _img_radius. This
catches objects anywhere on or overlapping the CCD, scales with the
per-object catalogue size, and strictly contains the old criterion
(corner within r implies centre within r + half-diagonal), so no
previously selected object is lost.

Evidence (CFIS P3, exposure 2586338 CCD 11): NGC 5949 sits mid-CCD and
was unmasked; with the fix it is selected (old criterion: 0 objects,
new: 1) and its region flagged (NGC-bit pixels 0 -> 930,704). Nearest
non-selected NGC object is 151 arcmin away. A DSO-free control CCD
(2254867-10) produces a bit-for-bit identical flag map to develop.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@martinkilbinger

Copy link
Copy Markdown
Contributor

Wow, that's an insane bug that claude found! Can't believe this was not spotted before. Luckily we have been using the structural masks on top of the ShapePipe ones that do mask Deep Space Objects that are anywhere in the image, not just close to a corner.

@cailmdaley

Copy link
Copy Markdown
Contributor Author

actually i found this one with mine own two eyes, in the sense i said "why isn't that bright, spatially extended galaxy masked?" but claude did all the hard work :)

@cailmdaley
cailmdaley merged commit 6af71ab into develop Jul 14, 2026
3 checks passed
@cailmdaley
cailmdaley deleted the pr/mask-dso-footprint-overlap branch July 14, 2026 11:22
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