LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
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"
32 #include "lsst/afw/geom/SkyWcs.h"
38 
39 namespace lsst { namespace meas { namespace extensions { namespace photometryKron {
40 
41 class KronAperture;
42 
49 public:
50 
52  "if true, use existing shape and centroid measurements instead of fitting");
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");
58  "Largest aperture for which to use the slow, accurate, sinc aperture code");
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");
64  "Use the Footprint size as part of initial estimate of Kron radius");
66  "Smooth image with N(0, smoothingSigma^2) Gaussian while estimating R_K");
68  "Name of field specifying reference Kron radius for forced measurement");
69 
71  fixed(false),
72  nSigmaForRadius(6.0),
73  nIterForRadius(1),
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 
88 public:
89 
90  // Structures and routines to manage flaghandler
102 
106 
108  Control const & ctrl,
109  std::string const & name,
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 
131 private:
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  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 
161 public:
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 
175  KronAperture(afw::table::SourceRecord const& reference, geom::AffineTransform const& refToMeas,
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 
229 private:
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
schema
table::Schema schema
Definition: Amplifier.cc:115
lsst::meas::extensions::photometryKron::KronAperture::getX
double getX() const
Accessors.
Definition: photometryKron.h:183
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::meas::base::SimpleAlgorithm
An abstract base classes for which the same implementation can be used for both SingleFrameAlgorithm ...
Definition: Algorithm.h:170
lsst::meas::extensions::photometryKron::KronAperture::getAxes
afw::geom::ellipses::Axes const & getAxes() const
Definition: photometryKron.h:191
std::nanf
T nanf(T... args)
lsst::meas::extensions::photometryKron::KronFluxControl::minimumRadius
double minimumRadius
"Minimum Kron radius (if == 0.0 use PSF's Kron radius) if enforceMinimumRadius. " "Also functions as ...
Definition: photometryKron.h:61
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::NO_FALLBACK_RADIUS
static meas::base::FlagDefinition const NO_FALLBACK_RADIUS
Definition: photometryKron.h:96
std::string
STL class.
CentroidUtilities.h
lsst::log.log.logContinued.error
def error(fmt, *args)
Definition: logContinued.py:213
lsst::afw::table::SourceRecord
Record class that contains measurements made on a single exposure.
Definition: Source.h:80
lsst::afw::image::Exposure< float >
std::pair< double, double >
lsst::meas::extensions::photometryKron::KronFluxControl::fixed
bool fixed
"if true, use existing shape and centroid measurements instead of fitting" ;
Definition: photometryKron.h:52
lsst::meas::extensions::photometryKron::KronAperture::transform
boost::shared_ptr< KronAperture > transform(geom::AffineTransform const &trans) const
Transform a Kron Aperture to a different frame.
Definition: photometryKron.h:215
lsst::geom::LinearTransform
A 2D linear coordinate transformation.
Definition: LinearTransform.h:69
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::KronFluxAlgorithm
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.
Definition: KronPhotometry.cc:366
FluxUtilities.h
lsst::meas::extensions::photometryKron::KronAperture::getRadiusForRadius
float getRadiusForRadius() const
Definition: photometryKron.h:185
lsst::meas::base::MeasurementError
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition: exceptions.h:48
SkyWcs.h
lsst::meas::extensions::photometryKron::KronFluxControl
C++ control object for Kron flux.
Definition: photometryKron.h:48
lsst::afw::table::Schema
Defines the fields and offsets for a table.
Definition: Schema.h:50
lsst::meas::extensions::photometryKron::KronFluxControl::nSigmaForRadius
double nSigmaForRadius
"Multiplier of rms size for aperture used to initially estimate the Kron radius" ;
Definition: photometryKron.h:54
InputUtilities.h
lsst::meas::base::SafeCentroidExtractor
Utility class for measurement algorithms that extracts a position from the Centroid slot and handles ...
Definition: InputUtilities.h:39
lsst::afw::geom::ellipses::Axes
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a,...
Definition: Axes.h:47
lsst::afw::geom::SkyWcs
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:117
lsst.pipe.tasks.processCcdWithFakes.radius
radius
Definition: processCcdWithFakes.py:345
lsst::geom::Point2D
Point< double, 2 > Point2D
Definition: Point.h:324
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::Control
KronFluxControl Control
A typedef to the Control object for this algorithm, defined above.
Definition: photometryKron.h:105
lsst::meas::base::FluxResultKey
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:59
lsst::meas::extensions::photometryKron::KronAperture::getY
double getY() const
Definition: photometryKron.h:184
PTR
#define PTR(...)
Definition: base.h:41
lsst::meas::extensions::photometryKron::KronAperture
Definition: photometryKron.h:160
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::USED_PSF_RADIUS
static meas::base::FlagDefinition const USED_PSF_RADIUS
Definition: photometryKron.h:99
lsst::meas::extensions::photometryKron::KronAperture::KronAperture
KronAperture(afw::table::SourceRecord const &source, float radiusForRadius=std::nanf(""))
Definition: photometryKron.h:169
lsst::meas::base::FlagDefinitionList
vector-type utility class to build a collection of FlagDefinitions
Definition: FlagHandler.h:60
lsst::geom::AffineTransform
An affine coordinate transformation consisting of a linear transformation and an offset.
Definition: AffineTransform.h:75
ast::detail::source
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224
lsst::meas::extensions::photometryKron::KronAperture::getKronAxes
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.
Definition: KronPhotometry.cc:222
lsst::afw::geom::ellipses::BaseCore
A base class for parametrizations of the "core" of an ellipse - the ellipticity and size.
Definition: BaseCore.h:55
lsst::meas::extensions::photometryKron::KronFluxControl::nRadiusForFlux
double nRadiusForFlux
"Number of Kron radii for Kron flux" ;
Definition: photometryKron.h:56
lsst::meas::base::FlagHandler
Utility class for handling flag fields that indicate the failure modes of an algorithm.
Definition: FlagHandler.h:148
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::EDGE
static meas::base::FlagDefinition const EDGE
Definition: photometryKron.h:93
lsst::meas::extensions::photometryKron::KronFluxAlgorithm
A measurement algorithm that estimates flux using Kron photometry.
Definition: photometryKron.h:87
lsst::geom::AffineTransform::getLinear
LinearTransform const & getLinear() const noexcept
Definition: AffineTransform.h:155
lsst::meas::extensions::photometryKron::KronFluxControl::useFootprintRadius
bool useFootprintRadius
"Use the Footprint size as part of initial estimate of Kron radius" ;
Definition: photometryKron.h:64
lsst::meas::extensions::photometryKron::KronAperture::measureFlux
std::pair< double, double > measureFlux(ImageT const &image, double const nRadiusForFlux, double const maxSincRadius) const
Photometer within the Kron Aperture on an image.
Definition: KronPhotometry.cc:346
lsst::afw::table::Key< float >
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::BAD_SHAPE
static meas::base::FlagDefinition const BAD_SHAPE
Definition: photometryKron.h:101
LSST_CONTROL_FIELD
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ "control object" structs.
Definition: config.h:43
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::measure
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Called to measure a single child source in an image.
Definition: KronPhotometry.cc:455
Algorithm.h
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::SMALL_RADIUS
static meas::base::FlagDefinition const SMALL_RADIUS
Definition: photometryKron.h:100
lsst::meas::extensions::photometryKron::KronAperture::KronAperture
KronAperture(afw::table::SourceRecord const &reference, geom::AffineTransform const &refToMeas, double radius, float radiusForRadius=std::nanf(""))
Definition: photometryKron.h:175
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::BAD_SHAPE_NO_PSF
static meas::base::FlagDefinition const BAD_SHAPE_NO_PSF
Definition: photometryKron.h:94
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::meas::extensions::photometryKron::KronFluxControl::enforceMinimumRadius
bool enforceMinimumRadius
"If true check that the Kron radius exceeds some minimum" ;
Definition: photometryKron.h:62
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::FAILURE
static meas::base::FlagDefinition const FAILURE
Definition: photometryKron.h:92
lsst::geom
Definition: AffineTransform.h:36
lsst::meas::base::FlagDefinition
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
Definition: FlagHandler.h:40
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::BAD_RADIUS
static meas::base::FlagDefinition const BAD_RADIUS
Definition: photometryKron.h:97
lsst::meas::extensions::photometryKron::KronFluxControl::refRadiusName
std::string refRadiusName
"Name of field specifying reference Kron radius for forced measurement" ;
Definition: photometryKron.h:68
lsst::meas::extensions::photometryKron::KronAperture::getCenter
geom::Point2D const & getCenter() const
Definition: photometryKron.h:187
FlagHandler.h
lsst::meas::extensions::photometryKron::KronAperture::determineRadius
static boost::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.
Definition: KronPhotometry.cc:234
lsst::meas::extensions::photometryKron::KronAperture::KronAperture
KronAperture(geom::Point2D const &center, afw::geom::ellipses::BaseCore const &core, float radiusForRadius=std::nanf(""))
Definition: photometryKron.h:162
lsst::geom::Point< double, 2 >
lsst::meas::extensions::photometryKron::KronFluxControl::maxSincRadius
double maxSincRadius
"Largest aperture for which to use the slow, accurate, sinc aperture code" ;
Definition: photometryKron.h:58
lsst::daf::base::PropertySet
Class for storing generic metadata.
Definition: PropertySet.h:67
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::getFlagDefinitions
static meas::base::FlagDefinitionList const & getFlagDefinitions()
Definition: KronPhotometry.cc:66
config.h
lsst.pex::exceptions::Exception
Provides consistent interface for LSST exceptions.
Definition: Exception.h:107
lsst::meas::extensions::photometryKron::KronFluxControl::nIterForRadius
int nIterForRadius
"Number of times to iterate when setting the Kron radius" ;
Definition: photometryKron.h:55
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::fail
virtual void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record.
Definition: KronPhotometry.cc:388
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::NO_MINIMUM_RADIUS
static meas::base::FlagDefinition const NO_MINIMUM_RADIUS
Definition: photometryKron.h:95
Exposure.h
lsst::meas::extensions::photometryKron.name
name
Definition: __init__.py:30
lsst::meas::extensions::photometryKron::KronAperture::getAxes
afw::geom::ellipses::Axes & getAxes()
Definition: photometryKron.h:189
geom.h
lsst::meas::extensions::photometryKron::KronFluxControl::KronFluxControl
KronFluxControl()
Definition: photometryKron.h:70
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::measureForced
virtual void measureForced(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure, afw::table::SourceRecord const &refRecord, afw::geom::SkyWcs const &refWcs) const
Called to measure a single child source in an image.
Definition: KronPhotometry.cc:563
lsst::meas::extensions::photometryKron::KronFluxAlgorithm::USED_MINIMUM_RADIUS
static meas::base::FlagDefinition const USED_MINIMUM_RADIUS
Definition: photometryKron.h:98
lsst::meas::extensions::photometryKron::KronFluxControl::smoothingSigma
double smoothingSigma
"Smooth image with N(0, smoothingSigma^2) Gaussian while estimating R_K" ;
Definition: photometryKron.h:66