Class CModelAlgorithm

Class Documentation

class CModelAlgorithm

Main public interface class for CModel algorithm.

See CModel Magnitudes for a full description of the algorithm.

This class provides the methods that actually execute the algorithm, and (depending on how it is constructed) holds the Key objects necessary to use SourceRecords for input and output.

Public Types

typedef CModelControl Control

Typedef to the master Control struct.

typedef CModelResult Result

Typedef to the master Result struct.

Public Functions

CModelAlgorithm(std::string const &name, Control const &ctrl, afw::table::Schema &schema)

Construct an algorithm instance and add its fields to the Schema.

All fields needed to write the outputs of a regular, non-forced fit will be added to the given Schema. In addition, keys needed to retrieve the PSF shapelet approximation (assuming the ShapeletPsfApprox plugin has been run) will be extracted from the Schema.

Parameters
  • [in] name: Name of the algorithm used as a prefix for all fields added to the Schema.

  • [in] ctrl: Control object that configures the algorithm.

  • [inout] schema: Schema to which fields will be added, and from which keys for the PSF shapelet approximation will be extacted.

CModelAlgorithm(std::string const &name, Control const &ctrl, afw::table::SchemaMapper &schemaMapper)

Construct an algorithm instance suitable for forced photometry and add its fields to the Schema.

All fields needed to write the outputs of a forced fit will be added to the given SchemaMapper’s output schema. Keys needed to retrieve the reference ellipses for the exp and dev fits will be extracted from the SchemaMapper’s input schema. In addition, keys needed to retrieve the PSF shapelet approximation (assuming the ShapeletPsfApprox plugin has been run) will be extracted from the SchemaMapper’s output schema (note that the ShapeletPsfApprox plugin must be run in forced mode as well, to approximate the measurement image’s PSF rather than the reference image’s PSF, so its outputs are found in the output schema, not the input schema).

Parameters
  • [in] name: Name of the algorithm used as a prefix for all fields added to the Schema.

  • [in] ctrl: Control object that configures the algorithm.

  • [inout] schemaMapper: SchemaMapper containing input (reference) and output schemas.

CModelAlgorithm(Control const &ctrl)

Construct an algorithm instance that cannot use SourceRecords for input/output.

This constructor initializes the algorithm without initializing any of the keys necessary to operate on SourceRecords. As a result, only methods that take inputs directly and return Result objects may be called.

Control const &getControl() const

Return the control object the algorithm was constructed with.

Result apply(afw::image::Exposure<Pixel> const &exposure, shapelet::MultiShapeletFunction const &psf, geom::Point2D const &center, afw::geom::ellipses::Quadrupole const &moments, Scalar approxFlux = -1, Scalar kronRadius = -1, int footprintArea = -1) const

Run the CModel algorithm on an image, supplying inputs directly and returning outputs in a Result.

Parameters
  • [in] exposure: Image to measure. Must have a valid Psf, Wcs and PhotoCalib.

  • [in] psf: multi-shapelet approximation to the PSF at the position of the source

  • [in] center: Centroid of the source to be fit.

  • [in] moments: Non-PSF-corrected moments of the source, used to initialize the model parameters

  • [in] approxFlux: Rough estimate of the flux of the source, used to set the fit coordinate system and ensure internal parameters are of order unity. If less than or equal to zero, the sum of the flux within the footprint will be used.

  • [in] kronRadius: Estimate of the Kron radius (optional); used as the first choice when estimating the region of pixel to include in the fit.

  • [in] footprintArea: Area of the detection Fooptrint; used as the fallback when estimating the region of pixel to include in the fit.

Result applyForced(afw::image::Exposure<Pixel> const &exposure, shapelet::MultiShapeletFunction const &psf, geom::Point2D const &center, Result const &reference, Scalar approxFlux = -1) const

Run the CModel algorithm in forced mode on an image, supplying inputs directly and returning outputs in a Result.

Parameters
  • [in] exposure: Image to measure. Must have a valid Psf, Wcs and PhotoCalib.

  • [in] psf: multi-shapelet approximation to the PSF at the position of the source

  • [in] center: Centroid of the source to be fit.

  • [in] reference: Result object from a previous, non-forced run of CModelAlgorithm.

  • [in] approxFlux: Rough estimate of the flux of the source, used to set the fit coordinate system and ensure internal parameters are of order unity. If less than or equal to zero, the sum of the flux within the footprint will be used.

void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure<Pixel> const &exposure) const

Run the CModel algorithm on an image, using a SourceRecord for inputs and outputs.

To run this method, the

CModelAlgorithm instance must have been created using the constructor that takes a Schema argument, and that Schema must match the Schema of the SourceRecord passed here.
Parameters
  • [inout] measRecord: A SourceRecord instance used to provide a Footprint, the centroid and shape of the source, a MultiShapeletFunction PSF, and an approximate estimate of the (via the PsfFlux slot), and to which all outputs will be written.

  • [in] exposure: Image to be measured. Must have a valid Psf, Wcs, and PhotoCalib.

void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure<Pixel> const &exposure, afw::table::SourceRecord const &refRecord) const

Run the CModel algorithm in forced mode on an image, using a SourceRecord for inputs and outputs.

To run this method, the

CModelAlgorithm instance must have been created using the constructor that takes a Schema argument, and that Schema must match the Schema of the SourceRecord passed here.
Parameters
  • [inout] measRecord: A SourceRecord instance used to provide a Footprint, the centroid of the source, a MultiShapeletFunction PSF, and an approximate estimate of the (via the PsfFlux slot), and to which all outputs will be written.

  • [in] exposure: Image to be measured. Must have a valid Psf, Wcs, and PhotoCalib.

  • [in] refRecord: A SourceRecord that contains the outputs of a previous non-forced run of CModelAlgorithm (which may have taken place on an image with a different Wcs).

void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error) const

Handle an exception thrown by one of the measure() methods, setting the appropriate flag in the given record.

Parameters
  • [out] measRecord: Record on which the flag should be set.

  • [in] error: Error containing the bit to be set. If null, only the general failure bit will be set.

void writeResultToRecord(Result const &result, afw::table::BaseRecord &record) const

Copy values from a Result struct to a BaseRecord object.