LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
Utility class for handling flag fields that indicate the failure modes of an algorithm. More...
#include <FlagHandler.h>
Public Member Functions | |
FlagHandler () | |
Each error should have a corresponding static FlagDefinition object. More... | |
FlagHandler (afw::table::SubSchema const &s, FlagDefinitionList const &flagDefs, FlagDefinitionList const &exclDefs=FlagDefinitionList::getEmptyList()) | |
Construct a FlagHandler to manage fields already added to a schema. More... | |
unsigned int | getFlagNumber (std::string const &flagName) const |
Return the index of a flag with the given flag name. More... | |
std::string | getFlagName (std::size_t i) const |
Return the value of the flag name corresponding to the given flag index. More... | |
bool | getValue (afw::table::BaseRecord const &record, std::size_t i) const |
Return the value of the flag field corresponding to the given flag index. More... | |
bool | getValue (afw::table::BaseRecord const &record, std::string const &flagName) const |
Return the value of the flag field with the given flag name. More... | |
void | setValue (afw::table::BaseRecord &record, std::size_t i, bool value) const |
Set the flag field corresponding to the given flag index. More... | |
void | setValue (afw::table::BaseRecord &record, std::string const &flagName, bool value) const |
Set the flag field corresponding to the given flag name. More... | |
std::size_t | getFailureFlagNumber () const |
Get the index of the General Failure flag, if one is defined. More... | |
void | handleFailure (afw::table::BaseRecord &record, MeasurementError const *error=nullptr) const |
Handle an expected or unexpected Exception thrown by a measurement algorithm. More... | |
Static Public Member Functions | |
static std::string const & | getFailureFlagName () |
Define the universal name of the general failure flag. More... | |
static FlagHandler | addFields (afw::table::Schema &schema, std::string const &prefix, FlagDefinitionList const &flagDefs, FlagDefinitionList const &exclDefs=FlagDefinitionList::getEmptyList()) |
Add Flag fields to a schema, creating a FlagHandler object to manage them. More... | |
Public Attributes | |
std::size_t | failureFlagNumber |
Utility class for handling flag fields that indicate the failure modes of an algorithm.
The typical pattern for using FlagHandler within an Algorithm is:
See PsfFluxAlgorithm for a complete example.
Definition at line 148 of file FlagHandler.h.
|
inline |
Each error should have a corresponding static FlagDefinition object.
In the Algorithm header file, this will be defined like this:
static FlagDefinition const & FAILURE; static FlagDefinition const & SOME_OTHER_FAILURE_MODE; ...
A static FlagDefinitionList is created in the Algorithm .cc file, like this:
FlagDefinitionList flagDefinitions; FlagDefinition const FAILURE = flagDefinitions.addFailureFlag(); FlagDefinition const FAILURE_MODE = flagDefinitions.add("flag_mode", "Specific failure flag");
Default constructor for delayed initialization.
This constructor creates an invalid, unusable FlagHandler in the same way a const_iterator default constructor constructs an invalid const_iterator. Its only purpose is to delay construction of the FlagHandler from an Algorithm constructor's initializer list to the constructor body, which can be necessary when the list of possible flags depends on the algorithm's configuration. To use this constructor to delay initialization, simply use it in the initializer list, and then assign the result of a call to addFields() to the FlagHandler data member later in the constructor.
Definition at line 176 of file FlagHandler.h.
lsst::meas::base::FlagHandler::FlagHandler | ( | afw::table::SubSchema const & | s, |
FlagDefinitionList const & | flagDefs, | ||
FlagDefinitionList const & | exclDefs = FlagDefinitionList::getEmptyList() |
||
) |
Construct a FlagHandler to manage fields already added to a schema.
This is primarily intended for use by forced measurement algorithms that need to parse the flags of the single-frame measurement algorithms providing their reference parameters.
[in] | A | SubSchema object that holds the fields to extract and their namespace. Obtainable from the arguments to addFields() as "schema[prefix]". |
[in] | flagDefs | Reference to a FlagDefinitionList |
[in] | exclDefs | optional FlagDefinitionList of flags to exclude |
As with addFields(), pointers must be valid only for the duration of this constructor call.
Definition at line 58 of file FlagHandler.cc.
|
static |
Add Flag fields to a schema, creating a FlagHandler object to manage them.
This is the way FlagHandlers will typically be constructed for new algorithms.
[out] | schema | Schema to which fields should be added. |
[in] | prefix | String name of the algorithm or algorithm component. Field names will be constructed by using schema.join() on this and the flag name from the FlagDefinition array. |
[in] | flagDefs | Reference to a FlagDefinitionList |
[in] | exclDefs | optional FlagDefinitionList of flags to exclude |
If the set of flags depends on the algorithm configuration, a flag may be excluded from the schema using the optional exclDefs parameter. This can be specified using an initializer_list, as in: _flagHandler = FlagHandler::addFields(schema, prefix, flagDefs, {NO_PSF})
Definition at line 37 of file FlagHandler.cc.
|
inlinestatic |
Define the universal name of the general failure flag.
Definition at line 181 of file FlagHandler.h.
|
inline |
Get the index of the General Failure flag, if one is defined.
This flag is defined by most algorithms, and if defined, is set whenever an error is caught by the FlagHandler. If no General Failure flag is defined, this routine will return FlagDefinition::number_undefined
Definition at line 286 of file FlagHandler.h.
|
inline |
Return the value of the flag name corresponding to the given flag index.
Definition at line 233 of file FlagHandler.h.
|
inline |
|
inline |
Return the value of the flag field corresponding to the given flag index.
Definition at line 242 of file FlagHandler.h.
|
inline |
Return the value of the flag field with the given flag name.
Definition at line 251 of file FlagHandler.h.
void lsst::meas::base::FlagHandler::handleFailure | ( | afw::table::BaseRecord & | record, |
MeasurementError const * | error = nullptr |
||
) | const |
Handle an expected or unexpected Exception thrown by a measurement algorithm.
If the exception is expected, it should inherit from MeasurementError and can be passed here; this allows handleFailure to extract the failure mode enum value from the exception and set the corresponding flag. The general failure flag will be set regardless of whether the "error" argument is nullptr (which happens when an unexpected error occurs).
Definition at line 76 of file FlagHandler.cc.
|
inline |
Set the flag field corresponding to the given flag index.
Definition at line 262 of file FlagHandler.h.
|
inline |
Set the flag field corresponding to the given flag name.
Definition at line 272 of file FlagHandler.h.
std::size_t lsst::meas::base::FlagHandler::failureFlagNumber |
Definition at line 297 of file FlagHandler.h.