Skip to content

DM-54305: Improve guider source detection robustness#188

Open
estevesjh wants to merge 8 commits intomainfrom
tickets/DM-54305
Open

DM-54305: Improve guider source detection robustness#188
estevesjh wants to merge 8 commits intomainfrom
tickets/DM-54305

Conversation

@estevesjh
Copy link
Member

@estevesjh estevesjh commented Mar 3, 2026

Summary

  • Fix NaN handling on cutout window in measureStarOnStamp: replace NaN from border-clipped
    Cutout2D with median instead of rejecting the whole cutout, recovering stars near stamp
    edges.
  • Add single-stamp fallback when coadd detection fails: recovers stars lost in the coadd due
    to drift or artifacts.
  • Add GalSim failure warning when FootprintSet finds sources but GalSim fails on all of
    them.
  • Replace absolute flux threshold in isBlankImage with adaptive peak pixel SNR.
  • Fix fluxErr sqrt warning in runGalSim (clamp negative flux/gain to 0).
  • Track detection_method column ("coadd" or "single_stamp") in buildReferenceCatalog.

Validation

Night 2026-02-22 (447 sequences, 3576 guider-sequences):

Stage Stars Possible Rate
Old pipeline 1345 3576 37.6%
+ DM-54263 (stddev>0 fix) 3144 3576 87.9%
+ DM-54305 (this PR) 3386 3576 94.7%
+ De-streak correction 3610 3696 97.7%

Breakdown of the 86 missed (3696 - 3610):

  • 41 coadd ellipticity rejections (was 112)
  • 29 no-detections (was 30)
  • 16 tracking quality cuts rejection (was 8)

Test plan

  • Validated on 447 sequences from night 2026-02-22
  • 192 passing control sequences: 117 unchanged, 65 improved, 10 lose 1–2 stars (GalSim
    convergence, not this PR)
  • black, isort, mypy pass

Open:

@estevesjh estevesjh force-pushed the tickets/DM-54305 branch 5 times, most recently from 1443b36 to ab37a2e Compare March 4, 2026 14:30
@estevesjh estevesjh requested a review from mfisherlevine March 9, 2026 19:34
When source detection on the coadd image fails for a guider, fall back
to trying detection on individual stamps evenly spread across the
sequence. Stamps with low peak pixel SNR are skipped as truly empty.
Returns the detection with the highest SNR. This recovers stars that
are lost in the coadd due to drift or artifacts.

Adds nFallbackStamps and peakSnrThreshold to GuiderStarTrackerConfig.
(DM-54263)
- Fix NaN handling on cutout window in measureStarOnStamp: replace NaN
  from border-clipped Cutout2D with median instead of rejecting the
  whole cutout, recovering stars near stamp edges.
- Add GalSim failure warning in runSourceDetection when FootprintSet
  finds sources but GalSim fails on all of them.
- Fix fluxErr sqrt warning in runGalSim: clamp negative flux/gain to 0.
- Track detection_method column ("coadd" or "single_stamp") in
  buildReferenceCatalog.
- Replace absolute flux threshold in isBlankImage with peak pixel SNR.
- Add module-level logger for detection diagnostics.

(DM-54305)
Replace np.nanstd with MAD (median absolute deviation) scaled by
1.4826 for a robust noise estimate. The previous np.nanstd was
inflated by streaks and negative artifacts, causing isBlankImage
to misclassify guiders with real stars as blank.

(DM-54305)
Restores the original fluxMin=300 ADU absolute threshold as the
primary check so bright stars are never misclassified as blank,
and keeps the MAD-based peakSNR as a secondary check for fainter
stars in low-noise images.
When FindAdaptiveMom cannot converge, use the 0th moment
(flux-weighted center of mass) and aperture photometry instead
of discarding the star. Adds galsim_failed flag to
StarMeasurement and DEFAULT_COLUMNS for downstream tracking.
The fallback in measureStarOnStamp corrupted buildReferenceCatalog
by returning non-empty results for GalSim failures, which prevented
_detectOnSingleStamps from running. Net result was a regression
(208 missed vs 191 without fallback). Reverted entirely.
…stars

When all reference catalog candidates for a guider are rejected by
quality cuts, log the best candidate (highest SNR) with flux, snr,
ellipticity, fwhm, and position, plus which cut rejected it.
Distinguishes between "no detection" and "detected but rejected".
Uses the same mask logic as applyQualityCuts for accuracy.
As suggested by Robert, use a low percentile (default 10th) instead
of the median for column bias estimation. Stars and trails are very
unlikely to live in the 10th percentile, which avoids the dark dip
artifacts created by the median being pulled by bright sources.
The percentile is slightly noisier but eliminates the dark bands.

Added biasPercentile config option to GuiderReader.get() and
processStamps() to allow tuning the percentile value.
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