File Blendedness.h

namespace lsst

Class for a simple mapping implementing a generic AstrometryTransform.

Remove all non-astronomical counts from the Chunk Exposure’s pixels.

Forward declarations for lsst::utils::Cache

For details on the Cache class, see the Cache.h file.

It uses a template rather than a pointer so that the derived classes can use the specifics of the transform. The class simplePolyMapping overloads a few routines.

A base class for image defects

Numeric constants used by the Integrate.h integrator routines.

Compute Image Statistics

Note

Gauss-Kronrod-Patterson quadrature coefficients for use in quadpack routine qng. These coefficients were calculated with 101 decimal digit arithmetic by L. W. Fullerton, Bell Labs, Nov 1981.

Note

The Statistics class itself can only handle lsst::afw::image::MaskedImage() types. The philosophy has been to handle other types by making them look like lsst::afw::image::MaskedImage() and reusing that code. Users should have no need to instantiate a Statistics object directly, but should use the overloaded makeStatistics() factory functions.

namespace meas
namespace base
class BlendednessAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <Blendedness.h>

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

Private Functions

void _measureMoments(afw::image::MaskedImage<float> const &image, afw::table::SourceRecord &child, afw::table::Key<double> const &instFluxRawKey, afw::table::Key<double> const &instFluxAbsKey, ShapeResultKey const &_shapeRawKey, ShapeResultKey const &_shapeAbsKey) const

Private Members

Control const _ctrl
afw::table::Key<double> _old
afw::table::Key<double> _raw
afw::table::Key<double> _instFluxChildRaw
afw::table::Key<double> _instFluxParentRaw
afw::table::Key<double> _abs
afw::table::Key<double> _instFluxChildAbs
afw::table::Key<double> _instFluxParentAbs
ShapeResultKey _shapeChildRaw
ShapeResultKey _shapeParentRaw
ShapeResultKey _shapeChildAbs
ShapeResultKey _shapeParentAbs
FlagHandler _flagHandler
class BlendednessControl

Public Functions

lsst::meas::base::BlendednessControl::LSST_CONTROL_FIELD(doOld, bool, "Whether to compute HeavyFootprint dot products (the old deblend.blendedness parameter)")
lsst::meas::base::BlendednessControl::LSST_CONTROL_FIELD(doFlux, bool, "Whether to compute quantities related to the Gaussian-weighted flux")
lsst::meas::base::BlendednessControl::LSST_CONTROL_FIELD(doShape, bool, "Whether to compute quantities related to the Gaussian-weighted shape")
lsst::meas::base::BlendednessControl::LSST_CONTROL_FIELD(nSigmaWeightMax, double, "Radius factor that sets the maximum extent of the weight function (and hence the " "flux measurements)")
BlendednessControl()