lsst.meas.base  14.0-21-gb9e430a+3
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 
29 #include "lsst/afw/geom/SkyWcs.h"
30 #include "lsst/afw/image/Calib.h"
32 #include "lsst/afw/table/Schema.h"
33 
34 namespace lsst { namespace meas { namespace base {
35 
39 struct FluxResult {
42 
44  FluxResult();
45 
47  explicit FluxResult(Flux flux_, FluxErrElement fluxSigma_) :
48  flux(flux_), fluxSigma(fluxSigma_)
49  {}
50 };
51 
58 class FluxResultKey : public afw::table::FunctorKey<FluxResult> {
59 public:
60 
71  static FluxResultKey addFields(
73  std::string const & name,
74  std::string const & doc
75  );
76 
78  FluxResultKey() : _flux(), _fluxSigma() {}
79 
82  afw::table::Key<meas::base::Flux> const & flux, // namespace qualification to unconfuse swig
84  ) :
85  _flux(flux), _fluxSigma(fluxSigma)
86  {}
87 
97  FluxResultKey(afw::table::SubSchema const & s) : _flux(s["flux"]), _fluxSigma(s["fluxSigma"]) {}
98 
100  virtual FluxResult get(afw::table::BaseRecord const & record) const;
101 
103  virtual void set(afw::table::BaseRecord & record, FluxResult const & other) const;
104 
106  bool operator==(FluxResultKey const & other) const {
108  return _flux == other._flux && _fluxSigma == other._fluxSigma;
109  }
110  bool operator!=(FluxResultKey const & other) const { return !(*this == other); }
112 
114  bool isValid() const { return _flux.isValid() && _fluxSigma.isValid(); }
115 
117  afw::table::Key<meas::base::Flux> getFlux() const { return _flux; }
118 
120  afw::table::Key<FluxErrElement> getFluxSigma() const { return _fluxSigma; }
121 
122 private:
123  afw::table::Key<Flux> _flux;
125 };
126 
130 struct MagResult {
133 };
134 
141 class MagResultKey : public afw::table::FunctorKey<MagResult> {
142 public:
150  static MagResultKey addFields(
152  std::string const & name
153  );
154 
156  MagResultKey() : _magKey(), _magErrKey() {}
157 
166  MagResultKey(afw::table::SubSchema const & s) : _magKey(s["mag"]), _magErrKey(s["magErr"]) {}
167 
169  virtual MagResult get(afw::table::BaseRecord const & record) const;
170 
172  virtual void set(afw::table::BaseRecord & record, MagResult const & magResult) const;
173 
175  virtual void set(afw::table::BaseRecord & record, std::pair<double,double> const & magPair) const;
176 
177 private:
178  afw::table::Key<Mag> _magKey;
180 };
181 
193 class FluxTransform : public BaseTransform {
194 public:
196 
197  /*
198  * @brief Perform transformation from inputCatalog to outputCatalog.
199  *
200  * @param[in] inputCatalog Source of data to be transformed
201  * @param[in,out] outputCatalog Container for transformed results
202  * @param[in] wcs World coordinate system under which transformation will take place
203  * @param[in] calib Photometric calibration under which transformation will take place
204  * @throws LengthError Catalog sizes do not match
205  */
206  virtual void operator()(afw::table::SourceCatalog const & inputCatalog,
207  afw::table::BaseCatalog & outputCatalog,
208  afw::geom::SkyWcs const & wcs,
209  afw::image::Calib const & calib) const;
210 private:
211  MagResultKey _magKey;
212 };
213 
222 public:
225 private:
226  bool _throwOnNegative;
227 };
228 
229 }}} // lsst::meas::base
230 
231 #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:78
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:81
FluxResult(Flux flux_, FluxErrElement fluxSigma_)
Constructor from flux and its uncertainty.
Definition: FluxUtilities.h:47
FluxResultKey(afw::table::SubSchema const &s)
Construct from a subschema, assuming flux and fluxSigma subfields.
Definition: FluxUtilities.h:97
Flux flux
Measured flux in DN.
Definition: FluxUtilities.h:40
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:58
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:83
FluxErrElement fluxSigma
1-Sigma error (sqrt of variance) on flux in DN.
Definition: FluxUtilities.h:41
A reusable result struct for flux measurements.
Definition: FluxUtilities.h:39