LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
ApertureFlux.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2015 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 "lsst/pex/config.h"
29 #include "lsst/afw/table/arrays.h"
36 
37 namespace lsst { namespace meas { namespace base {
38 
43 public:
44 
46 
48  radii, std::vector<double>,
49  "Radius (in pixels) of apertures."
50  );
51 
53  maxSincRadius, double,
54  "Maximum radius (in pixels) for which the sinc algorithm should be used instead of the "
55  "faster naive algorithm. For elliptical apertures, this is the minor axis radius."
56  );
57 
59  shiftKernel, std::string,
60  "Warping kernel used to shift Sinc photometry coefficients to different center positions"
61  );
62 
63 };
64 
65 
66 struct ApertureFluxResult;
67 
68 
83 public:
84 
86  enum FlagBits {
91  };
92 
95 
98 
100 
111  template <typename T>
112  static Result computeSincFlux(
113  afw::image::Image<T> const & image,
114  afw::geom::ellipses::Ellipse const & ellipse,
115  Control const & ctrl=Control()
116  );
117  template <typename T>
118  static Result computeSincFlux(
119  afw::image::MaskedImage<T> const & image,
120  afw::geom::ellipses::Ellipse const & ellipse,
121  Control const & ctrl=Control()
122  );
124 
126 
135  template <typename T>
136  static Result computeNaiveFlux(
137  afw::image::Image<T> const & image,
138  afw::geom::ellipses::Ellipse const & ellipse,
139  Control const & ctrl=Control()
140  );
141  template <typename T>
142  static Result computeNaiveFlux(
143  afw::image::MaskedImage<T> const & image,
144  afw::geom::ellipses::Ellipse const & ellipse,
145  Control const & ctrl=Control()
146  );
148 
150 
161  template <typename T>
162  static Result computeFlux(
163  afw::image::Image<T> const & image,
164  afw::geom::ellipses::Ellipse const & ellipse,
165  Control const & ctrl=Control()
166  );
167 
168  template <typename T>
169  static Result computeFlux(
170  afw::image::MaskedImage<T> const & image,
171  afw::geom::ellipses::Ellipse const & ellipse,
172  Control const & ctrl=Control()
173  );
175 
179  explicit ApertureFluxAlgorithm(
180  Control const & ctrl,
181  std::string const & name,
183  daf::base::PropertySet & metadata
184  );
185 
187 
196  virtual void measure(
197  afw::table::SourceRecord & record,
198  afw::image::Exposure<float> const & exposure
199  ) const = 0;
200 
202  virtual void fail(
203  afw::table::SourceRecord & measRecord,
204  MeasurementError * error=NULL
205  ) const;
206 
219  static std::string makeFieldPrefix(std::string const & name, double radius);
220 
221 protected:
222 
223  void copyResultToRecord(Result const & result, afw::table::SourceRecord & record, int index) const;
224 
225  FlagHandler const & getFlagHandler(int index) const { return _keys[index].flags; }
226 
227  Control const _ctrl;
229 
230 private:
231 
232  struct Keys {
235 
236  Keys(afw::table::Schema & schema, std::string const & prefix, std::string const & doc, bool isSinc);
237  };
238 
239  std::vector<Keys> _keys;
240 };
241 
242 
249 
251  bool getFlag(ApertureFluxAlgorithm::FlagBits bit) const { return _flags[bit]; }
252 
254  void setFlag(ApertureFluxAlgorithm::FlagBits bit, bool value=true) { _flags[bit] = value; }
255 
258 
259 private:
260  std::bitset<ApertureFluxAlgorithm::N_FLAGS> _flags;
261 };
262 
270 public:
272  ApertureFluxTransform(Control const & ctrl, std::string const & name, afw::table::SchemaMapper & mapper);
273 
274  /*
275  * @brief Perform transformation from inputCatalog to outputCatalog.
276  *
277  * @param[in] inputCatalog Source of data to be transformed
278  * @param[in,out] outputCatalog Container for transformed results
279  * @param[in] wcs World coordinate system under which transformation will take place
280  * @param[in] calib Photometric calibration under which transformation will take place
281  * @throws LengthError Catalog sizes do not match
282  */
283  virtual void operator()(afw::table::SourceCatalog const & inputCatalog,
284  afw::table::BaseCatalog & outputCatalog,
285  afw::image::Wcs const & wcs,
286  afw::image::Calib const & calib) const;
287 private:
288  std::vector<MagResultKey> _magKeys;
290 };
291 
292 }}} // namespace lsst::meas::base
293 
294 #endif // !LSST_MEAS_BASE_ApertureFlux_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
void setFlag(ApertureFluxAlgorithm::FlagBits bit, bool value=true)
Set the flag value associated with the given bit.
Definition: ApertureFlux.h:254
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
Definition: ApertureFlux.cc:98
table::Key< std::string > name
Definition: ApCorrMap.cc:71
A custom container class for records, based on std::vector.
Definition: Catalog.h:94
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19
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
tbl::Key< int > wcs
ApertureFluxAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema, daf::base::PropertySet &metadata)
Definition: ApertureFlux.cc:80
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
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:251
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
Definition: config.h:36
void copyResultToRecord(Result const &result, afw::table::SourceRecord &record, int index) const
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:67
def error
Definition: log.py:108
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
static Result computeFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
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:56
static std::string makeFieldPrefix(std::string const &name, double radius)
Definition: ApertureFlux.cc:62
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:77
static Result computeNaiveFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
FlagHandler const & getFlagHandler(int index) const
Definition: ApertureFlux.h:225
void unsetFlag(ApertureFluxAlgorithm::FlagBits bit)
Clear (i.e. set to false) the flag associated with the given bit.
Definition: ApertureFlux.h:257
tbl::Schema schema
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:56
ApertureFluxControl Control
Typedef to the control object associated with this algorithm, defined above.
Definition: ApertureFlux.h:94
Class for storing generic metadata.
Definition: PropertySet.h:82
static Result computeSincFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Record class that contains measurements made on a single exposure.
Definition: Source.h:81
std::vector< MagResultKey > _magKeys
Definition: ApertureFlux.h:288
std::string shiftKernel
&quot;Warping kernel used to shift Sinc photometry coefficients to different center positions&quot; ; ...
Definition: ApertureFlux.h:61
std::vector< double > radii
&quot;Radius (in pixels) of apertures.&quot; ;
Definition: ApertureFlux.h:50
A class to represent a 2-dimensional array of pixels.
Definition: PSF.h:43
std::bitset< ApertureFluxAlgorithm::N_FLAGS > _flags
Definition: ApertureFlux.h:260
ApertureFluxResult Result
Result object returned by static methods.
Definition: ApertureFlux.h:97
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:228