lsst.meas.base  21.0.0-12-gbc0a1a5+358ec59a0b
Public Member Functions | List of all members
lsst::meas::base::SafeCentroidExtractor Class Reference

Utility class for measurement algorithms that extracts a position from the Centroid slot and handles errors in a safe and consistent way. More...

#include <InputUtilities.h>

Public Member Functions

 SafeCentroidExtractor (afw::table::Schema &schema, std::string const &name, bool isCentroider=false)
 Construct the extractor, creating a flag alias that indicates failure in the input centroid by linking to the slot centroid flag. More...
 
geom::Point2D operator() (afw::table::SourceRecord &record, FlagHandler const &flags) const
 Extract a position from the given record. More...
 

Detailed Description

Utility class for measurement algorithms that extracts a position from the Centroid slot and handles errors in a safe and consistent way.

Definition at line 39 of file InputUtilities.h.

Constructor & Destructor Documentation

◆ SafeCentroidExtractor()

lsst::meas::base::SafeCentroidExtractor::SafeCentroidExtractor ( afw::table::Schema schema,
std::string const &  name,
bool  isCentroider = false 
)

Construct the extractor, creating a flag alias that indicates failure in the input centroid by linking to the slot centroid flag.

Parameters
[out]schemaSchema to which the alias should be added. The "slot_Centroid" alias must already be present in the Schema's AliasMap.
[in]nameThe name of the algorithm; the flag alias added will be "<name>_flag_badCentroid", or "<name>_flag_badInitialCentroid" if isCentroider=true.
[in]isCentroiderIndicates whether the calling algorithm is itself a centroid measurement algorithm. If true,, falling back to the Peak because there was no previous centroider or a previous centroider failed will not cause the general failure flag of the current algorithm to be set.

Definition at line 35 of file InputUtilities.cc.

Member Function Documentation

◆ operator()()

geom::Point2D lsst::meas::base::SafeCentroidExtractor::operator() ( afw::table::SourceRecord record,
FlagHandler const &  flags 
) const

Extract a position from the given record.

We use the Centroid slot if it is not NaN, and fall back to the Peak on the Footprint otherwise.

If the Centroid slot is not defined, we throw FatalAlgorithmError, as this indicates a configuration problem.

If the Centroid slot value is NaN and is not flagged (or there is no Centroid slot flag), we throw RuntimeError, which should cause the measurement framework to log a warning and set the current algorithm's general failure flag if it is allowed to propagate out of the algorithm implementation.

If the Centroid slot is NaN and there is no Footprint or Peak (even if the centroid is flagged), we also throw RuntimeError, as this indicates something wrong in another stage of the pipeline that should be addressed before measurement is run.

If the Centroid slot is flagged and we nevertheless obtain a usable position (either from a the Centroid slot itself or from a successful fall-back to the Peak), we set the current algorithm's general failure flag, but return the position as well, allowing it to continue while indicating that the result may not be reliable.

Definition at line 84 of file InputUtilities.cc.


The documentation for this class was generated from the following files: