38 FlagDefinitionList flagDefinitions;
43 flagDefinitions.add(
"flag_noGoodPixels",
"no good pixels in the annulus");
51 _resultKey(
FluxResultKey::addFields(schema, name,
"background in annulus around source")),
53 _centroidExtractor(schema, name),
54 _stats(ctrl.bgRej, ctrl.bgIter) {
60 geom::Point2D const center = _centroidExtractor(measRecord, _flagHandler);
70 float const psfSigma =
psf->computeShape().getDeterminantRadius();
80 auto const& annulus = outer->clippedTo(image.
getBBox())->intersectNot(*inner);
81 auto const& imageValues = annulus->flatten(image.
getImage()->getArray(), image.
getXY0());
82 auto const& maskValues = annulus->flatten(image.
getMask()->getArray(), image.
getXY0());
86 values.
reserve(imageValues.getNumElements());
87 assert(imageValues.getNumElements() == maskValues.getNumElements());
88 auto maskIter = maskValues.begin();
89 for (
auto imageIter = imageValues.begin(); imageIter != imageValues.end(); ++imageIter, ++maskIter) {
90 if ((*maskIter & badMask) == 0) {
95 if (values.
size() == 0) {
114 if (flag == LocalBackgroundAlgorithm::FAILURE)
continue;
115 if (
mapper.getInputSchema().getNames().count(
mapper.getInputSchema().join(
name, flag.
name)) == 0)
118 mapper.getInputSchema().find<afw::table::Flag>(
name +
"_" + flag.
name).key;
std::size_t size() const
return the current size (number of defined elements) of the collection
Defines the fields and offsets for a table.
Configuration of LocalBackgroundAlgorithm.
A mapping between the keys of two Schemas, used to copy data between them.
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" ; ...
static std::shared_ptr< geom::SpanSet > fromShape(int r, Stencil s=Stencil::CIRCLE, lsst::geom::Point2I offset=lsst::geom::Point2I())
Factory function for creating SpanSets from a Stencil.
Exception to be thrown when a measurement algorithm experiences a known failure mode.
lsst::geom::Point2I getXY0() const
Return the image's origin.
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
LSST DM logging module built on log4cxx.
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
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" ;
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
A base class for image defects.
MaskedImageT getMaskedImage()
Return the MaskedImage.
Represent a 2-dimensional array of bitmask pixels.
An ellipse defined by an arbitrary BaseCore and a center point.
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
A class to manipulate images, masks, and variance as a single object.
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
static FlagDefinition const NO_GOOD_PIXELS
A FunctorKey for FluxResult.
static FlagDefinitionList const & getFlagDefinitions()
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a...
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()
Return the Exposure's Psf object.
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)
Set value of a field for the given key.
Record class that contains measurements made on a single exposure.
static FlagDefinition const FAILURE
vector-type utility class to build a collection of FlagDefinitions
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
A reusable result struct for instFlux measurements.