lsst.meas.base
tickets.DM-23835-g914efbff1e
|
Go to the documentation of this file.
26 #include "boost/algorithm/string/replace.hpp"
28 #include "ndarray/eigen.h"
40 FlagDefinitionList 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) {
80 std::string doc = (boost::format(
"instFlux within %f-pixel aperture") % ctrl.
radii[i]).str();
90 _keys[i].flags.handleFailure(measRecord, error);
96 record.
set(_keys[index].instFluxKey,
result);
112 template <
typename T>
122 if (!
bbox.contains(cImage->getBBox())) {
136 cImage = std::make_shared<afw::image::Image<T> >(*cImage, overlap);
143 template <
typename T>
151 (ndarray::asEigenArray(subImage.getArray()) * ndarray::asEigenArray(cImage->getArray())).sum();
155 template <
typename T>
163 result.instFlux = (ndarray::asEigenArray(subImage.getImage()->getArray()) *
164 ndarray::asEigenArray(cImage->getArray()))
167 std::sqrt((ndarray::asEigenArray(subImage.getVariance()->getArray()).
template cast<T>() *
168 ndarray::asEigenArray(cImage->getArray()).square())
173 template <
typename T>
185 spanIter != spanEnd; ++spanIter) {
187 image.x_at(spanIter->getBeginX() -
image.getX0(), spanIter->getY() -
image.getY0());
193 template <
typename T>
207 spanIter != spanEnd; ++spanIter) {
209 spanIter->getBeginX() -
image.getX0(), spanIter->getY() -
image.getY0());
211 spanIter->getBeginX() -
image.getX0(), spanIter->getY() -
image.getY0());
220 template <
typename T>
229 template <
typename T>
237 #define INSTANTIATE(T) \
238 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeFlux( \
239 afw::image::Image<T> const &, afw::geom::ellipses::Ellipse const &, Control const &); \
240 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeFlux( \
241 afw::image::MaskedImage<T> const &, afw::geom::ellipses::Ellipse const &, Control const &); \
242 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeSincFlux( \
243 afw::image::Image<T> const &, afw::geom::ellipses::Ellipse const &, Control const &); \
244 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeSincFlux( \
245 afw::image::MaskedImage<T> const &, afw::geom::ellipses::Ellipse const &, Control const &); \
246 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeNaiveFlux( \
247 afw::image::Image<T> const &, afw::geom::ellipses::Ellipse const &, Control const &); \
248 template ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeNaiveFlux( \
249 afw::image::MaskedImage<T> const &, afw::geom::ellipses::Ellipse const &, Control const &)
266 .find<afw::table::Flag>(
267 (boost::format(
"%s_%s") %
289 for (; inSrc != inputCatalog.
end() && outSrc != outputCatalog.
end(); ++inSrc, ++outSrc) {
291 FluxResult instFluxResult = instFluxKeys[i].get(*inSrc);
static const FlagDefinition SINC_COEFFS_TRUNCATED
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...
lsst::geom::Box2I const & getBBox() const
meas::base::Flux instFlux
Measured instFlux in DN.
A reusable result struct for instFlux measurements.
std::vector< Span >::const_iterator Iterator
lsst::geom::Box2D computeBBox() const
void add(std::string const &name, T const &value)
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Base::const_iterator const_iterator
static const FlagDefinition FAILURE
A Result struct for running an aperture flux algorithm with a single radius.
A FunctorKey for FluxResult.
std::string shiftKernel
"Warping kernel used to shift Sinc photometry coefficients to different center positions" ;
static boost::shared_ptr< CoeffT const > get(afw::geom::ellipses::Axes const &outerEllipse, float const innerRadiusFactor=0.0)
Get the coefficients for an aperture.
vector-type utility class to build a collection of FlagDefinitions
meas::base::FluxErrElement instFluxErr
Standard deviation of instFlux in DN.
std::unique_ptr< SchemaItem< U > > result
double maxSincRadius
"Maximum radius (in pixels) for which the sinc algorithm should be used instead of the " "faster naiv...
Utility class for handling flag fields that indicate the failure modes of an algorithm.
void copyResultToRecord(Result const &result, afw::table::SourceRecord &record, int index) const
lsst::geom::Point2D const & getCenter() const
bool contains(Point2I const &point) const noexcept
CatalogIterator< typename Internal::iterator > iterator
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.
static const FlagDefinition APERTURE_TRUNCATED
_view_t::x_iterator x_iterator
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.
std::size_t size() const
return the current size (number of defined elements) of the collection
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
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.
std::vector< double > radii
"Radius (in pixels) of apertures." ;
void clip(Box2I const &other) noexcept
std::shared_ptr< ImageT > offsetImage(ImageT const &image, float dx, float dy, std::string const &algorithmName="lanczos5", unsigned int buffer=0)
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.
Base class for multiple-aperture photometry algorithms.
BaseCore const & getCore() const
void set(Key< T > const &key, U const &value)
Configuration object for multiple-aperture flux algorithms.
static FlagDefinitionList const & getFlagDefinitions()
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.