28 #include "ndarray/eigen.h" 36 namespace lsst {
namespace meas {
namespace base {
38 template <
typename MaskedImageT>
41 explicit FootprintBits() : _bits(0) {}
49 typename MaskedImageT::Mask::Pixel
const & value) {
54 typename MaskedImageT::Mask::Pixel getBits()
const {
return _bits; }
56 typename MaskedImageT::Mask::Pixel _bits;
59 typedef afw::image::MaskedImage<float> MaskedImageF;
62 afw::table::SourceRecord & measRecord) {
63 for (
auto const & i: maskFlagToPixelFlag) {
65 if (func.getBits() & MaskedImageF::Mask::getPlaneBitMask(i.first)) {
66 measRecord.set(i.second,
true);
69 catch (pex::exceptions::InvalidParameterError & err) {
82 _generalFailureKey = schema.
addField<afw::table::Flag>(name +
"_flag",
83 "general failure flag, set if anything went wring");
84 _offImageKey = schema.
addField<afw::table::Flag>(name+
"_flag" +
"_offimage",
85 "Source center is off image");
87 _anyKeys[
"EDGE"] = schema.
addField<afw::table::Flag>(name +
"_flag_edge",
88 "Source is outside usable exposure region (masked EDGE or NO_DATA)");
89 _anyKeys[
"INTRP"] = schema.
addField<afw::table::Flag>(name +
"_flag_interpolated",
90 "Interpolated pixel in the Source footprint");
91 _anyKeys[
"SAT"] = schema.
addField<afw::table::Flag>(name +
"_flag_saturated",
92 "Saturated pixel in the Source footprint");
93 _anyKeys[
"CR"] = schema.
addField<afw::table::Flag>(name +
"_flag_cr",
94 "Cosmic ray in the Source footprint");
95 _anyKeys[
"BAD"] = schema.
addField<afw::table::Flag>(name +
"_flag_bad",
96 "Bad pixel in the Source footprint");
97 _anyKeys[
"SUSPECT"] = schema.
addField<afw::table::Flag>(name +
"_flag_suspect",
98 "Source's footprint includes suspect pixels");
100 _centerKeys[
"INTRP"] = schema.
addField<afw::table::Flag>(name +
"_flag_interpolatedCenter",
101 "Interpolated pixel in the Source center");
102 _centerKeys[
"SAT"] = schema.
addField<afw::table::Flag>(name +
"_flag_saturatedCenter",
103 "Saturated pixel in the Source center");
104 _centerKeys[
"CR"] = schema.
addField<afw::table::Flag>(name +
"_flag_crCenter",
105 "Cosmic ray in the Source center");
106 _centerKeys[
"SUSPECT"] = schema.
addField<afw::table::Flag>(name +
"_flag_suspectCenter",
107 "Source's center is close to suspect pixels");
113 _centerKeys[i] = schema.
addField<afw::table::Flag>(name +
"_flag_" + maskName +
"Center",
114 "Source center is close to "+ i +
" pixels");
120 _anyKeys[i] = schema.
addField<afw::table::Flag>(name +
"_flag_" + maskName,
121 "Source footprint includes " + i +
" pixels");
131 FootprintBits<MaskedImageF> func;
135 if (measRecord.
getTable()->getCentroidKey().isValid()) {
140 "Center point passed to PixelFlagsAlgorithm is NaN");
146 measRecord.
set(_generalFailureKey,
true);
155 if (!footprint || footprint->getPeaks().empty()) {
159 center.setX(footprint->getPeaks().front().getFx());
160 center.setY(footprint->getPeaks().front().getFy());
166 measRecord.
set(_offImageKey,
true);
167 measRecord.
set(_anyKeys.
at(
"EDGE"),
true);
172 footprint.
getSpans()->clippedTo(mimage.getBBox())->applyFunctor(func, *(mimage.getMask()));
176 if (func.getBits() & MaskedImageF::Mask::getPlaneBitMask(
"NO_DATA")) {
177 measRecord.
set(_anyKeys.
at(
"EDGE"),
true);
184 updateFlags(_anyKeys, func, measRecord);
193 middle.getSpans()->clippedTo(mimage.getBBox())->applyFunctor(func, *(mimage.getMask()));
196 updateFlags(_centerKeys, func, measRecord);
201 measRecord.
set(_generalFailureKey,
true);
int positionToIndex(double pos)
std::map< std::string, afw::table::Key< afw::table::Flag > > KeyMap
std::shared_ptr< Footprint > getFootprint() const
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Exception to be thrown when a measurement algorithm experiences a fatal error.
MaskedImageT getMaskedImage()
std::shared_ptr< SourceTable const > getTable() const
PixelFlagsAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=nullptr) const
Handle an exception thrown by the current algorithm by setting flags in the given record...
#define LSST_EXCEPT(type,...)
virtual char const * what(void) const
A C++ control class to handle PixelFlagsAlgorithm's configuration.
std::vector< std::string > masksFpCenter
"List of mask planes to be searched for which occur in the center of a footprint. " "If any of the pl...
void set(Key< T > const &key, U const &value)
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Called to measure a single child source in an image.
This is the algorithm for PixelFlags.
std::vector< std::string > masksFpAnywhere
"List of mask planes to be searched for which occur anywhere within a footprint. " "If any of the pla...
Key< T > addField(Field< T > const &field, bool doReplace=false)
CentroidSlotDefinition::MeasValue getCentroid() const