Class SimpleShape

Inheritance Relationships

Base Type

Class Documentation

class SimpleShape : public lsst::meas::base::SimpleAlgorithm

Public Types

typedef SimpleShapeControl Control

Public Functions

SimpleShape(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
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, lsst::meas::base::MeasurementError *error = NULL) 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 base::FlagDefinitionList const &getFlagDefinitions()
template<typename T>
static SimpleShapeResult computeMoments(afw::geom::ellipses::Ellipse const &weight, afw::image::MaskedImage<T> const &image, double nSigmaRegion = 3.0)

Compute the Gaussian-weighted moments of an image.

Parameters
  • [in] weight: An ellipse object of Gaussian weights to apply to the measurement.

  • [in] image: A Masked image instance with int float or double pixels.

  • [in] nSigmaRegion: Maximum radius for pixels to include, in units of sigma

static Eigen::Matrix<double, 5, 6> convertRawMoments(Eigen::Matrix<double, 6, 1> const &q, afw::geom::ellipses::Quadrupole &quadrupole, geom::Point2D &center)

Convert linear raw moments into an ellipse and centroid, and return the derivative of the conversion.

For weight function

\(w\) and data \(p\), the “raw” moments \(Q\) are defined as:
\[\begin{split}\begin{eqnarray*} Q_0 &=& \sum_n w(x_n, y_n) p_n \\ Q_{xx} &=& \sum_n w(x_n, y_n) x_n^2 p_n \\ Q_{yy} &=& \sum_n w(x_n, y_n) y_n^2 p_n \\ Q_{xy} &=& \sum_n w(x_n, y_n) x_n y_n p_n \\ Q_x &=& \sum_n w(x_n, y_n) x_n p_n \\ Q_y &=& \sum_n w(x_n, y_n) y_n p_n \end{eqnarray*}\end{split}\]
whereas the converted ellipse and centroid moments are:
\[\begin{split}\begin{eqnarray*} M_{xx} &=& Q_{xx} / Q_0 - Q_x^2 \\ M_{xx} &=& Q_{yy} / Q_0 - Q_y^2 \\ M_{xx} &=& Q_{xy} / Q_0 - Q_x Q_y \\ M_x &=& Q_x / Q_0 \\ M_y &=& Q_y / Q_0 \end{eqnarray*}\end{split}\]
Note

This function is mainly intended for internal use, and is only exposed publically so it can be unit-tested in Python.

Note the slightly unusual ordering; this is for consistency with afw::geom::ellipses::Ellipse.

static Eigen::Matrix<double, 5, 5> correctWeightedMoments(afw::geom::ellipses::Quadrupole const &weight, afw::geom::ellipses::Quadrupole &ellipse, geom::Point2D &center)

Correct moments measured with a Gaussian weight function by assuming the data was also an elliptical Gaussian, and return the derivative of the correction.

If we naively measure Gaussian-weighted moments, we’ll measure the moments of the product of the weight function and the data. What we want is the moments of the data, as if we had measured them with no weight function (but without sacrificing the S/N benefit that comes from using a weight function). To do that, we assume the data is also an elliptical Gaussian, and “divide” the weight function from the measured moments to compute it.

Note

This function is mainly intended for internal use, and is only exposed publically so it can be unit-tested in Python.

If \(W\) and \(M\) are the quadruple matrices of the weight function and measurement, and \(\eta\) is the measured centroid (we work in a coordinate system where the weight function is centered at the origin), then the corrected quadrupole matrix \(C\) and centroid are \(\nu\) are:

\[\begin{split}\begin{eqnarray*} C &=& \left(M^{-1} - W^{-1}\right)^{-1} \\ \nu &=& C M^{-1} \eta \end{eqnarray*}\end{split}\]

Public Static Attributes

unsigned int const N_FLAGS = 1
base::FlagDefinition const FAILURE