lsst.meas.base  14.0-9-g876143c
FluxUtilities.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_FluxUtilities_h_INCLUDED
25 #define LSST_MEAS_BASE_FluxUtilities_h_INCLUDED
26 
30 #include "lsst/afw/table/Schema.h"
31 
32 namespace lsst { namespace meas { namespace base {
33 
37 struct FluxResult {
40 
42  FluxResult();
43 
45  explicit FluxResult(Flux flux_, FluxErrElement fluxSigma_) :
46  flux(flux_), fluxSigma(fluxSigma_)
47  {}
48 };
49 
56 class FluxResultKey : public afw::table::FunctorKey<FluxResult> {
57 public:
58 
69  static FluxResultKey addFields(
71  std::string const & name,
72  std::string const & doc
73  );
74 
76  FluxResultKey() : _flux(), _fluxSigma() {}
77 
80  afw::table::Key<meas::base::Flux> const & flux, // namespace qualification to unconfuse swig
82  ) :
83  _flux(flux), _fluxSigma(fluxSigma)
84  {}
85 
95  FluxResultKey(afw::table::SubSchema const & s) : _flux(s["flux"]), _fluxSigma(s["fluxSigma"]) {}
96 
98  virtual FluxResult get(afw::table::BaseRecord const & record) const;
99 
101  virtual void set(afw::table::BaseRecord & record, FluxResult const & other) const;
102 
104  bool operator==(FluxResultKey const & other) const {
106  return _flux == other._flux && _fluxSigma == other._fluxSigma;
107  }
108  bool operator!=(FluxResultKey const & other) const { return !(*this == other); }
110 
112  bool isValid() const { return _flux.isValid() && _fluxSigma.isValid(); }
113 
115  afw::table::Key<meas::base::Flux> getFlux() const { return _flux; }
116 
118  afw::table::Key<FluxErrElement> getFluxSigma() const { return _fluxSigma; }
119 
120 private:
121  afw::table::Key<Flux> _flux;
123 };
124 
128 struct MagResult {
131 };
132 
139 class MagResultKey : public afw::table::FunctorKey<MagResult> {
140 public:
148  static MagResultKey addFields(
150  std::string const & name
151  );
152 
154  MagResultKey() : _magKey(), _magErrKey() {}
155 
164  MagResultKey(afw::table::SubSchema const & s) : _magKey(s["mag"]), _magErrKey(s["magErr"]) {}
165 
167  virtual MagResult get(afw::table::BaseRecord const & record) const;
168 
170  virtual void set(afw::table::BaseRecord & record, MagResult const & magResult) const;
171 
173  virtual void set(afw::table::BaseRecord & record, std::pair<double,double> const & magPair) const;
174 
175 private:
176  afw::table::Key<Mag> _magKey;
178 };
179 
191 class FluxTransform : public BaseTransform {
192 public:
194 
195  /*
196  * @brief Perform transformation from inputCatalog to outputCatalog.
197  *
198  * @param[in] inputCatalog Source of data to be transformed
199  * @param[in,out] outputCatalog Container for transformed results
200  * @param[in] wcs World coordinate system under which transformation will take place
201  * @param[in] calib Photometric calibration under which transformation will take place
202  * @throws LengthError Catalog sizes do not match
203  */
204  virtual void operator()(afw::table::SourceCatalog const & inputCatalog,
205  afw::table::BaseCatalog & outputCatalog,
206  afw::image::Wcs const & wcs,
207  afw::image::Calib const & calib) const;
208 private:
209  MagResultKey _magKey;
210 };
211 
220 public:
223 private:
224  bool _throwOnNegative;
225 };
226 
227 }}} // lsst::meas::base
228 
229 #endif // !LSST_MEAS_BASE_FluxUtilities_h_INCLUDED
double FluxErrElement
Definition: constants.h:50
MagResultKey(afw::table::SubSchema const &s)
Construct from a subschema, assuming mag and magErr subfields.
afw::table::Key< meas::base::Flux > getFlux() const
Return the underlying flux Key.
FluxResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: FluxUtilities.h:76
afw::table::Schema schema
double MagErrElement
Definition: constants.h:52
This defines the base of measurement transformations.
A FunctorKey for MagResult.
Temporarily replace negative fluxes with NaNs.
A reusable result struct for magnitudes.
bool operator==(CoordKey const &lhs, CoordKey const &rhs)
FluxResult()
Default constructor; initializes everything to NaN.
Base for flux measurement transformations.
string name
STL class.
FluxResultKey(afw::table::Key< meas::base::Flux > const &flux, afw::table::Key< FluxErrElement > const &fluxSigma)
Construct from a pair of Keys.
Definition: FluxUtilities.h:79
FluxResult(Flux flux_, FluxErrElement fluxSigma_)
Constructor from flux and its uncertainty.
Definition: FluxUtilities.h:45
FluxResultKey(afw::table::SubSchema const &s)
Construct from a subschema, assuming flux and fluxSigma subfields.
Definition: FluxUtilities.h:95
Flux flux
Measured flux in DN.
Definition: FluxUtilities.h:38
bool operator!=(FluxResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying flux and fluxSigma Keys...
MagResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:56
bool isValid() const
Return True if both the flux and fluxSigma Keys are valid.
afw::table::Key< FluxErrElement > getFluxSigma() const
Return the underlying fluxSigma Key.
Abstract base class for all C++ measurement transformations.
Definition: Transform.h:82
FluxErrElement fluxSigma
1-Sigma error (sqrt of variance) on flux in DN.
Definition: FluxUtilities.h:39
A reusable result struct for flux measurements.
Definition: FluxUtilities.h:37