LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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
static std::array< FlagDefinition, ApertureFluxAlgorithm::N_FLAGS > const & getFlagDefinitions()
Definition: ApertureFlux.cc:46
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
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
SafeCentroidExtractor _centroidExtractor
Definition: ApertureFlux.h:234
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19
static Result computeSincFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
std::vector< double > radii
&quot;Radius (in pixels) of apertures.&quot; ;
Definition: ApertureFlux.h:51
virtual void operator()(afw::table::SourceCatalog const &inputCatalog, afw::table::BaseCatalog &outputCatalog, afw::image::Wcs const &wcs, afw::image::Calib const &calib) const
tbl::Key< int > wcs
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
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
Definition: config.h:36
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
FlagHandler const & getFlagHandler(int index) const
Definition: ApertureFlux.h:231
ApertureFluxControl Control
Typedef to the control object associated with this algorithm, defined above.
Definition: ApertureFlux.h:95
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
void unsetFlag(ApertureFluxAlgorithm::FlagBits bit)
Clear (i.e. set to false) the flag associated with the given bit.
Definition: ApertureFlux.h:263
def error
Definition: log.py:103
virtual void measure(afw::table::SourceRecord &record, afw::image::Exposure< float > const &exposure) const =0
ApertureFluxTransform(Control const &ctrl, std::string const &name, afw::table::SchemaMapper &mapper)
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
ApertureFluxResult Result
Result object returned by static methods.
Definition: ApertureFlux.h:98
An ellipse defined by an arbitrary BaseCore and a center point.
Definition: Ellipse.h:50
bool getFlag(ApertureFluxAlgorithm::FlagBits bit) const
Return the flag value associated with the given bit.
Definition: ApertureFlux.h:257
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:78
void copyResultToRecord(Result const &result, afw::table::SourceRecord &record, int index) const
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:56
ApertureFluxAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema, daf::base::PropertySet &metadata)
Definition: ApertureFlux.cc:73
static std::string makeFieldPrefix(std::string const &name, double radius)
Definition: ApertureFlux.cc:55
std::bitset< ApertureFluxAlgorithm::N_FLAGS > _flags
Definition: ApertureFlux.h:266
void setFlag(ApertureFluxAlgorithm::FlagBits bit, bool value=true)
Set the flag value associated with the given bit.
Definition: ApertureFlux.h:260
Class for storing generic metadata.
Definition: PropertySet.h:82
Keys(afw::table::Schema &schema, std::string const &prefix, std::string const &doc, bool isSinc)
Definition: ApertureFlux.cc:60
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
Record class that contains measurements made on a single exposure.
Definition: Source.h:80
static Result computeNaiveFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
A class to represent a 2-dimensional array of pixels.
Definition: PSF.h:43
A reusable result struct for flux measurements.
Definition: FluxUtilities.h:37
static Result computeFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())