File simpleShape.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 extensions
namespace simpleShape
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

Private Members

Control _ctrl
SimpleShapeResultKey _resultKey
lsst::meas::base::SafeCentroidExtractor _centroidExtractor
class SimpleShapeControl
#include <simpleShape.h>

A C++ control class to handle SdssShapeAlgorithm’s configuration.

Public Functions

lsst::meas::extensions::simpleShape::SimpleShapeControl::LSST_CONTROL_FIELD(sigma, double, "Sigma of circular Gaussian used as weight function, in pixels")
lsst::meas::extensions::simpleShape::SimpleShapeControl::LSST_CONTROL_FIELD(nSigmaRegion, double, "Maximum radius for pixels to include, in units of sigma")
SimpleShapeControl()
class SimpleShapeResult
#include <simpleShape.h>

Struct to hold the results of SimpleShape when we don’t run it as a plugin.

Public Functions

bool getFlag(int index) const
SimpleShapeResult()

Constructor; initializes everything to Nan.

Public Members

afw::geom::ellipses::Quadrupole ellipse

Measured second moments.

geom::Point2D center

Measured first moments, or the input center if !recentroid.

Eigen::Matrix<double, 5, 5> covariance

Matrix of uncertainties; ordered Ixx, Iyy, Ixy, Ix, Iy.

std::bitset<SimpleShape::N_FLAGS> flags
class SimpleShapeResultKey : public lsst::afw::table::FunctorKey<SimpleShapeResult>

Unnamed Group

bool operator==(SimpleShapeResultKey const &other) const

Compare the FunctorKey for equality with another, using the underlying Keys.

bool operator!=(SimpleShapeResultKey const &other) const

Public Functions

SimpleShapeResultKey()
SimpleShapeResultKey(lsst::afw::table::SubSchema const &s)

Construct from a subschema, assuming _xx, _yy, etc. subfields.

If a schema has “a_xx”, “a_yy”, etc. fields, this constructor allows you to construct a SimpleShapeResultKey via:

SimpleShapeResultKey k(schema["a"]);

virtual SimpleShapeResult get(afw::table::BaseRecord const &record) const
virtual void set(afw::table::BaseRecord &record, SimpleShapeResult const &value) const
bool isValid() const

Return True if the key is valid.

lsst::meas::base::FlagHandler const &getFlagHandler() const

Public Static Functions

static SimpleShapeResultKey addFields(afw::table::Schema &schema, std::string const &name)

Private Members

lsst::afw::table::QuadrupoleKey _shapeResult
lsst::afw::table::Point2DKey _centroidResult
lsst::afw::table::CovarianceMatrixKey<double, 5> _uncertantyResult
lsst::meas::base::FlagHandler _flagHandler