DM-54305: Improve guider source detection robustness#188
Open
DM-54305: Improve guider source detection robustness#188
Conversation
1443b36 to
ab37a2e
Compare
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.
decaa3e to
3bed600
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
measureStarOnStamp: replace NaN from border-clippedCutout2Dwith median instead of rejecting the whole cutout, recovering stars near stampedges.
to drift or artifacts.
them.
isBlankImagewith adaptive peak pixel SNR.fluxErrsqrt warning inrunGalSim(clamp negative flux/gain to 0).detection_methodcolumn ("coadd" or "single_stamp") inbuildReferenceCatalog.Validation
Night 2026-02-22 (447 sequences, 3576 guider-sequences):
Breakdown of the 86 missed (3696 - 3610):
Test plan
convergence, not this PR)
Open: