File FlagHandler.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 base
struct FlagDefinition
#include <FlagHandler.h>

Simple class used to define and document flags The name and doc constitute the identity of the FlagDefinition The number is used for indexing, but is assigned arbitrarily.

Public Functions

FlagDefinition()
FlagDefinition(std::string const &name, std::string const &doc, std::size_t number = number_undefined)
bool operator==(FlagDefinition const &other) const
bool operator!=(FlagDefinition const &other) const

Public Members

std::string name
std::string doc
std::size_t number

Public Static Attributes

constexpr std::size_t number_undefined = SIZE_MAX
class FlagDefinitionList
#include <FlagHandler.h>

vector-type utility class to build a collection of FlagDefinitions

Public Functions

FlagDefinitionList()

initialize a FlagDefinition list with no entries.

FlagDefinitionList(std::initializer_list<FlagDefinition> const &list)

initialize a FlagDefinition list from initializer_list.

FlagDefinition getDefinition(std::size_t index) const

get a reference to the FlagDefinition with specified index.

FlagDefinition getDefinition(std::string const &name) const

get a reference to the FlagDefinition with specified name.

FlagDefinition operator[](std::size_t index) const

get a reference to the FlagDefinition with specified array index

bool hasDefinition(std::string const &name) const

See if there is a FlagDefinition with specified name.

FlagDefinition addFailureFlag(std::string const &doc = "General Failure Flag")

Add a Flag Defintion to act as a “General” failure flag This flag will be set if a Measurement error is thrown.

FlagDefinition add(std::string const &name, std::string const &doc)

Add a new FlagDefinition to this list. Return a copy with the FlagDefinition.number set corresponding to its index in the list.

std::size_t size() const

return the current size (number of defined elements) of the collection

Public Static Functions

static FlagDefinitionList const &getEmptyList()

Private Members

std::vector<FlagDefinition> _vector
class FlagHandler
#include <FlagHandler.h>

Utility class for handling flag fields that indicate the failure modes of an algorithm.

The typical pattern for using FlagHandler within an Algorithm is:

  • Add a FlagHandler object as a data member.

  • Create a FlagDefinitionList to specify the name and doc for each flag Add a “general” failure flag if one is needed (this indicates that some failure occurred). Add specific error flags for each type of error (these indicate a specific failure).

  • Initialize the FlagHandler data member within the Algorithm’s constructor, using the static addFields method to add the flags from the FlagDefinitionList to the schema.

See PsfFluxAlgorithm for a complete example.

Public Functions

FlagHandler()

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.

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.

As with

addFields(), pointers must be valid only for the duration of this constructor call.
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

unsigned int getFlagNumber(std::string const &flagName) const

Return the index of a flag with the given flag name

std::string getFlagName(std::size_t i) const

Return the value of the flag name corresponding to the given flag index.

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.

bool getValue(afw::table::BaseRecord const &record, std::string const &flagName) const

Return the value of the flag field with the given flag name

void setValue(afw::table::BaseRecord &record, std::size_t i, bool value) const

Set the flag field corresponding to the given flag index.

void setValue(afw::table::BaseRecord &record, std::string const &flagName, bool value) const

Set the flag field corresponding to the given flag name.

std::size_t getFailureFlagNumber() const

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

void 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).

Public Members

std::size_t failureFlagNumber

Public Static Functions

static std::string const &getFailureFlagName()

Define the universal name of the general failure flag

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.

This is the way FlagHandlers will typically be constructed for new algorithms.

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})
Parameters
  • [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

Private Types

typedef std::vector<std::pair<std::string, afw::table::Key<afw::table::Flag>>> Vector

Private Members

Vector _vector