LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Attributes | List of all members
lsst::meas::base::PixelFlagsAlgorithm Class Reference

A measurement algorithm that gets mask bits from the exposure and sets flag bits to summarize which bits are set within a source's footprint. More...

#include <PixelFlags.h>

Inheritance diagram for lsst::meas::base::PixelFlagsAlgorithm:
lsst::meas::base::SimpleAlgorithm lsst::meas::base::SingleFrameAlgorithm lsst::meas::base::ForcedAlgorithm lsst::meas::base::BaseAlgorithm lsst::meas::base::BaseAlgorithm

Public Types

enum  {
  FAILURE =FlagHandler::FAILURE, EDGE, INTERPOLATED, INTERPOLATED_CENTER,
  SATURATED, SATURATED_CENTER, CR, CR_CENTER,
  BAD, N_FLAGS
}
 Flag bits to be used with the 'flags' data member of the Result object. More...
 
typedef PixelFlagsControl Control
 

Public Member Functions

 PixelFlagsAlgorithm (Control const &ctrl, std::string const &name, afw::table::Schema &schema)
 
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
 
- Public Member Functions inherited from lsst::meas::base::SimpleAlgorithm
virtual void measureForced (afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure, afw::table::SourceRecord const &refRecord, afw::image::Wcs const &refWcs) const
 
virtual void measureNForced (afw::table::SourceCatalog const &measCat, afw::image::Exposure< float > const &exposure, afw::table::SourceCatalog const &refRecord, afw::image::Wcs const &refWcs) const
 
- Public Member Functions inherited from lsst::meas::base::SingleFrameAlgorithm
virtual void measureN (afw::table::SourceCatalog const &measCat, afw::image::Exposure< float > const &exposure) const
 
- Public Member Functions inherited from lsst::meas::base::BaseAlgorithm
virtual ~BaseAlgorithm ()
 

Private Attributes

Control _ctrl
 
FlagHandler _flagHandler
 
SafeCentroidExtractor _centroidExtractor
 

Detailed Description

A measurement algorithm that gets mask bits from the exposure and sets flag bits to summarize which bits are set within a source's footprint.

Definition at line 59 of file PixelFlags.h.

Member Typedef Documentation

A typedef to the Control object for this algorithm, defined above. The control object contains the configuration parameters for this algorithm.

Definition at line 82 of file PixelFlags.h.

Member Enumeration Documentation

anonymous enum

Constructor & Destructor Documentation

lsst::meas::base::PixelFlagsAlgorithm::PixelFlagsAlgorithm ( Control const &  ctrl,
std::string const &  name,
afw::table::Schema schema 
)

Definition at line 61 of file PixelFlags.cc.

65  : _ctrl(ctrl),
67 {
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"}
78  }};
79  _flagHandler = FlagHandler::addFields(schema, name, flagDefs.begin(), flagDefs.end());
80 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
afw::table::Schema schema
Definition: GaussianPsf.cc:41
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinition const *begin, FlagDefinition const *end)
Definition: FlagHandler.cc:28
SafeCentroidExtractor _centroidExtractor
Definition: PixelFlags.h:100

Member Function Documentation

void lsst::meas::base::PixelFlagsAlgorithm::fail ( afw::table::SourceRecord measRecord,
MeasurementError error = NULL 
) const
virtual

Handle an exception thrown by the current algorithm by setting flags in the given record.

fail() is called by the measurement framework when an exception is allowed to propagate out of one the algorithm's measure() methods. It should generally set both a general failure flag for the algorithm as well as a specific flag indicating the error condition, if possible. To aid in this, if the exception was an instance of MeasurementError, it will be passed in, carrying information about what flag to set.

An algorithm can also to chose to set flags within its own measure() methods, and then just return, rather than throw an exception. However, fail() should be implemented even when all known failure modes do not throw exceptions, to ensure that unexpected exceptions thrown in lower-level code are properly handled.

Implements lsst::meas::base::BaseAlgorithm.

Definition at line 139 of file PixelFlags.cc.

139  {
140  _flagHandler.handleFailure(measRecord, error);
141 }
def error
Definition: log.py:108
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=NULL) const
Definition: FlagHandler.cc:59
void lsst::meas::base::PixelFlagsAlgorithm::measure ( afw::table::SourceRecord measRecord,
afw::image::Exposure< float > const &  exposure 
) const
virtual

Called to measure a single child source in an image.

Before this method is called, all neighbors will be replaced with noise, using the outputs of the deblender. Outputs should be saved in the given SourceRecord, which can also be used to obtain centroid (see SafeCentroidExtractor) and shape (see SafeShapeExtractor) information.

Implements lsst::meas::base::SingleFrameAlgorithm.

Definition at line 82 of file PixelFlags.cc.

85  {
86 
88  typedef afw::image::MaskedImage<float> MaskedImageT;
89  MaskedImageT mimage = exposure.getMaskedImage();
90 
91  FootprintBits<MaskedImageT> func(mimage);
92 
93 // Catch NAN in centroid estimate
94  if (lsst::utils::isnan(center.getX()) || lsst::utils::isnan(center.getY())) {
95  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
96  "Center point passed to PixelFlagsALgorithm is NaN");
97  }
98 // Catch centroids off the image
99  if (!mimage.getBBox().contains(afw::geom::Point2I(center))) {
100  _flagHandler.setValue(measRecord, EDGE, true);
101  }
102  // Check for bits set in the source's Footprint
103  afw::detection::Footprint const & footprint(*measRecord.getFootprint());
104  func.apply(footprint);
105  if (func.getBits() & (MaskedImageT::Mask::getPlaneBitMask("EDGE") |
106  MaskedImageT::Mask::getPlaneBitMask("NO_DATA"))) {
107  _flagHandler.setValue(measRecord, EDGE, true);
108  }
109  if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask("BAD")) {
110  _flagHandler.setValue(measRecord, BAD, true);
111  }
112  if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask("INTRP")) {
113  _flagHandler.setValue(measRecord, INTERPOLATED, true);
114  }
115  if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask("SAT")) {
116  _flagHandler.setValue(measRecord, SATURATED, true);
117  }
118  if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask("CR")) {
119  _flagHandler.setValue(measRecord, CR, true);
120  }
121 
122  // Check for bits set in the 3x3 box around the center
123  afw::geom::Point2I llc(afw::image::positionToIndex(center.getX())-1, afw::image::positionToIndex(center.getY()) - 1);
124 
125  afw::detection::Footprint const middle(afw::geom::BoxI(llc, afw::geom::ExtentI(3))); // central 3x3
126  func.apply(middle);
127  if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask("INTRP")) {
128  _flagHandler.setValue(measRecord, INTERPOLATED_CENTER, true);
129  }
130  if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask("SAT")) {
131  _flagHandler.setValue(measRecord, SATURATED_CENTER, true);
132  }
133  if (func.getBits() & MaskedImageT::Mask::getPlaneBitMask("CR")) {
134  _flagHandler.setValue(measRecord, CR_CENTER, true);
135  }
136  _flagHandler.setValue(measRecord, FAILURE, false);
137 }
int positionToIndex(double pos)
Convert image position to nearest integer index.
Definition: ImageUtils.h:69
Box2I BoxI
Definition: Box.h:479
Point< double, 2 > Point2D
Definition: Point.h:286
Point< int, 2 > Point2I
Definition: Point.h:283
int isnan(T t)
Definition: ieee.h:110
void setValue(afw::table::BaseRecord &record, int i, bool value) const
Definition: FlagHandler.h:72
Extent< int, 2 > ExtentI
Definition: Extent.h:352
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
lsst::afw::detection::Footprint Footprint
Definition: Source.h:61
SafeCentroidExtractor _centroidExtractor
Definition: PixelFlags.h:100

Member Data Documentation

SafeCentroidExtractor lsst::meas::base::PixelFlagsAlgorithm::_centroidExtractor
private

Definition at line 100 of file PixelFlags.h.

Control lsst::meas::base::PixelFlagsAlgorithm::_ctrl
private

Definition at line 98 of file PixelFlags.h.

FlagHandler lsst::meas::base::PixelFlagsAlgorithm::_flagHandler
private

Definition at line 99 of file PixelFlags.h.


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