26#include "boost/algorithm/string.hpp"
28#include "ndarray/eigen.h"
40FlagDefinitionList flagDefinitions;
45 flagDefinitions.add(
"flag_apertureTruncated",
"aperture did not fit within measurement image");
47 "flag_sincCoeffsTruncated",
"full sinc coefficient image did not fit within measurement image");
53 static std::array<double, 10> defaultRadii = {{3.0, 4.5, 6.0, 9.0, 12.0, 17.0, 25.0, 35.0, 50.0, 70.0}};
59 return boost::replace_all_copy(
prefix,
".",
"_");
75 : _ctrl(
ctrl), _centroidExtractor(schema, name) {
82 std::string doc = (boost::format(
"instFlux within %f-pixel aperture") %
ctrl.radii[
i]).str();
98 record.
set(_keys[index].instFluxKey,
result);
100 _keys[index].flags.setValue(record,
FAILURE.number,
true);
138 cImage = std::make_shared<afw::image::Image<T> >(*cImage, overlap);
153 (ndarray::asEigenArray(
subImage.getArray()) * ndarray::asEigenArray(
cImage->getArray())).
sum();
165 result.instFlux = (ndarray::asEigenArray(
subImage.getImage()->getArray()) *
166 ndarray::asEigenArray(
cImage->getArray()))
170 ndarray::asEigenArray(
cImage->getArray()).square())
180 if (!image.getBBox().contains(
region.getBBox())) {
189 image.x_at(
spanIter->getBeginX() - image.getX0(),
spanIter->getY() - image.getY0());
201 if (!image.getBBox().contains(
region.getBBox())) {
239#define INSTANTIATE(T) \
240 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeFlux( \
241 afw::image::Image<T> const &, afw::geom::ellipses::Ellipse const &, Control const &); \
242 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeFlux( \
243 afw::image::MaskedImage<T> const &, afw::geom::ellipses::Ellipse const &, Control const &); \
244 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeSincFlux( \
245 afw::image::Image<T> const &, afw::geom::ellipses::Ellipse const &, Control const &); \
246 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeSincFlux( \
247 afw::image::MaskedImage<T> const &, afw::geom::ellipses::Ellipse const &, Control const &); \
248 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeNaiveFlux( \
249 afw::image::Image<T> const &, afw::geom::ellipses::Ellipse const &, Control const &); \
250 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeNaiveFlux( \
251 afw::image::MaskedImage<T> const &, afw::geom::ellipses::Ellipse const &, Control const &)
268 .find<afw::table::Flag>(
269 (boost::format(
"%s_%s") %
double const getB() const
std::vector< Span >::const_iterator Iterator
typename _view_t::x_iterator x_iterator
void set(Key< T > const &key, U const &value)
typename Base::const_iterator const_iterator
void add(std::string const &name, T const &value)
Base class for multiple-aperture photometry algorithms.
ApertureFluxAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema, daf::base::PropertySet &metadata)
Construct the algorithm and add its fields to the given Schema.
void copyResultToRecord(Result const &result, afw::table::SourceRecord &record, int index) const
static FlagDefinitionList const & getFlagDefinitions()
static FlagDefinition const FAILURE
static FlagDefinition const SINC_COEFFS_TRUNCATED
static std::string makeFieldPrefix(std::string const &name, double radius)
Construct an appropriate prefix for table fields.
static Result computeSincFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the instFlux (and optionally, uncertanties) within an aperture using Sinc photometry.
static Result computeFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the instFlux (and optionally, uncertanties) within an aperture using the algorithm determined...
static FlagDefinition const APERTURE_TRUNCATED
static Result computeNaiveFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the instFlux (and optionally, uncertanties) within an aperture using naive photometry.
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.
Configuration object for multiple-aperture flux algorithms.
double maxSincRadius
"Maximum radius (in pixels) for which the sinc algorithm should be used instead of the " "faster naiv...
std::vector< double > radii
"Radius (in pixels) of apertures." ;
vector-type utility class to build a collection of FlagDefinitions
Utility class for handling flag fields that indicate the failure modes of an algorithm.
A FunctorKey for FluxResult.
static MagResultKey addFields(afw::table::Schema &schema, std::string const &name)
Add a pair of _mag, _magErr fields to a Schema, and return a MagResultKey that points to them.
Exception to be thrown when a measurement algorithm experiences a known failure mode.
static std::shared_ptr< CoeffT const > get(afw::geom::ellipses::Axes const &outerEllipse, float const innerRadiusFactor=0.0)
Get the coefficients for an aperture.
std::shared_ptr< ImageT > offsetImage(ImageT const &image, float dx, float dy, std::string const &algorithmName="lanczos5", unsigned int buffer=0)
A Result struct for running an aperture flux algorithm with a single radius.
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
A reusable result struct for instFlux measurements.