Skip to content

Old-vs-new mask comparison on real data (tiles + exposures) #850

Description

@cailmdaley

The gate for retiring ShapePipe's internal masking (#847 keeps the old path config-selectable until this lands). Part of epic #845.

Goal. Run both mask paths on the same real data — the Nibi P3 run (#808: 10 tiles, ~1960 single-CCD exposures) is the natural testbed — and understand, visually and quantitatively, what each mask piece does and where it comes from, before the old path is removed.

Deliverables:

  • Side-by-side visual overlays of old (WeightWatcher/GSC star halos+spikes, NGC/Messier regions) vs new (healsparse-rasterized maskforce) masks on real image pixels, for several tiles and exposure CCDs. The question each panel answers: do the masks land on the artifacts, and which system catches what?
  • Component-provenance audit. A table of every mask ingredient and where it enters each path: saturation / bleeding / bad columns (instrument flag files from CFHT preprocessing — summed in at the exposure level via USE_EXT_FLAG), cosmic rays (Stephen's masking), bright-star halos + spikes (old: GSC-2.3 + WeightWatcher; new: PhotoPipe bright-star masks), extended galaxies (old: NGC/Messier region files; new: 2MASS manual masks), MaxiMask. Per Axel (Slack 2026-07-16), the exposure level is where pixel masks matter — the audit should make explicit what the exposure-level flag image contains under each path.
  • Quantitative comparison: masked-area fractions, IMAFLAGS_ISO population changes, PSF star-selection differences (counts + size–magnitude locus), and PSF model quality on the affected CCDs.

Non-goal: deciding halo/spike sizes — that validation is the tangential-shear test (separate sub-issue), though the two share infrastructure.

— Fable, on behalf of Cail

Activity

  1. cailmdaley commented on Jul 16, 2026

    @cailmdaley
    ContributorAuthor

    Old vs new masks on real data — 10 tiles + 9 exposure CCDs from the P3 run (#808).

    All panels: CFIS r-band pixels (zscale + asinh stretch); percentages = masked fraction per component. These figures compare only what gets masked in ShapePipe: the NEW panels show the external healsparse masks as #847 rasterizes them into the pipeline — in current production those are applied post-production, at the catalogue level.

    • Tile figures (OLD | NEW). OLD = ShapePipe's internal tile pipeline_flag from this run: GSC-2.3 star halos + diffraction spikes rasterized by WeightWatcher (Messier/NGC masking enabled but empty on these tiles; no instrument content at tile level). NEW = the external healsparse reason maps (nside 131072 ≈ 1.6″) queried at each pixel's sky position: faint star halo (bit 1), bright star halo (2), bright stars (4), manual galaxy mask (8), MaxiMask (1024).
    • Exposure figures (INSTRUMENT | OLD | NEW). One full 2112×4644 MegaCam CCD each. INSTRUMENT = the CFHT/Elixir flag file (bad pixels, saturation, bleed trails); in production it is summed into both old and new pipeline_flag, so it is shown separately — the OLD/NEW panels isolate what each masking system itself adds. OLD caveat: bit 2 is ambiguous (halo=2 collides with instrument saturated=2 under summing).

    Tiles

    tile 196-305
    tile 196-306
    tile 196-307
    tile 196-308
    tile 196-309
    tile 198-305
    tile 198-306
    tile 198-307
    tile 198-308
    tile 198-309

    Exposure CCDs

    exp 2114049-4
    exp 2114049-28
    exp 2114050-13
    exp 2114051-36
    exp 2254829-0
    exp 2254830-22
    exp 2254831-9
    exp 2254835-31
    exp 2254867-18

    — Fable, on behalf of Cail

  2. aguinot commented on Jul 16, 2026

    @aguinot
    Contributor

    If I may make a few comments:

    • Using MaxiMask on the coadds is hard to justify. MaxiMask was not trained on coadds but on single exposures.
    • More generally, I don't see a justification to use MaxiMask at all. It was trained on old and outdated CFHT images and the outcome is redundant in some case, or just bad.
    • We don't need pixel level masks on the coadds.
    • The bright stars/objects can be constructed at the single exposure level and combined to a full sky mask at posteriori.

    A mask like this is the best way to inject systematics in the data
    Image

  3. martinkilbinger commented on Jul 17, 2026

    @martinkilbinger
    Contributor

    Something went very wrong with the ShapePipe tile masks, none of the star masks and actual star coordinates match.

  4. cailmdaley commented on Jul 17, 2026

    @cailmdaley
    ContributorAuthor

    @martinkilbinger i don't think that's true, there are stars under the old ShapePipe tile masks. it's just that not all stars are masked.

  5. AstroMike commented on Jul 17, 2026

    @AstroMike

    Ludo identified one case where the external (galaxy mask) did not look good.

    Can you @cailmdaley / Claude maybe draw 20 tiles or CCDs randomly from P3 that have at least one external mask present, and overlay just the mask with the greyscale so we can see how well or poorly it fits? (It looks better if its just an outline not a filled-in coloured polygon).

    I will let you turn this into a separate subtask on github - I claim ignorance.

  6. AstroMike commented on Jul 17, 2026

    @AstroMike

    @martinkilbinger i don't think that's true, there are stars under the old ShapePipe tile masks. it's just that not all stars are masked.

    I believe the GSC (guide star catalogue) intentionally rejected close pairs of stars (these not good for HST to guide on), so its far from complete.

  7. cailmdaley commented on Jul 17, 2026

    @cailmdaley
    ContributorAuthor

    More generally, I don't see a justification to use MaxiMask at all.

    @aguinot what should we do for the streaks (satellites?) that appear occasionally then? the instrument mask doesn't seem to capture them:

  8. cailmdaley commented on Jul 17, 2026

    @cailmdaley
    ContributorAuthor

    Can you @cailmdaley / Claude maybe draw 20 tiles or CCDs randomly from P3 that have at least one external mask present, and overlay just the mask with the greyscale so we can see how well or poorly it fits? (It looks better if its just an outline not a filled-in coloured polygon).

    sure, check out #855 @AstroMike

  9. aguinot commented on Jul 21, 2026

    @aguinot
    Contributor

    Satellite strickes could be a reason to use MaxiMMask but just for this purpose only. Also, maybe the mask would need to be rework a bit before use to enlarge and "smooth" it. The dented pattern is probably not great in terms of systematic.

  10. cailmdaley commented on Jul 23, 2026

    @cailmdaley
    ContributorAuthor

    Following the telecon action, here are updated versions of the mask-comparison CCD figures with the PSF stars added. Each setools PSF-star candidate is drawn as an open circle on both the old pipeline_flag and the new healsparse (n1|n2|n4) panels: blue = survives the full ShapePipe PSF selection (setools cuts -> PSFEx sample selection -> PSFEx sigma clipping / FLAGS_PSF), so it constrains the PSF model; red = candidate rejected somewhere in that chain. Markers are open so the star stays visible underneath.

    2086749-17
    2086750-39
    2104298-25
    2113833-33
    2602952-30

    — Claude on behalf of Cail

  11. aguinot commented on Jul 23, 2026

    @aguinot
    Contributor

    It looks like the mask of the spikes is not aligned with the spikes. Do you understand why?

  12. cailmdaley commented on Sep 4, 2026

    @cailmdaley
    ContributorAuthor

    Refreshed the comparison against the regenerated August masks (UNIONS_DR6_finalmask; same 10 P3 tiles plus the CCDs from the earlier posts; masks now drawn as outlines + hatching rather than fills). Two things stand out:

    • Bits 0 and 1 have exchanged content relative to the July set: July n1 ≡ August n2 pixel-for-pixel and vice versa, while the bit-table header still says bit 0 = faint halo, bit 1 = bright halo — so one vintage disagrees with its own header. The two bits are a subset/superset pair, not concentric rings: where both are present the halos coincide; the larger set adds same-radius halos around more stars. The Aug-2025 products had the same layout as July (the cumulative-area table on the wiki Masking page: n2 924 deg², n1 adds 1.8 deg²), so August 2026 is the vintage that changed. The extra stars in the larger set skew fainter (GSC: brightest 5% at V≈12 vs V≈10 for stars in both), which suggests the larger set is the faint-halo selection — i.e. the August labelling is the header-consistent one and the earlier products had the bits swapped, but the GSC magnitudes are too sparse to call it. @AstroMike, is the swap intended, and are the two halo bits meant to be nested (same radius, deeper cut) rather than distinct populations?
    • Otherwise the change is a ~30% growth in n4 (bright stars, 8.5% → 11.1% of tile area); the other bits move by a few percent or less.

    The CCD panels also carry the PSFEx star fate from a rerun on the #847 branch (○ kept, ✕ clipped by PSFEx outlier rejection, marker size ∝ CHI2_PSF; faint dots are the 20% validation hold-out). Over the 14 CCDs: 531 kept, 22 clipped, 145 held out.

    fig_tile_198-307.png
    fig_ccd_2254829-0.png
    stat2_bit_crossmatch.png

    All 10 tile panels

    fig_tile_196-305.png
    fig_tile_196-306.png
    fig_tile_196-307.png
    fig_tile_196-308.png
    fig_tile_196-309.png
    fig_tile_198-305.png
    fig_tile_198-306.png
    fig_tile_198-307.png
    fig_tile_198-308.png
    fig_tile_198-309.png

    All 14 CCD panels

    fig_ccd_2086749-17.png
    fig_ccd_2086750-39.png
    fig_ccd_2104298-25.png
    fig_ccd_2113833-33.png
    fig_ccd_2114049-28.png
    fig_ccd_2114049-4.png
    fig_ccd_2114050-13.png
    fig_ccd_2114051-36.png
    fig_ccd_2254829-0.png
    fig_ccd_2254830-22.png
    fig_ccd_2254831-9.png
    fig_ccd_2254835-31.png
    fig_ccd_2254867-18.png
    fig_ccd_2602952-30.png

    Full set: https://gist.github.com/cailmdaley/db592afba3553207d8f679029b581a15

    — Claude, on behalf of Cail

  13. cailmdaley commented on Sep 4, 2026

    @cailmdaley
    ContributorAuthor

    It looks like the mask of the spikes is not aligned with the spikes. Do you understand why?

    i don't, i was waiting for the above comparison to see the misalignment went way, looks like it hasn't.. the star spike mask seems to be big enough that it's not an issue.

  14. cailmdaley commented on Sep 30, 2026

    @cailmdaley
    ContributorAuthor

    The current DR6 halo labels are settled: MASK_n1 = faint-star halo (value 1, bit index 0); MASK_n2 = bright-star halo (value 2, bit index 1). MASK_n4 is the separate star-body mask. This follows the producer schema, Mike's identification of n2 as the bright-halo panel at the 29 September call, and Cail's adoption of that convention.

    The descriptions now agree in ShapePipe #886, sp_validation #343, calibration labels and the mask wiki page. Independent fixtures verify that distinct n1/n2 maps retain their identities through catalogue writing, adaptation and separate cuts (5 ShapePipe tests and 55 validation grammar tests passed in containers). No mask files, numerical column identities or default selections were exchanged.

    The measured July–August content exchange remains a historical provenance difference; its cause is unknown. Each replacement ladder should carry its release, source revision when available, checksums and bit schema. This closes the remaining label question in this already-closed issue; it does not claim a new validation of mask radii or a with/without-mask rho campaign.

    — GPT-6 on behalf of Cail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions