Skip to content

DM-52721: Wavelet detection - #21

Open
fred3m wants to merge 14 commits into
mainfrom
tickets/DM-52721
Open

fred3m wants to merge 14 commits into
mainfrom
tickets/DM-52721

Conversation

@fred3m

@fred3m fred3m commented Nov 7, 2025

Copy link
Copy Markdown
Collaborator

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@codecov

codecov Bot commented Nov 7, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.70588% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.47%. Comparing base (ccef28c) to head (631d300).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
python/lsst/scarlet/lite/detect.py 99.46% 3 Missing ⚠️
python/lsst/scarlet/lite/wavelet.py 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #21      +/-   ##
==========================================
+ Coverage   93.35%   94.47%   +1.11%     
==========================================
  Files          49       49              
  Lines        6400     7653    +1253     
==========================================
+ Hits         5975     7230    +1255     
+ Misses        425      423       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

get_multiband_multiresolution_support mirrors the multiband starlet
transform and reconstruction: it loops over the band axis and delegates
to the single-band routine. MultiResolutionSupport gains a multiband
flag that sets and validates the expected array dimensions.

get_multiresolution_support gains a generation parameter, which the
multiband variant passes to the space-branch noise realization.

Generated with AI

Co-Authored-By: SLAC AI
Detect peak candidates in each band and starlet scale, plus a clipped
chi-squared coadd plane that combines bands color-agnostically. The
coefficient noise is propagated from a per-band scalar variance through
the analytic per-scale factor sum(K_j**2), and the chi threshold is
calibrated to the coadd survival function to match a single-band sigma
cut.

Remove the superseded detect_sources and its DetectionResult.

Generated with AI

Co-Authored-By: SLAC AI
The image_type="space" branch returned sigma_je, the per-scale
coefficient std for unit-variance noise, without multiplying by the
estimated image noise sigma_i. The returned per-scale sigma was low by
the image noise level, disagreeing with the threshold that built the
support and with the ground branch's absolute-noise convention.

Generated with AI

Co-Authored-By: SLAC AI
FactorizedChi2Initialization and FactorizedWaveletInitialization were
deprecated for removal after v29.0 and shipped through the v30 major
release, so their removal is now due. FactorizedInitialization replaces
both.

Generated with AI

Co-Authored-By: SLAC AI
get_wavelets is reachable only through the deprecated detect_footprints,
and get_detect_wavelets is public API superseded by detect_peaks. Both
are scheduled for removal after v31.0.

Align the removal version on the existing io deprecations (ComponentCube,
from_source, from_blend) to v31.0; they were first deprecated after the
v30.0.0 release candidate, so v31.0 is the earliest release they can be
removed in.

Generated with AI

Co-Authored-By: SLAC AI
detect_peaks previously stopped at per-plane candidates. Carry those
candidates through to one detection per source:

- get_peaks runs a contrast-limited watershed that culls a peak whose
  prominence above its saddle to a brighter peak is below kappa, and
  records that saddle on each Peak.
- The chi coadd is mapped to Gaussian sigma so every significance-map
  plane shares one threshold. The mapping is evaluated in log space so
  it stays finite and monotonic for arbitrarily bright cores.
- _collapse_positions groups candidates by position and _assign_peaks
  links positions into peaks, keeping two positions distinct when a
  plane resolved them as separate peaks and letting blend_policy decide
  ambiguous ones.

A flat plateau seeds a peak, so a footprint whose only maximum is a
plateau above peak_thresh is kept rather than dropped.

Generated with AI

Co-Authored-By: SLAC AI
fred3m and others added 8 commits September 19, 2026 10:02
CI mypy (with numpy stubs) flagged six type errors in files untouched
by the detection work:

- get_filter_bounds, convolve, and Observation.convolution_bounds are
  annotated as returning/taking tuple[int, int, int, int], but the
  bounds are per-pixel arrays; correct the annotation to ndarrays.
- get_fft_shape reused one name for a bool array, an int array, and a
  list; give the padded result a definite int array and return the
  next-fast-length tuple directly.
- get_multiband_multiresolution_support broadcasts sigma to one value
  per band so the loop always indexes an array.
- relative_step casts its axis argument, which mean() rejects through
  the numpy stub.

Generated with AI

Co-Authored-By: SLAC AI
FactorizedChi2Initialization and FactorizedWaveletInitialization were
removed in favor of FactorizedInitialization, breaking the rst doctest.
Point the example at FactorizedInitialization and drop the wavelet
initialization subsection, whose bulge/disk wavelet-slice scheme no
longer exists; note that a custom detection image can still be passed
through the detect argument.

Generated with AI

Co-Authored-By: SLAC AI
Per-plane footprints of one source differ in extent across bands and
scales, so a footprint is identified with a source only after the
peaks are grouped: the per-plane footprints are unioned into a mask,
relabeled into connected components, and each final peak is placed in
the component containing it. Components left without a peak are
dropped. The peak table gains a footprint column linking back.

Generated with AI

Co-Authored-By: SLAC AI
The multi-resolution detection task in meas_algorithms coadds its own
PSF-correlated bands into a chi^2 image, so it needs the same mapping to
sigma, and the same choice of noise, that the starlet peaks use.

- build_chi2_significance maps standardized bands to Gaussian sigma, the
  step _build_significance_map performed inline.
- variance_mode chooses one noise per band or the variance plane per
  pixel. "pixel" costs a sigma as large as the starlet coefficients, so
  "median" stays the default.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A saturated or otherwise bad pixel rings in the starlet coefficients
and seeds false peaks in a halo around it. Drop peak candidates that
fall within a dilated bad-pixel mask, per band, so a source stays
detected in the bands that are clean there. The halo widens with the
starlet kernel, so the dilation radius doubles with each scale.

Generated with AI

Co-Authored-By: SLAC AI
The sequential assignment in _assign_peaks depended on the visiting
order, and a coarse-scale position between two resolved sources
could seed a peak of its own. Treating a missing link as evidence of
two sources makes every peak a clique, so the number of peaks is the
minimum clique cover of each connected component: greedy bounds, then
an exact search up to search_cap. The result is independent of the
candidate order.

Positions fully adjacent to another clique are flagged ambiguous and
left out of the peak location, which is the position nearest the
median of the peak's candidates. psf_fwhm takes one value per band;
the per-band values break location ties and set the new statistical,
moment and scatter errors on each peak. The pairs and components
tables and the grouping metadata are returned for diagnostics.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Build footprints around a caller-supplied peak catalog instead of
detecting peaks per footprint. Each peak seeds its connected component
above footprint_thresh; components no peak reaches are dropped, and a
component reached by several peaks yields one footprint holding them
all. Peaks are in image coordinates, shifted by y0/x0 onto the local
array.

Generated with AI

Co-Authored-By: SLAC AI
Spiral arms and star forming regions are detected as separate peaks.
Peaks that share a connected region of the first-scale chi coadd above
1 sigma get a common structure_id and the region's peak count, so that
catalog users can cut on shredded galaxies. This is a stand-in for a
trained classifier.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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