Skip to content

Tile-level defect flags: exposure IMAFLAGS_ISO and interpolated-defect epochs on each object's footprint - #973

Open
cailmdaley wants to merge 8 commits into
feat/uberseg-seg-vignetfrom
feat/defect-flags-tile
Open

cailmdaley wants to merge 8 commits into
feat/uberseg-seg-vignetfrom
feat/defect-flags-tile

Conversation

@cailmdaley

@cailmdaley cailmdaley commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

We add exposure-defect flags on each tile object's segmentation footprint, leaving fits and existing stamp-wide diagnostics unchanged.
On real tile 188.307, 0.49% of objects with known footprints have an interpolated defect on their footprint, compared with 36.28% with interpolation somewhere in a kept stamp.
These are detection-level, no-fitting checks on one tile, not shear-sample rates.

Stacks on #925, which supplies int32 SEG_VIGNET through the committed detection and Tile_cat loader.
Stacking only on #922 would leave fitted objects without that input and produce -1.

Columns

  • NGMIX_IMAFLAGS_ISO preserves the bitwise OR of exposure instrument flags on tile_seg == obj_id, across epochs passing the masked-fraction cut and central veto.
  • NGMIX_N_EPOCH_INTERP_ISO counts those kept epochs with an interpolated defect on the same footprint.
    An unflagged zero-weight pixel can contribute to the count without adding an instrument bit.

We MegaCam-flip the coadd segmentation into each epoch orientation without reprojection, matching the existing overlay.
Both columns are -1 for missing, empty or edge-clipped footprints; never-fit final rows use 0 and still require fit-status checks.
Clean quarter-turn weight copies don't count as defects.
We record the choice in ASTRA's shape_measurement.defect_flagging decision and pin it in universes/committed.yaml.

Real-tile validation

We regenerated seven locally available exposures and tile inputs under /scratch/cdaley/defectflag-check/, with production mounts read-only and retrieval set to symlinks.
No download, production write, galaxy fit or back-fill was needed.
The read-only diagnostic script calls the real prepare_postage_stamps path with committed SEG_VIGNET, uberseg and interpolation.

Diagnostic Count / denominator Rate
Interpolation on the footprint 173 / 35,056 known footprints 0.4935%
Instrument bits on the footprint 174 / 35,056 known footprints 0.4963%
Interpolation anywhere in a kept stamp 12,943 / 35,677 objects with kept epochs 36.2783%
Edge-clipped -1 sentinel 621 / 35,677 objects with kept epochs 1.7406%

There are 36,051 detections, 374 without a kept epoch, and no empty footprints.
The edge-sentinel share is below the proposed few-percent threshold for reconsidering that policy on this tile.
The positive instrument bits are 1: 82, 2: 24, and 8: 96 objects; overlapping bits preserve their original identities.
All 112,734 kept flag stamps read from the regenerated SQLite stores are int16.
A literal final-column != 0 also includes the unknowns: 795/36,051 (2.2052%), versus 174 objects with positive bits.

Tile 188.307 footprint defects over the exposure defect map

Orange points are interpolation-positive objects; blue is flagged CCD pixels per sky pixel, not flagged exposures.
All 173 affected centroids are within 8 arcsec of a positive map cell, versus 82.2% of 2,000 deterministic controls.
Only 23/173 centroids occupy a positive cell themselves; the defective pixel can lie elsewhere on the footprint.
The campaign map's coarse rasterization makes this a spatial consistency check, not an independent false-positive measurement.

How the numbers fit together. Before the epoch cuts, 6.05% of objects have instrument flags on their footprint in at least one epoch. That matches the 6.97% of the tile area where the defect map is positive. The masked-fraction cut and the central veto then remove most of those epochs. 78% of footprints lie wholly inside the 7-px interpolated-defect veto radius, so for them any interpolated defect on the footprint drops the epoch instead of reaching the fit. What remains, 0.5%, are objects whose outer isophote crosses a defect that was interpolated and kept. The flag therefore marks the residual exposure to interpolation, not every object a defect ever touched. Epochs lost to defects show up in the epoch-cut counts, not here.

An independent-pixel estimate, 1-exp(-0.0028*A*N) per object, overshoots: 31.75% over the whole footprint, 6.81% outside the veto radius. The reason is that defects cluster. Kept footprints have a flagged-pixel fraction of 0.0149% (the kept stamps as a whole: 0.145%). Over a mean footprint of 66.8 px and 3.16 kept epochs, that is 0.031 flagged pixels per object. With 0.5% of objects flagged, each hit carries about 6 flagged pixels, as expected from column segments and clusters rather than isolated pixels. The rates come from 7 of the tile's 9 exposures (the two others were not on disk), so production objects have slightly more epochs.

The validation note and JSON summary give the denominators, bit combinations, local pixel rates, limitations and reproduction paths.

Tests and execution scope

The rebased ngmix, make_cat, unit and PSF property suite passes 830 tests, one skipped; workflow/DAG/params-pin checks pass 31 tests, one skipped.
ASTRA validation passes and the params pin is unchanged.
Completeness checks count files, not columns; this change creates no additional pipeline product file.
Fixtures cover clean and rejected epochs, flipped CCDs, missing/empty/clipped segmentation, zero-weight flag-zero defects, unsafe casts, integer FITS round trips and never-fit rows.
The committed-workflow guard resolves data and image-simulation configurations under default, noisefill and uberseg handling, then verifies segmentation delivery and clean-object zeros.

Restored mutation Assertion failures
Whole stamp instead of footprint 2
Overwrite instead of OR across epochs 2
Accumulate before epoch cuts 8
Drop make_cat mapping 1
Remove committed SEG_VIGNET export 6
Disable committed SEG_VIGNET option 6
Drop Tile_cat SEG_VIGNET read 6

The private run used one def-mjhudson allocation, 24921492, with 16 CPUs and 40 GiB.
The initial 29-job plan completed exposure products, detection, headers and PSF interpolation; we stopped its slow, unrelated CLASSIC coadd-weight FITS copy.
A separately audited private one-rule Snakemake target ran only the committed MULTI-EPOCH vignetmaker section and completed all five stores with 36,051 rows each.
We did not mark the original full tile-vignet stage complete.
The real measurement, PNG and cached/uncached synthetic-equivalence check completed before the allocation ended.
A final targeted pytest rerun hit the allocation time limit and supplies no additional completed-suite result.
The allocation has ended and we also issued scancel; no work is left running.
Scratch quota checks showed ample headroom before and after.

Open question: should we back-fill batches already run?
The columns don't require shear refits, but the inspected batches no longer retain usable shared vignet stores, so we would need to locate or regenerate those inputs first.
We haven't back-filled anything.

— Sol and Claude Opus on behalf of Cail.

🤖 Generated with Claude Code

cailmdaley and others added 7 commits October 24, 2026 09:18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ct footprints

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ey check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ery handling

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eration plan

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cailmdaley
cailmdaley force-pushed the feat/defect-flags-tile branch from c45de2f to 3ea9bc1 Compare October 24, 2026 13:32
@cailmdaley
cailmdaley changed the base branch from feat/masked-pixels to feat/uberseg-seg-vignet October 24, 2026 13:32
Measure real epoch preparation without fitting, record denominators and bit counts, and add a spatial overlay and conditional Poisson interpretation. Cache read-only stores and exposure WCS decoding for bounded validation runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cailmdaley
cailmdaley marked this pull request as ready for review October 24, 2026 15:53

This branch has not been deployed

No deployments
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.

1 participant