LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
ApertureFlux.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2016 AURA/LSST.
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 
24 #ifndef LSST_MEAS_BASE_ApertureFlux_h_INCLUDED
25 #define LSST_MEAS_BASE_ApertureFlux_h_INCLUDED
26 
27 #include <array>
28 #include "lsst/pex/config.h"
30 #include "lsst/afw/table/arrays.h"
37 
38 namespace lsst { namespace meas { namespace base {
39 
44 public:
45 
47 
49  radii, std::vector<double>,
50  "Radius (in pixels) of apertures."
51  );
52 
54  maxSincRadius, double,
55  "Maximum radius (in pixels) for which the sinc algorithm should be used instead of the "
56  "faster naive algorithm. For elliptical apertures, this is the minor axis radius."
57  );
58 
60  shiftKernel, std::string,
61  "Warping kernel used to shift Sinc photometry coefficients to different center positions"
62  );
63 
64 };
65 
66 
67 struct ApertureFluxResult;
68 
69 
84 public:
85 
87  enum FlagBits {
92  };
93 
96 
99 
101 
112  template <typename T>
113  static Result computeSincFlux(
114  afw::image::Image<T> const & image,
115  afw::geom::ellipses::Ellipse const & ellipse,
116  Control const & ctrl=Control()
117  );
118  template <typename T>
119  static Result computeSincFlux(
120  afw::image::MaskedImage<T> const & image,
121  afw::geom::ellipses::Ellipse const & ellipse,
122  Control const & ctrl=Control()
123  );
125 
127 
136  template <typename T>
137  static Result computeNaiveFlux(
138  afw::image::Image<T> const & image,
139  afw::geom::ellipses::Ellipse const & ellipse,
140  Control const & ctrl=Control()
141  );
142  template <typename T>
143  static Result computeNaiveFlux(
144  afw::image::MaskedImage<T> const & image,
145  afw::geom::ellipses::Ellipse const & ellipse,
146  Control const & ctrl=Control()
147  );
149 
151 
162  template <typename T>
163  static Result computeFlux(
164  afw::image::Image<T> const & image,
165  afw::geom::ellipses::Ellipse const & ellipse,
166  Control const & ctrl=Control()
167  );
168 
169  template <typename T>
170  static Result computeFlux(
171  afw::image::MaskedImage<T> const & image,
172  afw::geom::ellipses::Ellipse const & ellipse,
173  Control const & ctrl=Control()
174  );
176 
180  explicit ApertureFluxAlgorithm(
181  Control const & ctrl,
182  std::string const & name,
184  daf::base::PropertySet & metadata
185  );
186 
188 
197  virtual void measure(
198  afw::table::SourceRecord & record,
199  afw::image::Exposure<float> const & exposure
200  ) const = 0;
201 
203  virtual void fail(
204  afw::table::SourceRecord & measRecord,
205  MeasurementError * error=NULL
206  ) const;
207 
220  static std::string makeFieldPrefix(std::string const & name, double radius);
221 
225  static std::array<FlagDefinition,ApertureFluxAlgorithm::N_FLAGS> const & getFlagDefinitions();
226 
227 protected:
228 
229  void copyResultToRecord(Result const & result, afw::table::SourceRecord & record, int index) const;
230 
231  FlagHandler const & getFlagHandler(int index) const { return _keys[index].flags; }
232 
233  Control const _ctrl;
235 
236 private:
237 
238  struct Keys {
241 
242  Keys(afw::table::Schema & schema, std::string const & prefix, std::string const & doc, bool isSinc);
243  };
244 
245  std::vector<Keys> _keys;
246 };
247 
248 
255 
257  bool getFlag(ApertureFluxAlgorithm::FlagBits bit) const { return _flags[bit]; }
258 
260  void setFlag(ApertureFluxAlgorithm::FlagBits bit, bool value=true) { _flags[bit] = value; }
261 
264 
265 private:
266  std::bitset<ApertureFluxAlgorithm::N_FLAGS> _flags;
267 };
268 
276 public:
278  ApertureFluxTransform(Control const & ctrl, std::string const & name, afw::table::SchemaMapper & mapper);
279 
280  /*
281  * @brief Perform transformation from inputCatalog to outputCatalog.
282  *
283  * @param[in] inputCatalog Source of data to be transformed
284  * @param[in,out] outputCatalog Container for transformed results
285  * @param[in] wcs World coordinate system under which transformation will take place
286  * @param[in] calib Photometric calibration under which transformation will take place
287  * @throws LengthError Catalog sizes do not match
288  */
289  virtual void operator()(afw::table::SourceCatalog const & inputCatalog,
290  afw::table::BaseCatalog & outputCatalog,
291  afw::image::Wcs const & wcs,
292  afw::image::Calib const & calib) const;
293 private:
294  std::vector<MagResultKey> _magKeys;
296 };
297 
298 }}} // namespace lsst::meas::base
299 
300 #endif // !LSST_MEAS_BASE_ApertureFlux_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:44
void setFlag(ApertureFluxAlgorithm::FlagBits bit, bool value=true)
Set the flag value associated with the given bit.
Definition: ApertureFlux.h:260
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record...
Definition: ApertureFlux.cc:91
table::Key< std::string > name
Definition: ApCorrMap.cc:71
A custom container class for records, based on std::vector.
Definition: Catalog.h:95
afw::table::Schema schema
Definition: GaussianPsf.cc:41
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19
This defines the base of measurement transformations.
static std::array< FlagDefinition, ApertureFluxAlgorithm::N_FLAGS > const & getFlagDefinitions()
Return the flag definitions which apply to aperture flux measurements.
Definition: ApertureFlux.cc:46
virtual void operator()(afw::table::SourceCatalog const &inputCatalog, afw::table::BaseCatalog &outputCatalog, afw::image::Wcs const &wcs, afw::image::Calib const &calib) const
virtual void measure(afw::table::SourceRecord &record, afw::image::Exposure< float > const &exposure) const =0
Measure the configured apertures on the given image.
tbl::Key< int > wcs
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.
Definition: ApertureFlux.cc:73
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
Utility class for measurement algorithms that extracts a position from the Centroid slot and handles ...
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition: exceptions.h:48
bool getFlag(ApertureFluxAlgorithm::FlagBits bit) const
Return the flag value associated with the given bit.
Definition: ApertureFlux.h:257
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ &quot;control object&quot; structs.
Definition: config.h:36
void copyResultToRecord(Result const &result, afw::table::SourceRecord &record, int index) const
Describe an exposure&#39;s calibration.
Definition: Calib.h:82
Configuration object for multiple-aperture flux algorithms.
Definition: ApertureFlux.h:43
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
Keys(afw::table::Schema &schema, std::string const &prefix, std::string const &doc, bool isSinc)
Definition: ApertureFlux.cc:60
def error
Definition: log.py:103
Utility class for handling flag fields that indicate the failure modes of an algorithm.
Definition: FlagHandler.h:73
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Definition: fwd.h:55
Base class for multiple-aperture photometry algorithms.
Definition: ApertureFlux.h:83
static Result computeFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the flux (and optionally, uncertanties) within an aperture using the algorithm determined by ...
An ellipse defined by an arbitrary BaseCore and a center point.
Definition: Ellipse.h:50
double maxSincRadius
&quot;Maximum radius (in pixels) for which the sinc algorithm should be used instead of the &quot; &quot;faster naiv...
Definition: ApertureFlux.h:57
static std::string makeFieldPrefix(std::string const &name, double radius)
Construct an appropriate prefix for table fields.
Definition: ApertureFlux.cc:55
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:78
static Result computeNaiveFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the flux (and optionally, uncertanties) within an aperture using naive photometry.
FlagHandler const & getFlagHandler(int index) const
Definition: ApertureFlux.h:231
void unsetFlag(ApertureFluxAlgorithm::FlagBits bit)
Clear (i.e. set to false) the flag associated with the given bit.
Definition: ApertureFlux.h:263
Measurement transformation for aperture fluxes.
Definition: ApertureFlux.h:275
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:56
An abstract base classes for which the same implementation can be used for both SingleFrameAlgorithm ...
Definition: Algorithm.h:177
ApertureFluxControl Control
Typedef to the control object associated with this algorithm, defined above.
Definition: ApertureFlux.h:95
Class for storing generic metadata.
Definition: PropertySet.h:82
Abstract base class for all C++ measurement transformations.
Definition: Transform.h:82
static Result computeSincFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the flux (and optionally, uncertanties) within an aperture using Sinc photometry.
Record class that contains measurements made on a single exposure.
Definition: Source.h:80
std::vector< MagResultKey > _magKeys
Definition: ApertureFlux.h:294
std::string shiftKernel
&quot;Warping kernel used to shift Sinc photometry coefficients to different center positions&quot; ; ...
Definition: ApertureFlux.h:62
std::vector< double > radii
&quot;Radius (in pixels) of apertures.&quot; ;
Definition: ApertureFlux.h:51
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:416
std::bitset< ApertureFluxAlgorithm::N_FLAGS > _flags
Definition: ApertureFlux.h:266
ApertureFluxResult Result
Result object returned by static methods.
Definition: ApertureFlux.h:98
ApertureFluxTransform(Control const &ctrl, std::string const &name, afw::table::SchemaMapper &mapper)
A reusable result struct for flux measurements.
Definition: FluxUtilities.h:37
SafeCentroidExtractor _centroidExtractor
Definition: ApertureFlux.h:234
A Result struct for running an aperture flux algorithm with a single radius.
Definition: ApertureFlux.h:254