LSST Applications 26.0.0,g0265f82a02+6660c170cc,g07994bdeae+30b05a742e,g0a0026dc87+17526d298f,g0a60f58ba1+17526d298f,g0e4bf8285c+96dd2c2ea9,g0ecae5effc+c266a536c8,g1e7d6db67d+6f7cb1f4bb,g26482f50c6+6346c0633c,g2bbee38e9b+6660c170cc,g2cc88a2952+0a4e78cd49,g3273194fdb+f6908454ef,g337abbeb29+6660c170cc,g337c41fc51+9a8f8f0815,g37c6e7c3d5+7bbafe9d37,g44018dc512+6660c170cc,g4a941329ef+4f7594a38e,g4c90b7bd52+5145c320d2,g58be5f913a+bea990ba40,g635b316a6c+8d6b3a3e56,g67924a670a+bfead8c487,g6ae5381d9b+81bc2a20b4,g93c4d6e787+26b17396bd,g98cecbdb62+ed2cb6d659,g98ffbb4407+81bc2a20b4,g9ddcbc5298+7f7571301f,ga1e77700b3+99e9273977,gae46bcf261+6660c170cc,gb2715bf1a1+17526d298f,gc86a011abf+17526d298f,gcf0d15dbbd+96dd2c2ea9,gdaeeff99f8+0d8dbea60f,gdb4ec4c597+6660c170cc,ge23793e450+96dd2c2ea9,gf041782ebf+171108ac67
LSST Data Management Base Package
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
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");
70 "Maximum aperture radius in pixels; used to avoid excess memory consumption for faint objects");
71
73 fixed(false),
74 nSigmaForRadius(6.0),
76 nRadiusForFlux(2.5),
77 maxSincRadius(10.0),
78 minimumRadius(0.0),
80 useFootprintRadius(false),
81 smoothingSigma(-1.0),
82 refRadiusName("ext_photometryKron_KronFlux_radius"),
83 maxRadius(200.0)
84 {}
85};
86
91public:
92
93 // Structures and routines to manage flaghandler
105
109
111 Control const & ctrl,
112 std::string const & name,
114 daf::base::PropertySet & metadata
115 );
116
117 virtual void measure(
118 afw::table::SourceRecord & measRecord,
119 afw::image::Exposure<float> const & exposure
120 ) const;
121
122 virtual void measureForced(
123 afw::table::SourceRecord & measRecord,
124 afw::image::Exposure<float> const & exposure,
125 afw::table::SourceRecord const & refRecord,
126 afw::geom::SkyWcs const & refWcs
127 ) const;
128
129 virtual void fail(
130 afw::table::SourceRecord & measRecord,
132 ) const;
133
134private:
135
136 void _applyAperture(
138 afw::image::Exposure<float> const& exposure,
139 KronAperture const& aperture
140 ) const;
141
142 void _applyForced(
144 afw::image::Exposure<float> const & exposure,
145 geom::Point2D const & center,
146 afw::table::SourceRecord const & reference,
147 geom::AffineTransform const & refToMeas
148 ) const;
149
150 std::shared_ptr<KronAperture> _fallbackRadius(afw::table::SourceRecord& source, double const R_K_psf,
151 pex::exceptions::Exception& exc) const;
152
153 std::string _name;
154 Control _ctrl;
155 meas::base::FluxResultKey _fluxResultKey;
156 afw::table::Key<float> _radiusKey;
157 afw::table::Key<float> _radiusForRadiusKey;
158 afw::table::Key<float> _psfRadiusKey;
159 meas::base::FlagHandler _flagHandler;
160 meas::base::SafeCentroidExtractor _centroidExtractor;
161};
162
164public:
166 float radiusForRadius=std::nanf("")) :
167 _center(center),
168 _axes(core),
169 _radiusForRadius(radiusForRadius)
170 {}
171
172 explicit KronAperture(afw::table::SourceRecord const& source, float radiusForRadius=std::nanf("")) :
173 _center(geom::Point2D(source.getX(), source.getY())),
174 _axes(source.getShape()),
175 _radiusForRadius(radiusForRadius)
176 {}
177
179 double radius, float radiusForRadius=std::nanf("")) :
180 _center(refToMeas(reference.getCentroid())),
181 _axes(getKronAxes(reference.getShape(), refToMeas.getLinear(), radius)),
182 _radiusForRadius(radiusForRadius)
183 {}
184
186 double getX() const { return _center.getX(); }
187 double getY() const { return _center.getY(); }
188 float getRadiusForRadius() const { return _radiusForRadius; }
189
190 geom::Point2D const& getCenter() const { return _center; }
191
192 afw::geom::ellipses::Axes & getAxes() { return _axes; }
193
194 afw::geom::ellipses::Axes const& getAxes() const { return _axes; }
195
196
201 template<typename ImageT>
203 ImageT const& image,
205 geom::Point2D const& center,
206 KronFluxControl const& ctrl
207 );
208
210 template<typename ImageT>
212 ImageT const& image,
213 double const nRadiusForFlux,
214 double const maxSincRadius
215 ) const;
216
219 geom::Point2D const center = trans(getCenter());
220 afw::geom::ellipses::Axes const axes(*getAxes().transform(trans.getLinear()).copy());
221 return std::make_shared<KronAperture>(center, axes);
222 }
223
225 static
227 afw::geom::ellipses::Axes const& shape,
228 geom::LinearTransform const& transformation,
229 double const radius
230 );
231
232private:
233 geom::Point2D const _center; // Center of aperture
234 afw::geom::ellipses::Axes _axes; // Ellipse defining aperture shape
235 float _radiusForRadius; // Radius used to estimate the Kron radius
236};
237
238}}}} // namespace lsst::meas::extensions::photometryKron
239
240#endif // !LSST_MEAS_EXTENSIONS_PHOTOMETRY_KRON_H
table::Key< int > transform
table::Schema schema
Definition python.h:134
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition SkyWcs.h:117
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a,...
Definition Axes.h:47
A base class for parametrizations of the "core" of an ellipse - the ellipticity and size.
Definition BaseCore.h:55
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition Exposure.h:72
A class used as a handle to a particular field in a table.
Definition Key.h:53
Defines the fields and offsets for a table.
Definition Schema.h:51
Record class that contains measurements made on a single exposure.
Definition Source.h:78
Class for storing generic metadata.
Definition PropertySet.h:66
An affine coordinate transformation consisting of a linear transformation and an offset.
LinearTransform const & getLinear() const noexcept
A 2D linear coordinate transformation.
vector-type utility class to build a collection of FlagDefinitions
Definition FlagHandler.h:60
Utility class for handling flag fields that indicate the failure modes of an algorithm.
A FunctorKey for FluxResult.
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition exceptions.h:48
Utility class for measurement algorithms that extracts a position from the Centroid slot and handles ...
An abstract base classes for which the same implementation can be used for both SingleFrameAlgorithm ...
Definition Algorithm.h:170
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
Handle an exception thrown by the current algorithm by setting flags in the given record.
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Called to measure a single child source in an image.
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
Called to measure a single child source in an image.
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 maxRadius
"Maximum aperture radius in pixels; used to avoid excess memory consumption for faint objects" ;
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" ;
Provides consistent interface for LSST exceptions.
Definition Exception.h:107
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ "control object" structs.
Definition config.h:43
T nanf(T... args)
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
Definition FlagHandler.h:40