Class BlendednessAlgorithm

Inheritance Relationships

Base Type

Class Documentation

class BlendednessAlgorithm : public lsst::meas::base::SimpleAlgorithm

Compute metrics that measure how blended objects are.

Blendedness is initialized once for a given Schema, then run repeatedly by calls to measureChildPixels and measureParentPixels (in any order, possibly with multiple sources interleaved). Since it needs access to both the image with with noise and the noise replaced children it cannot use the standard plugin interface.

Public Types

typedef BlendednessControl Control

Public Functions

BlendednessAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
void measureChildPixels(afw::image::MaskedImage<float> const &image, afw::table::SourceRecord &child) const
void measureParentPixels(afw::image::MaskedImage<float> const &image, afw::table::SourceRecord &child) const
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure<float> const &exposure) const

Called to measure a single child source in an image.

Before this method is called, all neighbors will be replaced with noise, using the outputs of the deblender. Outputs should be saved in the given SourceRecord, which can also be used to obtain centroid (see SafeCentroidExtractor) and shape (see SafeShapeExtractor) information.

virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error = nullptr) const

Handle an exception thrown by the current algorithm by setting flags in the given record.

fail() is called by the measurement framework when an exception is allowed to propagate out of one the algorithm’s measure() methods. It should generally set both a general failure flag for the algorithm as well as a specific flag indicating the error condition, if possible. To aid in this, if the exception was an instance of MeasurementError, it will be passed in, carrying information about what flag to set.

An algorithm can also to chose to set flags within its own measure() methods, and then just return, rather than throw an exception. However, fail() should be implemented even when all known failure modes do not throw exceptions, to ensure that unexpected exceptions thrown in lower-level code are properly handled.

Public Static Functions

static FlagDefinitionList const &getFlagDefinitions()
static float computeAbsExpectation(float data, float variance)

Compute the posterior expectation value of the true instrumental flux in a pixel from its (Gaussian) likelihood and a flat nonnegative prior.

This computes

\[ \frac{\int_0^\infty f \frac{1}{\sqrt{2\pi}\sigma} e^{-\frac{(f-z)^2}{2\sigma^2}} df} {\int_0^\infty \frac{1}{\sqrt{2\pi}\sigma} e^{-\frac{(f-z)^2}{2\sigma^2}} df} \]
where \(z\) is the (noisy) pixel value and \(\sigma^2\) is the pixel variance. This approaches \(z\) when \(z \gg \sigma\) and \(0\) when \(z \ll -\sigma\).

We use single precision here for performance reasons; this function is called in a loop over single-precision pixels, and relies on a number of calls to exp and erfc, which are much faster in single precision.

static float computeAbsBias(float mu, float variance)

Compute the bias induced by using the absolute value of a pixel instead of its value.

The computation assumes the true distribution for the pixel is a Gaussian with mean mu and the given variance. To compute mu from the data, use computeAbsExpectation.

This computes

\[ \sqrt{\frac{2}{\pi}}\sigma e^{-\frac{\mu^2}{2\sigma^2}} - \mu\,\mathrm{erfc}\left(\frac{\mu}{\sqrt{2}\sigma}\right) \]
where \(\mu\) is the mean of the underlying distribution and \(\sigma^2\) is its variance. See section 4.9.11 of Bosch, J. et al. 2018, PASJ, 70, S5 for further details.

Public Static Attributes

FlagDefinition const FAILURE
FlagDefinition const NO_CENTROID
FlagDefinition const NO_SHAPE