24 #include "boost/array.hpp"
31 #include "lsst/afw/detection/FootprintArray.cc"
34 namespace lsst {
namespace meas {
namespace base {
38 boost::array<FlagDefinition,PsfFluxAlgorithm::N_FLAGS>
const & getFlagDefinitions() {
39 static boost::array<FlagDefinition,PsfFluxAlgorithm::N_FLAGS>
const flagDefs = {{
40 {
"flag",
"general failure flag"},
41 {
"flag_noGoodPixels",
"not enough non-rejected pixels in data to attempt the fit"},
42 {
"flag_edge",
"object was too close to the edge of the image to use the full PSF model"}
51 std::string
const &
name,
55 FluxResultKey::addFields(schema, name,
"flux derived from linear least-squares fit of PSF model")
57 _centroidExtractor(schema, name)
60 getFlagDefinitions().begin(), getFlagDefinitions().end());
71 "PsfFlux algorithm requires a Psf with every exposure"
78 if (fitBBox != psfImage->getBBox()) {
106 psfImage->getArray(),
124 PsfPixel
alpha = model.matrix().squaredNorm();
126 result.
flux = model.matrix().dot(data.matrix().cast<PsfPixel>()) /
alpha;
129 result.
fluxSigma = std::sqrt(model.square().matrix().dot(variance.matrix().cast<PsfPixel>()))
132 throw LSST_EXCEPT(PixelValueError,
"Invalid pixel value detected in image.");
143 std::string
const &
name,
148 for (
auto flag = getFlagDefinitions().begin() + 1; flag < getFlagDefinitions().end(); flag++) {
149 mapper.
addMapping(mapper.getInputSchema().find<afw::table::Flag>(
name +
"_" + flag->name).key);
Defines the fields and offsets for a table.
std::vector< std::string > badMaskPlanes
"Mask planes that indicate pixels that should be excluded from the fit" ;
void flattenArray(Footprint const &fp, ndarray::Array< T, N, C > const &src, ndarray::Array< U, N-1, D > const &dest, lsst::afw::geom::Point2I const &xy0=lsst::afw::geom::Point2I())
Flatten the first two dimensions of an array.
boost::uint16_t MaskPixel
MaskedImageT getMaskedImage()
Return the MaskedImage.
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
table::Key< std::string > name
Eigen matrix objects that present a view into an ndarray::Array.
Eigen3 view into an ndarray::Array.
A mapping between the keys of two Schemas, used to copy data between them.
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
Exception to be thrown when a measurement algorithm experiences a known failure mode.
lsst::afw::image::VariancePixel VarPixel
PixelT Pixel
A pixel in this ImageBase.
An integer coordinate rectangle.
Key< T > addMapping(Key< T > const &inputKey, bool doReplace=false)
Add a new field to the output Schema that is a copy of a field in the input Schema.
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's variance.
FlagDefinition getDefinition(int i) const
Flux flux
Measured flux in DN.
PsfFluxAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
void setValue(afw::table::BaseRecord &record, int i, bool value) const
FluxResultKey _fluxResultKey
math::Kernel::Pixel Pixel
Pixel type of Image returned by computeImage.
A FunctorKey for FluxResult.
boost::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure's Psf object.
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
#define LSST_EXCEPT(type,...)
SafeCentroidExtractor _centroidExtractor
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=NULL) const
Record class that contains measurements made on a single exposure.
A polymorphic base class for representing an image's Point Spread Function.
FluxErrElement fluxSigma
1-Sigma error (sqrt of variance) on flux in DN.
A C++ control class to handle PsfFluxAlgorithm's configuration.
geom::Point2I getXY0() const
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinition const *begin, FlagDefinition const *end)
A reusable result struct for flux measurements.