26 #include "boost/algorithm/string/replace.hpp" 28 #include "ndarray/eigen.h" 36 namespace lsst {
namespace meas {
namespace base {
38 FlagDefinitionList flagDefinitions;
46 return flagDefinitions;
53 3.0, 4.5, 6.0, 9.0, 12.0, 17.0, 25.0, 35.0, 50.0, 70.0
61 return boost::replace_all_copy(prefix,
".",
"_");
64 ApertureFluxAlgorithm::Keys::Keys(
85 _centroidExtractor(schema, name)
89 metadata.
add(name +
"_radii", ctrl.
radii[i]);
91 std::string doc = (boost::format(
"flux within %f-pixel aperture") % ctrl.
radii[i]).str();
101 _keys[i].flags.handleFailure(measRecord, error);
110 record.
set(_keys[index].fluxKey, result);
126 template <
typename T>
140 if (!bbox.
contains(cImage->getBBox())) {
145 result.
setFlag(ApertureFluxAlgorithm::SINC_COEFFS_TRUNCATED.number);
151 result.
setFlag(ApertureFluxAlgorithm::APERTURE_TRUNCATED.number);
152 result.
setFlag(ApertureFluxAlgorithm::FAILURE.number);
154 cImage = std::make_shared< afw::image::Image<T> >(*cImage, overlap);
161 template <
typename T>
171 result.flux = (subImage.getArray().template asEigen<Eigen::ArrayXpr>()
172 * cImage->getArray().template asEigen<Eigen::ArrayXpr>()).sum();
176 template <
typename T>
186 result.flux = (subImage.getImage()->getArray().template asEigen<Eigen::ArrayXpr>()
187 * cImage->getArray().template asEigen<Eigen::ArrayXpr>()).sum();
189 (subImage.getVariance()->getArray().template asEigen<Eigen::ArrayXpr>().
template cast<T>()
190 * cImage->getArray().template asEigen<Eigen::ArrayXpr>().square()).sum()
195 template <
typename T>
215 spanIter->getBeginX() - image.
getX0(),
216 spanIter->getY() - image.
getY0()
223 template <
typename T>
244 spanIter->getBeginX() - image.
getX0(),
245 spanIter->getY() - image.
getY0()
248 spanIter->getBeginX() - image.
getX0(),
249 spanIter->getY() - image.
getY0()
259 template <
typename T>
270 template <
typename T>
280 #define INSTANTIATE(T) \ 282 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeFlux( \ 283 afw::image::Image<T> const &, \ 284 afw::geom::ellipses::Ellipse const &, \ 288 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeFlux( \ 289 afw::image::MaskedImage<T> const &, \ 290 afw::geom::ellipses::Ellipse const &, \ 294 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeSincFlux( \ 295 afw::image::Image<T> const &, \ 296 afw::geom::ellipses::Ellipse const &, \ 300 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeSincFlux( \ 301 afw::image::MaskedImage<T> const &, \ 302 afw::geom::ellipses::Ellipse const &, \ 306 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeNaiveFlux( \ 307 afw::image::Image<T> const &, \ 308 afw::geom::ellipses::Ellipse const &, \ 312 ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeNaiveFlux( \ 313 afw::image::MaskedImage<T> const &, \ 314 afw::geom::ellipses::Ellipse const &, \ 332 if (_ctrl.
radii[i] > _ctrl.
maxSincRadius && flag == ApertureFluxAlgorithm::SINC_COEFFS_TRUNCATED) {
362 for (; inSrc != inputCatalog.
end() && outSrc != outputCatalog.
end(); ++inSrc, ++outSrc) {
364 FluxResult fluxResult = fluxKeys[i].get(*inSrc);
std::size_t size() const
return the current size (number of defined elements) of the collection
VariancePtr getVariance() const
static boost::shared_ptr< CoeffT const > get(afw::geom::ellipses::Axes const &outerEllipse, float const innerRadiusFactor=0.0)
Get the coefficients for an aperture.
Box2I const & getBBox() const
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...
bool getFlag(unsigned int index) const
Return the flag value associated with the given bit.
void setFlag(unsigned int index, bool value=true)
Set the flag value associated with the given bit.
geom::Box2I getBBox(ImageOrigin origin=PARENT) const
Schema const getInputSchema() const
afw::table::Schema schema
static FlagDefinitionList const & getFlagDefinitions()
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
_view_t::x_iterator x_iterator
Temporarily replace negative fluxes with NaNs.
BaseCore const & getCore() const
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
Return the flag definitions which apply to aperture flux measurements.
Exception to be thrown when a measurement algorithm experiences a known failure mode.
static FluxResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)
Add a pair of _flux, _fluxSigma fields to a Schema, and return a FluxResultKey that points to them...
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
ImagePtr getImage() const
Configuration object for multiple-aperture flux algorithms.
SchemaItem< T > find(std::string const &name) const
static FlagDefinition const FAILURE
static FlagDefinition const APERTURE_TRUNCATED
static Result computeFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the flux (and optionally, uncertanties) within an aperture using the algorithm determined by ...
double maxSincRadius
"Maximum radius (in pixels) for which the sinc algorithm should be used instead of the " "faster naiv...
static std::string makeFieldPrefix(std::string const &name, double radius)
Construct an appropriate prefix for table fields.
static FlagDefinition const SINC_COEFFS_TRUNCATED
static Result computeNaiveFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the flux (and optionally, uncertanties) within an aperture using naive photometry.
Flux flux
Measured flux in DN.
Schema & editOutputSchema()
bool contains(Point2I const &point) const
A FunctorKey for FluxResult.
std::unique_ptr< SchemaItem< U > > result
double getMagnitude(double const flux) const
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinitionList const &flagDefs, FlagDefinitionList const &exclDefs=FlagDefinitionList::getEmptyList())
Add Flag fields to a schema, creating a FlagHandler object to manage them.
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...
Point2D const & getCenter() const
std::shared_ptr< ImageT > offsetImage(ImageT const &image, float dx, float dy, std::string const &algorithmName="lanczos5", unsigned int buffer=0)
Base::const_iterator const_iterator
Box2D computeBBox() const
static Result computeSincFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the flux (and optionally, uncertanties) within an aperture using Sinc photometry.
x_iterator x_at(int x, int y) const
void set(Key< T > const &key, U const &value)
void clip(Box2I const &other)
Key< T > addMapping(Key< T > const &inputKey, bool doReplace=false)
std::string shiftKernel
"Warping kernel used to shift Sinc photometry coefficients to different center positions" ; ...
std::vector< double > radii
"Radius (in pixels) of apertures." ;
vector-type utility class to build a collection of FlagDefinitions
void add(std::string const &name, T const &value)
FluxErrElement fluxSigma
1-Sigma error (sqrt of variance) on flux in DN.
A reusable result struct for flux measurements.
CatalogIterator< typename Internal::iterator > iterator
A Result struct for running an aperture flux algorithm with a single radius.