31 namespace lsst {
namespace meas {
namespace base {
34 template <
typename MaskedImageT>
35 class FootprintBits :
public afw::detection::FootprintFunctor<MaskedImageT> {
37 explicit FootprintBits(MaskedImageT
const& mimage) :
38 afw::detection::FootprintFunctor<MaskedImageT>(mimage),
_bits(0)
48 void operator()(
typename MaskedImageT::xy_locator loc,
52 _bits |= loc.mask(0, 0);
56 typename MaskedImageT::Mask::Pixel getBits()
const {
return _bits; }
58 typename MaskedImageT::Mask::Pixel
_bits;
63 std::string
const &
name,
66 _centroidExtractor(schema, name)
68 static boost::array<FlagDefinition,N_FLAGS>
const flagDefs = {{
69 {
"flag",
"general failure flag, set if anything went wrong"},
70 {
"flag_edge",
"Source is outside usable exposure region (masked EDGE or NO_DATA)"},
71 {
"flag_interpolated",
"Interpolated pixel in the source footprint"},
72 {
"flag_interpolatedCenter",
"Interpolated pixel in the source center"},
73 {
"flag_saturated",
"Saturated pixel in the source footprint"},
74 {
"flag_saturatedCenter",
"Saturated pixel in the source center"},
75 {
"flag_cr",
"Cosmic ray in the source footprint"},
76 {
"flag_crCenter",
"Cosmic ray in the source center"},
77 {
"flag_bad",
"Bad pixel in the source footprint"}
91 FootprintBits<MaskedImageT> func(mimage);
95 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
96 "Center point passed to PixelFlagsALgorithm is NaN");
104 func.apply(footprint);
105 if (func.getBits() & (MaskedImageT::Mask::getPlaneBitMask(
"EDGE") |
106 MaskedImageT::Mask::getPlaneBitMask(
"NO_DATA"))) {
109 if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask(
"BAD")) {
112 if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask(
"INTRP")) {
115 if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask(
"SAT")) {
118 if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask(
"CR")) {
127 if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask(
"INTRP")) {
130 if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask(
"SAT")) {
133 if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask(
"CR")) {
Defines the fields and offsets for a table.
MaskedImageT getMaskedImage()
Return the MaskedImage.
table::Key< std::string > name
Eigen matrix objects that present a view into an ndarray::Array.
int positionToIndex(double pos)
Convert image position to nearest integer index.
MaskedImageT::Mask::Pixel _bits
lsst::afw::detection::Footprint Footprint
Exception to be thrown when a measurement algorithm experiences a known failure mode.
An integer coordinate rectangle.
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
A class to manipulate images, masks, and variance as a single object.
PixelFlagsAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
void setValue(afw::table::BaseRecord &record, int i, bool value) const
#define LSST_EXCEPT(type,...)
A C++ control class to handle PixelFlagsAlgorithm's configuration.
boost::shared_ptr< Footprint > getFootprint() const
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=NULL) const
Record class that contains measurements made on a single exposure.
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinition const *begin, FlagDefinition const *end)
SafeCentroidExtractor _centroidExtractor