34 namespace lsst {
namespace meas {
namespace base {
38 static boost::array<double,10> defaultRadii = {{
39 3.0, 4.5, 6.0, 9.0, 12.0, 17.0, 25.0, 35.0, 50.0, 70.0
41 std::copy(defaultRadii.begin(), defaultRadii.end(),
radii.begin());
46 std::string
const & name,
51 _centroidExtractor(schema, name),
53 afw::table::ArrayKey<
Flux>::addFields(
56 "flux within %f pixel aperture",
62 afw::table::ArrayKey<
Flux>::addFields(
65 "1-sigma uncertainty on flux within %f pixel aperture",
71 for (std::size_t i = 0; i < ctrl.
radii.size(); ++i) {
72 metadata.
add(name +
"_radii", ctrl.
radii[i]);
76 for (std::size_t i = 0; i < ctrl.
radii.size(); ++i) {
80 static boost::array<FlagDefinition,N_FLAGS>
const flagDefs = {{
81 {
"flag",
"general failure flag, set if anything went wrong"},
90 schema.addField<afw::table::Flag>(
91 (boost::
format(
"%s_flag_%d") % name % index).str(),
92 (boost::
format(
"flag set if aperture %d failed for any reason") % index).str()
96 schema.addField<afw::table::Flag>(
97 (boost::
format(
"%s_flag_apertureTruncated_%d") % name % index).str(),
98 (boost::
format(
"flag set if aperture %d did not fit within the measurement image") % index).str()
102 schema.addField<afw::table::Flag>(
103 (boost::
format(
"%s_flag_sincCoeffsTruncated_%d") % name % index).str(),
104 (boost::
format(
"flag set if the full sinc coefficient image for aperture %d did not "
105 "fit within the measurement image") % index).str()
141 template <
typename T>
143 afw::geom::Box2I const & bbox,
144 afw::geom::ellipses::Ellipse const & ellipse,
151 ellipse.getCenter().getX(),
152 ellipse.getCenter().getY(),
155 if (!bbox.contains(cImage->getBBox())) {
168 cImage = boost::make_shared< afw::image::Image<T> >(*cImage, overlap);
175 template <
typename T>
185 result.flux = (subImage.getArray().template asEigen<Eigen::ArrayXpr>()
186 * cImage->getArray().template asEigen<Eigen::ArrayXpr>()).sum();
190 template <
typename T>
200 result.flux = (subImage.getImage()->getArray().template asEigen<Eigen::ArrayXpr>()
201 * cImage->getArray().template asEigen<Eigen::ArrayXpr>()).sum();
202 result.fluxSigma = std::sqrt(
203 (subImage.getVariance()->getArray().template asEigen<Eigen::ArrayXpr>().
template cast<T>()
204 * cImage->getArray().template asEigen<Eigen::ArrayXpr>().square()).
sum()
209 template <
typename T>
228 spanIter->getBeginX() - image.
getX0(),
229 spanIter->getY() - image.
getY0()
231 result.
flux += std::accumulate(pixIter, pixIter + spanIter->
getWidth(), 0.0);
236 template <
typename T>
256 spanIter->getBeginX() - image.
getX0(),
257 spanIter->getY() - image.
getY0()
260 spanIter->getBeginX() - image.
getX0(),
261 spanIter->getY() - image.
getY0()
263 result.
flux += std::accumulate(pixIter, pixIter + spanIter->
getWidth(), 0.0);
265 result.
fluxSigma += std::accumulate(varIter, varIter + spanIter->
getWidth(), 0.0);
271 template <
typename T>
282 template <
typename T>
292 #define INSTANTIATE(T) \
294 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeFlux( \
295 afw::image::Image<T> const &, \
296 afw::geom::ellipses::Ellipse const &, \
300 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeFlux( \
301 afw::image::MaskedImage<T> const &, \
302 afw::geom::ellipses::Ellipse const &, \
306 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeSincFlux( \
307 afw::image::Image<T> const &, \
308 afw::geom::ellipses::Ellipse const &, \
312 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeSincFlux( \
313 afw::image::MaskedImage<T> const &, \
314 afw::geom::ellipses::Ellipse const &, \
318 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeNaiveFlux( \
319 afw::image::Image<T> const &, \
320 afw::geom::ellipses::Ellipse const &, \
324 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeNaiveFlux( \
325 afw::image::MaskedImage<T> const &, \
326 afw::geom::ellipses::Ellipse const &, \
std::vector< FlagKeys > _flagKeys
Defines the fields and offsets for a table.
void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
FlagKeys(std::string const &name, afw::table::Schema &schema, int index)
Eigen matrix objects that present a view into an ndarray::Array.
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
bool contains(Point2I const &point) const
Return true if the box contains the point.
A class to contain the data, WCS, and other information needed to describe an image of the sky...
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
SelectEigenView< T >::Type copy(Eigen::EigenBase< T > const &other)
Copy an arbitrary Eigen expression into a new EigenView.
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
ApertureFluxAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema, daf::base::PropertySet &metadata)
afw::table::ArrayKey< FluxErrElement > _fluxSigmaKey
geom::Box2I getBBox(ImageOrigin origin=PARENT) 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.
void copyResultToRecord(Result const &result, afw::table::SourceRecord &record, int index) const
An integer coordinate rectangle.
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's variance.
table::Key< table::Array< Kernel::Pixel > > image
afw::table::ArrayKey< Flux > _fluxKey
static Result computeFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
An ellipse defined by an arbitrary BaseCore and a center point.
double maxSincRadius
"Maximum radius (in pixels) for which the sinc algorithm should be used instead of the " "faster naiv...
Box2I const & getBBox() const
A class to manipulate images, masks, and variance as a single object.
void setFlag(ApertureFluxAlgorithm::ResultFlagBits bit, bool value=true)
Set the flag value associated with the given bit.
static Result computeNaiveFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Flux flux
Measured flux in DN.
BaseCore const & getCore() const
Return the ellipse core.
bool getFlag(ApertureFluxAlgorithm::ResultFlagBits bit) const
Return the flag value associated with the given bit.
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.
virtual void measure(afw::table::SourceRecord &record, afw::image::Exposure< float > const &exposure) const
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a...
ApertureFluxControl Control
Typedef to the control object associated with this algorithm, defined above.
Class for storing generic metadata.
static Result computeSincFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
int getWidth() const
Return the number of columns in the image.
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).
std::vector< double > radii
"Radius (in pixels) of apertures." ;
void add(std::string const &name, T const &value)
FluxErrElement fluxSigma
1-Sigma error (sqrt of variance) on flux in DN.
int getWidth() const
Return the number of columns in the image.
A class to represent a 2-dimensional array of pixels.
ApertureFluxResult Result
Result object returned by static methods.
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinition const *begin, FlagDefinition const *end)
afw::table::SourceRecord * record