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.
geom::Point2I getXY0() const
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
table::Key< std::string > name
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.
Eigen matrix objects that present a view into an ndarray::Array.
Eigen3 view into an ndarray::Array.
afw::table::Schema schema
A mapping between the keys of two Schemas, used to copy data between them.
boost::uint16_t MaskPixel
PixelT Pixel
A pixel in this ImageBase.
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
Exception to be thrown when a measurement algorithm experiences a known failure mode.
An integer coordinate rectangle.
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's variance.
FlagDefinition getDefinition(int i) const
MaskedImageT getMaskedImage()
Return the MaskedImage.
math::Kernel::Pixel Pixel
Pixel type of Image returned by computeImage.
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
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
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
lsst::afw::image::VariancePixel VarPixel
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.
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
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.
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinition const *begin, FlagDefinition const *end)
A reusable result struct for flux measurements.