stdpipe.photometry_quality module

PSF-based per-source quality metrics borrowed from the crowdsource photometry pipeline (Schlafly et al., MIT-licensed).

The metrics operate on stacks of postage stamps:

impsf — neighbour-subtracted data stamps (data minus the model of every other source). For an isolated source this is just the data stamp.

im — raw data stamps (no neighbour subtraction).

psf — model PSF stamps for each source, normalized to integrate to one.

weight — inverse-sigma stamps; pixels with weight == 0 are treated as masked.

All inputs are (N, S, S) arrays. Outputs are length-N 1D arrays.

The functions are deliberately decoupled from any particular photometry backend so they can be reused from stdpipe.photometry_psf.measure_objects_psf(), stdpipe.photometry_measure.measure_objects_sep(), or external code.

stdpipe.photometry_quality.neff_fwhm(stamp)[source]

FWHM-like quantity of a 2D PSF stamp, equivalent to crowdsource.psf.neff_fwhm.

Returns 1.18 / sqrt(pi * sum((p/norm)^2)). The 1.18 calibrates the n_eff-derived width to the actual FWHM of a Gaussian PSF.

stdpipe.photometry_quality.convolve_with_exp_galaxy(psf_stack, re)[source]

Convolve each (S, S) PSF in psf_stack with a circular exponential galaxy of effective radius re (in pixels).

Uses an FFT-based 6-Gaussian mixture approximation of the exponential, so the result is the same shape as the input. re may be a scalar or a length-N array (one per source).

stdpipe.photometry_quality.compute_qf(psf_stack, weight_stack)[source]

Per-source PSF quality factor.

qf = sum(P_normed * (W > 0)) — the fraction of the PSF footprint that overlaps unmasked pixels. 1.0 for a fully unmasked source, < 1 if pixels are masked or off-image.

stdpipe.photometry_quality.compute_fracflux(impsf_stack, im_stack, psf_stack, weight_stack)[source]

Per-source fraction-of-flux metric.

fracflux = sum(impsf * (W > 0) * P_normed) / sum(im * (W > 0) * P_normed)

Approaches 1 for an isolated source whose neighbours have been cleanly subtracted, and drops below 1 when nearby sources contribute flux at the target’s PSF footprint. Useful as a crowding / blendiness indicator.

stdpipe.photometry_quality.compute_spread_model(impsf_stack, psf_stack, weight_stack, fwhm=None)[source]

Per-source spread_model star/galaxy classifier (and its uncertainty).

Equivalent to SExtractor’s spread_model and to crowdsource_base.spread_model. Convolves each PSF with a tiny exponential galaxy (re = fwhm / 16 * 1.6783) and compares the data’s similarity to PSF vs PSF-convolved-galaxy. Returns (spread, dspread): a star yields spread ~ 0, an extended source spread > 0.

If fwhm is None it is estimated per-source from the PSF stamp via neff_fwhm().

stdpipe.photometry_quality.compute_psf_quality(impsf_stack, im_stack, psf_stack, weight_stack, fwhm=None)[source]

Convenience wrapper: returns dict with qf, fracflux, spread_model, and dspread_model for each source in the input stacks.