23 #ifndef LSST_MEAS_EXTENSIONS_PHOTOMETRY_KRON_H
24 #define LSST_MEAS_EXTENSIONS_PHOTOMETRY_KRON_H
29 #include "lsst/pex/config.h"
30 #include "lsst/afw/image/Exposure.h"
31 #include "lsst/meas/base/Algorithm.h"
32 #include "lsst/meas/base/FluxUtilities.h"
33 #include "lsst/meas/base/CentroidUtilities.h"
34 #include "lsst/meas/base/FlagHandler.h"
35 #include "lsst/meas/base/InputUtilities.h"
37 namespace lsst {
namespace meas {
namespace extensions {
namespace photometryKron {
49 LSST_CONTROL_FIELD(
fixed,
bool,
50 "if true, use existing shape and centroid measurements instead of fitting");
52 "Multiplier of rms size for aperture used to initially estimate the Kron radius");
53 LSST_CONTROL_FIELD(
nIterForRadius,
int,
"Number of times to iterate when setting the Kron radius");
54 LSST_CONTROL_FIELD(
nRadiusForFlux,
double,
"Number of Kron radii for Kron flux");
56 "Largest aperture for which to use the slow, accurate, sinc aperture code");
58 "Minimum Kron radius (if == 0.0 use PSF's Kron radius) if enforceMinimumRadius. "
59 "Also functions as fallback aperture radius if set.");
62 "Use the Footprint size as part of initial estimate of Kron radius");
64 "Smooth image with N(0, smoothingSigma^2) Gaussian while estimating R_K");
66 "Name of field specifying reference Kron radius for forced measurement");
90 static meas::base::FlagDefinition
const FAILURE;
91 static meas::base::FlagDefinition
const EDGE;
107 std::string
const &
name,
108 afw::table::Schema & schema,
109 daf::base::PropertySet & metadata
113 afw::table::SourceRecord & measRecord,
114 afw::image::Exposure<float>
const & exposure
118 afw::table::SourceRecord & measRecord,
119 afw::image::Exposure<float>
const & exposure,
120 afw::table::SourceRecord
const & refRecord,
121 afw::image::Wcs
const & refWcs
125 afw::table::SourceRecord & measRecord,
126 meas::base::MeasurementError * error=NULL
132 afw::table::SourceRecord & source,
133 afw::image::Exposure<float>
const& exposure,
138 afw::table::SourceRecord & source,
139 afw::image::Exposure<float>
const & exposure,
140 afw::geom::Point2D
const & center,
141 afw::table::SourceRecord
const & reference,
142 afw::geom::AffineTransform
const & refToMeas
145 PTR(
KronAperture) _fallbackRadius(afw::table::SourceRecord& source,
double const R_K_psf,
146 pex::exceptions::Exception& exc) const;
150 meas::base::FluxResultKey _fluxResultKey;
151 afw::table::Key<
float> _radiusKey;
152 afw::table::Key<
float> _radiusForRadiusKey;
153 afw::table::Key<
float> _psfRadiusKey;
154 meas::base::FlagHandler _flagHandler;
155 meas::base::SafeCentroidExtractor _centroidExtractor;
160 KronAperture(afw::geom::Point2D
const& center, afw::geom::ellipses::BaseCore
const& core,
161 float radiusForRadius=std::nanf(
"")) :
164 _radiusForRadius(radiusForRadius)
167 explicit KronAperture(afw::table::SourceRecord
const& source,
float radiusForRadius=std::nanf(
"")) :
168 _center(afw::geom::Point2D(source.getX(), source.getY())),
169 _axes(source.getShape()),
170 _radiusForRadius(radiusForRadius)
173 KronAperture(afw::table::SourceRecord
const& reference, afw::geom::AffineTransform
const& refToMeas,
174 double radius,
float radiusForRadius=std::nanf(
"")) :
175 _center(refToMeas(reference.getCentroid())),
176 _axes(getKronAxes(reference.getShape(), refToMeas.getLinear(), radius)),
177 _radiusForRadius(radiusForRadius)
181 double getX()
const {
return _center.getX(); }
182 double getY()
const {
return _center.getY(); }
185 afw::geom::Point2D
const&
getCenter()
const {
return _center; }
187 afw::geom::ellipses::Axes &
getAxes() {
return _axes; }
189 afw::geom::ellipses::Axes
const&
getAxes()
const {
return _axes; }
196 template<
typename ImageT>
197 static PTR(KronAperture) determineRadius(
199 afw::geom::ellipses::Axes axes,
200 afw::geom::Point2D const& center,
205 template<typename ImageT>
206 std::pair<
double,
double> measureFlux(
208 double const nRadiusForFlux,
209 double const maxSincRadius
213 PTR(KronAperture) transform(afw::geom::AffineTransform const& trans)
const {
214 afw::geom::Point2D
const center = trans(getCenter());
215 afw::geom::ellipses::Axes
const axes(*getAxes().transform(trans.getLinear()).copy());
216 return std::make_shared<KronAperture>(center, axes);
221 afw::geom::ellipses::Axes getKronAxes(
222 afw::geom::ellipses::Axes
const& shape,
223 afw::geom::LinearTransform
const& transformation,
228 afw::geom::Point2D
const _center;
229 afw::geom::ellipses::Axes _axes;
230 float _radiusForRadius;
235 #endif // !LSST_MEAS_EXTENSIONS_PHOTOMETRY_KRON_H
static meas::base::FlagDefinition const SMALL_RADIUS
virtual void measureForced(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure, afw::table::SourceRecord const &refRecord, afw::image::Wcs const &refWcs) const
static meas::base::FlagDefinition const NO_MINIMUM_RADIUS
C++ control object for Kron flux.
afw::geom::Point2D const & getCenter() const
double smoothingSigma
"Smooth image with N(0, smoothingSigma^2) Gaussian while estimating R_K" ;
afw::geom::ellipses::Axes const & getAxes() const
float getRadiusForRadius() const
double minimumRadius
"Minimum Kron radius (if == 0.0 use PSF's Kron radius) if enforceMinimumRadius. " "Also functions as...
virtual void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
KronFluxAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema, daf::base::PropertySet &metadata)
A class that knows how to calculate fluxes using the KRON photometry algorithm.
bool fixed
"if true, use existing shape and centroid measurements instead of fitting" ;
static meas::base::FlagDefinition const USED_MINIMUM_RADIUS
static meas::base::FlagDefinition const USED_PSF_RADIUS
static meas::base::FlagDefinition const NO_FALLBACK_RADIUS
static meas::base::FlagDefinition const BAD_SHAPE_NO_PSF
double nSigmaForRadius
"Multiplier of rms size for aperture used to initially estimate the Kron radius" ; ...
bool enforceMinimumRadius
"If true check that the Kron radius exceeds some minimum" ;
KronFluxControl Control
A typedef to the Control object for this algorithm, defined above.
std::string refRadiusName
"Name of field specifying reference Kron radius for forced measurement" ;
KronAperture(afw::table::SourceRecord const &reference, afw::geom::AffineTransform const &refToMeas, double radius, float radiusForRadius=std::nanf(""))
static meas::base::FlagDefinition const FAILURE
double maxSincRadius
"Largest aperture for which to use the slow, accurate, sinc aperture code" ;
static meas::base::FlagDefinition const BAD_RADIUS
double getX() const
Accessors.
int nIterForRadius
"Number of times to iterate when setting the Kron radius" ;
bool useFootprintRadius
"Use the Footprint size as part of initial estimate of Kron radius" ;
A measurement algorithm that estimates flux using Kron photometry.
static meas::base::FlagDefinition const EDGE
KronAperture(afw::geom::Point2D const ¢er, afw::geom::ellipses::BaseCore const &core, float radiusForRadius=std::nanf(""))
KronAperture(afw::table::SourceRecord const &source, float radiusForRadius=std::nanf(""))
afw::geom::ellipses::Axes & getAxes()
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
double nRadiusForFlux
"Number of Kron radii for Kron flux" ;
static meas::base::FlagDefinition const BAD_SHAPE
static meas::base::FlagDefinitionList const & getFlagDefinitions()