lsst.meas.extensions.photometryKron g670421136f+f53e9990a4
Loading...
Searching...
No Matches
photometryKron.h
Go to the documentation of this file.
1// -*- lsst-c++ -*-
2/*
3 * LSST Data Management System
4 * Copyright 2008-2015 LSST Corporation.
5 *
6 * This product includes software developed by the
7 * LSST Project (http://www.lsst.org/).
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the LSST License Statement and
20 * the GNU General Public License along with this program. If not,
21 * see <http://www.lsstcorp.org/LegalNotices/>.
22 */
23#ifndef LSST_MEAS_EXTENSIONS_PHOTOMETRY_KRON_H
24#define LSST_MEAS_EXTENSIONS_PHOTOMETRY_KRON_H
25
26#include <memory>
27#include <cmath>
28
29#include "lsst/pex/config.h"
30#include "lsst/geom.h"
38
39namespace lsst { namespace meas { namespace extensions { namespace photometryKron {
40
41class KronAperture;
42
49public:
50
51 LSST_CONTROL_FIELD(fixed, bool,
52 "if true, use existing shape and centroid measurements instead of fitting");
53 LSST_CONTROL_FIELD(nSigmaForRadius, double,
54 "Multiplier of rms size for aperture used to initially estimate the Kron radius");
55 LSST_CONTROL_FIELD(nIterForRadius, int, "Number of times to iterate when setting the Kron radius");
56 LSST_CONTROL_FIELD(nRadiusForFlux, double, "Number of Kron radii for Kron flux");
57 LSST_CONTROL_FIELD(maxSincRadius, double,
58 "Largest aperture for which to use the slow, accurate, sinc aperture code");
59 LSST_CONTROL_FIELD(minimumRadius, double,
60 "Minimum Kron radius (if == 0.0 use PSF's Kron radius) if enforceMinimumRadius. "
61 "Also functions as fallback aperture radius if set.");
62 LSST_CONTROL_FIELD(enforceMinimumRadius, bool, "If true check that the Kron radius exceeds some minimum");
63 LSST_CONTROL_FIELD(useFootprintRadius, bool,
64 "Use the Footprint size as part of initial estimate of Kron radius");
65 LSST_CONTROL_FIELD(smoothingSigma, double,
66 "Smooth image with N(0, smoothingSigma^2) Gaussian while estimating R_K");
67 LSST_CONTROL_FIELD(refRadiusName, std::string,
68 "Name of field specifying reference Kron radius for forced measurement");
69
71 fixed(false),
72 nSigmaForRadius(6.0),
74 nRadiusForFlux(2.5),
75 maxSincRadius(10.0),
76 minimumRadius(0.0),
78 useFootprintRadius(false),
79 smoothingSigma(-1.0),
80 refRadiusName("ext_photometryKron_KronFlux_radius")
81 {}
82};
83
88public:
89
90 // Structures and routines to manage flaghandler
102
106
108 Control const & ctrl,
109 std::string const & name,
110 afw::table::Schema & schema,
111 daf::base::PropertySet & metadata
112 );
113
114 virtual void measure(
115 afw::table::SourceRecord & measRecord,
116 afw::image::Exposure<float> const & exposure
117 ) const;
118
119 virtual void measureForced(
120 afw::table::SourceRecord & measRecord,
121 afw::image::Exposure<float> const & exposure,
122 afw::table::SourceRecord const & refRecord,
123 afw::geom::SkyWcs const & refWcs
124 ) const;
125
126 virtual void fail(
127 afw::table::SourceRecord & measRecord,
129 ) const;
130
131private:
132
133 void _applyAperture(
135 afw::image::Exposure<float> const& exposure,
136 KronAperture const& aperture
137 ) const;
138
139 void _applyForced(
141 afw::image::Exposure<float> const & exposure,
142 geom::Point2D const & center,
143 afw::table::SourceRecord const & reference,
144 geom::AffineTransform const & refToMeas
145 ) const;
146
147 std::shared_ptr<KronAperture> _fallbackRadius(afw::table::SourceRecord& source, double const R_K_psf,
148 pex::exceptions::Exception& exc) const;
149
150 std::string _name;
151 Control _ctrl;
152 meas::base::FluxResultKey _fluxResultKey;
153 afw::table::Key<float> _radiusKey;
154 afw::table::Key<float> _radiusForRadiusKey;
155 afw::table::Key<float> _psfRadiusKey;
156 meas::base::FlagHandler _flagHandler;
157 meas::base::SafeCentroidExtractor _centroidExtractor;
158};
159
161public:
163 float radiusForRadius=std::nanf("")) :
164 _center(center),
165 _axes(core),
166 _radiusForRadius(radiusForRadius)
167 {}
168
169 explicit KronAperture(afw::table::SourceRecord const& source, float radiusForRadius=std::nanf("")) :
170 _center(geom::Point2D(source.getX(), source.getY())),
171 _axes(source.getShape()),
172 _radiusForRadius(radiusForRadius)
173 {}
174
176 double radius, float radiusForRadius=std::nanf("")) :
177 _center(refToMeas(reference.getCentroid())),
178 _axes(getKronAxes(reference.getShape(), refToMeas.getLinear(), radius)),
179 _radiusForRadius(radiusForRadius)
180 {}
181
183 double getX() const { return _center.getX(); }
184 double getY() const { return _center.getY(); }
185 float getRadiusForRadius() const { return _radiusForRadius; }
186
187 geom::Point2D const& getCenter() const { return _center; }
188
189 afw::geom::ellipses::Axes & getAxes() { return _axes; }
190
191 afw::geom::ellipses::Axes const& getAxes() const { return _axes; }
192
193
198 template<typename ImageT>
200 ImageT const& image,
202 geom::Point2D const& center,
203 KronFluxControl const& ctrl
204 );
205
207 template<typename ImageT>
209 ImageT const& image,
210 double const nRadiusForFlux,
211 double const maxSincRadius
212 ) const;
213
216 geom::Point2D const center = trans(getCenter());
217 afw::geom::ellipses::Axes const axes(*getAxes().transform(trans.getLinear()).copy());
218 return std::make_shared<KronAperture>(center, axes);
219 }
220
222 static
224 afw::geom::ellipses::Axes const& shape,
225 geom::LinearTransform const& transformation,
226 double const radius
227 );
228
229private:
230 geom::Point2D const _center; // Center of aperture
231 afw::geom::ellipses::Axes _axes; // Ellipse defining aperture shape
232 float _radiusForRadius; // Radius used to estimate the Kron radius
233};
234
235}}}} // namespace lsst::meas::extensions::photometryKron
236
237#endif // !LSST_MEAS_EXTENSIONS_PHOTOMETRY_KRON_H
LinearTransform const & getLinear() const noexcept
KronAperture(afw::table::SourceRecord const &reference, geom::AffineTransform const &refToMeas, double radius, float radiusForRadius=std::nanf(""))
afw::geom::ellipses::Axes const & getAxes() const
KronAperture(afw::table::SourceRecord const &source, float radiusForRadius=std::nanf(""))
std::pair< double, double > measureFlux(ImageT const &image, double const nRadiusForFlux, double const maxSincRadius) const
Photometer within the Kron Aperture on an image.
std::shared_ptr< KronAperture > transform(geom::AffineTransform const &trans) const
Transform a Kron Aperture to a different frame.
KronAperture(geom::Point2D const &center, afw::geom::ellipses::BaseCore const &core, float radiusForRadius=std::nanf(""))
static afw::geom::ellipses::Axes getKronAxes(afw::geom::ellipses::Axes const &shape, geom::LinearTransform const &transformation, double const radius)
Determine Kron axes from a reference image.
static std::shared_ptr< KronAperture > determineRadius(ImageT const &image, afw::geom::ellipses::Axes axes, geom::Point2D const &center, KronFluxControl const &ctrl)
Determine the Kron Aperture from an image.
A measurement algorithm that estimates flux using Kron photometry.
static meas::base::FlagDefinition const BAD_RADIUS
static meas::base::FlagDefinition const USED_MINIMUM_RADIUS
static meas::base::FlagDefinition const FAILURE
static meas::base::FlagDefinition const SMALL_RADIUS
KronFluxControl Control
A typedef to the Control object for this algorithm, defined above.
virtual void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
static meas::base::FlagDefinition const BAD_SHAPE
static meas::base::FlagDefinitionList const & getFlagDefinitions()
virtual void measureForced(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure, afw::table::SourceRecord const &refRecord, afw::geom::SkyWcs const &refWcs) const
static meas::base::FlagDefinition const EDGE
static meas::base::FlagDefinition const NO_MINIMUM_RADIUS
static meas::base::FlagDefinition const NO_FALLBACK_RADIUS
static meas::base::FlagDefinition const BAD_SHAPE_NO_PSF
static meas::base::FlagDefinition const USED_PSF_RADIUS
double smoothingSigma
"Smooth image with N(0, smoothingSigma^2) Gaussian while estimating R_K" ;
std::string refRadiusName
"Name of field specifying reference Kron radius for forced measurement" ;
int nIterForRadius
"Number of times to iterate when setting the Kron radius" ;
bool fixed
"if true, use existing shape and centroid measurements instead of fitting" ;
bool useFootprintRadius
"Use the Footprint size as part of initial estimate of Kron radius" ;
double minimumRadius
"Minimum Kron radius (if == 0.0 use PSF's Kron radius) if enforceMinimumRadius. " "Also functions as ...
double maxSincRadius
"Largest aperture for which to use the slow, accurate, sinc aperture code" ;
double nRadiusForFlux
"Number of Kron radii for Kron flux" ;
bool enforceMinimumRadius
"If true check that the Kron radius exceeds some minimum" ;
double nSigmaForRadius
"Multiplier of rms size for aperture used to initially estimate the Kron radius" ;
const char * source()
Point< double, 2 > Point2D
T nanf(T... args)