33 namespace pexExceptions = lsst::pex::exceptions;
34 namespace afwDet = lsst::afw::detection;
36 namespace afwMath = lsst::afw::math;
37 namespace afwGeom = lsst::afw::geom;
39 namespace lsst {
namespace meas {
namespace base {
43 template <
typename MaskedImageT,
typename WeightImageT>
47 MaskedImageT
const& mimage,
48 typename WeightImageT::Ptr wimage
50 afwDet::FootprintFunctor<MaskedImageT>(mimage),
53 _x0(wimage->getX0()),
_y0(wimage->getY0()) {}
65 if (bbox.getDimensions() !=
_wimage->getDimensions()) {
68 "for %d x %d weight image") %
69 bbox.getMinX() % bbox.getMinY() % bbox.getMaxX() % bbox.getMaxY() %
75 void operator()(
typename MaskedImageT::xy_locator iloc,
79 typename MaskedImageT::Image::Pixel ival = iloc.image(0, 0);
80 typename MaskedImageT::Image::Pixel vval = iloc.variance(0, 0);
81 typename WeightImageT::Pixel wval = (*_wimage)(x -
_x0, y -
_y0);
87 double getSum()
const {
return _sum; }
88 double getSumVar()
const {
return _sumVar; }
91 typename WeightImageT::Ptr
const&
_wimage;
102 template<
typename MaskedImageT>
103 std::pair<double, double>
105 double const innerFactor)
107 double flux = std::numeric_limits<double>::quiet_NaN();
108 double fluxErr = std::numeric_limits<double>::quiet_NaN();
110 typedef typename MaskedImageT::Image Image;
111 typedef typename Image::Pixel Pixel;
112 typedef typename Image::Ptr ImagePtr;
124 ImagePtr cimage =
afwMath::offsetImage(*cimage0, ellipse.getCenter().getX(), ellipse.getCenter().getY());
133 bbox.
shift(-cimage->getX0(), -cimage->getY0());
134 cimage =
typename Image::Ptr(
new Image(*cimage, bbox,
false));
135 cimage->setXY0(cimXy0);
137 int x1 = (cimage->getX0() < mimage.getX0()) ? mimage.getX0() : cimage->getX0();
138 int y1 = (cimage->getY0() < mimage.getY0()) ? mimage.getY0() : cimage->getY0();
139 int x2 = (cimage->getX0() + cimage->getWidth() > mimage.getX0() + mimage.getWidth()) ?
140 mimage.getX0() + mimage.getWidth() - 1 : cimage->getX0() + cimage->getWidth() - 1;
141 int y2 = (cimage->getY0() + cimage->getHeight() > mimage.getY0() + mimage.getHeight()) ?
142 mimage.getY0() + mimage.getHeight() - 1 : cimage->getY0() + cimage->getHeight() - 1;
145 if ( (x2 - x1 + 1 != cimage->getWidth()) || (y2 - y1 + 1 != cimage->getHeight()) ) {
158 FootprintWeightFlux<MaskedImageT, Image> wfluxFunctor(mimage, cimage);
161 wfluxFunctor.apply(foot);
162 flux = wfluxFunctor.getSum();
163 fluxErr = ::sqrt(wfluxFunctor.getSumVar());
165 return std::make_pair(flux, fluxErr);
172 std::string
const & name,
176 FluxResultKey::addFields(schema, name,
"flux from Sinc Flux algorithm")
178 _centroidExtractor(schema, name)
180 static boost::array<FlagDefinition,N_FLAGS>
const flagDefs = {{
181 {
"flag",
"general failure flag, set if anything went wrong"},
198 double flux = fluxes.first;
199 double fluxErr = fluxes.second;
Defines the fields and offsets for a table.
SafeCentroidExtractor _centroidExtractor
static boost::shared_ptr< CoeffT const > get(afw::geom::ellipses::Axes const &outerEllipse, float const innerRadiusFactor=0.0)
WeightImageT::Ptr const & _wimage
Eigen matrix objects that present a view into an ndarray::Array.
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Exception to be thrown when a measurement algorithm experiences a known failure mode.
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
std::pair< double, double > calculateSincApertureFlux(MaskedImageT const &mimage, afw::geom::ellipses::Ellipse const &ellipse, double const innerFactor)
Include files required for standard LSST Exception handling.
A C++ control class to handle SincFluxAlgorithm's configuration.
MaskedImageT getMaskedImage()
Return the MaskedImage.
SincFluxAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
void shift(Extent< T, N > const &offset)
Shift the point by the given offset.
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
An ellipse defined by an arbitrary BaseCore and a center point.
Flux flux
Measured flux in DN.
void setValue(afw::table::BaseRecord &record, int i, bool value) const
double radius2
"major axis of outer boundary (pixels)" ;
A FunctorKey for FluxResult.
ImageT::Ptr offsetImage(ImageT const &image, float dx, float dy, std::string const &algorithmName="lanczos5", unsigned int buffer=0)
Return an image offset by (dx, dy) using the specified algorithm.
#define LSST_EXCEPT(type,...)
FluxResultKey _fluxResultKey
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a...
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).
FluxErrElement fluxSigma
1-Sigma error (sqrt of variance) on flux in DN.
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinition const *begin, FlagDefinition const *end)
A reusable result struct for flux measurements.
double radius1
"major axis of inner boundary (pixels)" ;