34 namespace lsst {
namespace meas {
namespace base {
36 FlagDefinitionList flagDefinitions;
41 "no good pixels in the annulus");
46 return flagDefinitions;
56 _resultKey(
FluxResultKey::addFields(schema, name,
"background in annulus around source")),
58 _centroidExtractor(schema, name),
59 _stats(ctrl.bgRej, ctrl.bgIter)
76 auto const psf = exposure.
getPsf();
80 float const psfSigma = psf->computeShape().getDeterminantRadius();
90 auto const& annulus = outer->clippedTo(image.
getBBox())->intersectNot(*inner);
91 auto const& imageValues = annulus->flatten(image.
getImage()->getArray(), image.
getXY0());
92 auto const& maskValues = annulus->flatten(image.
getMask()->getArray(), image.
getXY0());
96 values.
reserve(imageValues.getNumElements());
97 assert(imageValues.getNumElements() == maskValues.getNumElements());
98 auto maskIter = maskValues.begin();
99 for (
auto imageIter = imageValues.begin(); imageIter != imageValues.end(); ++imageIter, ++maskIter) {
100 if ((*maskIter & badMask) == 0) {
105 if (values.
size() == 0) {
112 measRecord.
set(_resultKey, result);
130 if (flag == LocalBackgroundAlgorithm::FAILURE)
continue;
131 if (mapper.getInputSchema().getNames().count(
132 mapper.getInputSchema().join(
name, flag.
name)) == 0)
continue;
135 mapper.addMapping(key);
std::size_t size() const
return the current size (number of defined elements) of the collection
Configuration of LocalBackgroundAlgorithm.
static std::shared_ptr< geom::SpanSet > fromShape(int r, Stencil s=Stencil::CIRCLE, Point2I offset=Point2I())
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Called to measure a single child source in an image.
float annulusInner
"Inner radius for background annulus as a multiple of the PSF sigma" ;
std::vector< std::string > badMaskPlanes
"Mask planes that indicate pixels that should be excluded from the measurement" ; ...
Exception to be thrown when a measurement algorithm experiences a known failure mode.
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
ImagePtr getImage() const
Utility class for handling flag fields that indicate the failure modes of an algorithm.
float annulusOuter
"Outer radius for background annulus as a multiple of the PSF sigma" ;
MaskedImageT getMaskedImage()
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
static FlagDefinition const NO_GOOD_PIXELS
A FunctorKey for FluxResult.
static FlagDefinitionList const & getFlagDefinitions()
#define LSST_EXCEPT(type,...)
LocalBackgroundAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema, std::string const &logName="")
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...
std::shared_ptr< lsst::afw::detection::Psf > getPsf()
static FlagDefinition const NO_PSF
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=nullptr) const
Handle an expected or unexpected Exception thrown by a measurement algorithm.
void set(Key< T > const &key, U const &value)
static FlagDefinition const FAILURE
vector-type utility class to build a collection of FlagDefinitions
A reusable result struct for flux measurements.
geom::Point2I getXY0() const