lsst.meas.base  16.0-7-g95fb7bf+2
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 {
35 namespace meas {
36 namespace base {
37 
41 struct FluxResult {
44 
46  FluxResult();
47 
49  explicit FluxResult(Flux flux_, FluxErrElement fluxSigma_) : flux(flux_), fluxSigma(fluxSigma_) {}
50 };
51 
58 class FluxResultKey : public afw::table::FunctorKey<FluxResult> {
59 public:
70  static FluxResultKey addFields(afw::table::Schema& schema, std::string const& name,
71  std::string const& doc);
72 
74  FluxResultKey() : _flux(), _fluxSigma() {}
75 
77  FluxResultKey(afw::table::Key<meas::base::Flux> const& flux, // namespace qualification to unconfuse swig
79  : _flux(flux), _fluxSigma(fluxSigma) {}
80 
90  FluxResultKey(afw::table::SubSchema const& s) : _flux(s["flux"]), _fluxSigma(s["fluxSigma"]) {}
91 
93  virtual FluxResult get(afw::table::BaseRecord const& record) const;
94 
96  virtual void set(afw::table::BaseRecord& record, FluxResult const& other) const;
97 
99  bool operator==(FluxResultKey const& other) const {
101  return _flux == other._flux && _fluxSigma == other._fluxSigma;
102  }
103  bool operator!=(FluxResultKey const& other) const { return !(*this == other); }
105 
107  bool isValid() const { return _flux.isValid() && _fluxSigma.isValid(); }
108 
110  afw::table::Key<meas::base::Flux> getFlux() const { return _flux; }
111 
113  afw::table::Key<FluxErrElement> getFluxSigma() const { return _fluxSigma; }
114 
115 private:
116  afw::table::Key<Flux> _flux;
118 };
119 
123 struct MagResult {
126 };
127 
134 class MagResultKey : public afw::table::FunctorKey<MagResult> {
135 public:
143  static MagResultKey addFields(afw::table::Schema& schema, std::string const& name);
144 
146  MagResultKey() : _magKey(), _magErrKey() {}
147 
156  MagResultKey(afw::table::SubSchema const& s) : _magKey(s["mag"]), _magErrKey(s["magErr"]) {}
157 
159  virtual MagResult get(afw::table::BaseRecord const& record) const;
160 
162  virtual void set(afw::table::BaseRecord& record, MagResult const& magResult) const;
163 
165  virtual void set(afw::table::BaseRecord& record, std::pair<double, double> const& magPair) const;
166 
167 private:
168  afw::table::Key<Mag> _magKey;
170 };
171 
183 class FluxTransform : public BaseTransform {
184 public:
186 
187  /*
188  * @brief Perform transformation from inputCatalog to outputCatalog.
189  *
190  * @param[in] inputCatalog Source of data to be transformed
191  * @param[in,out] outputCatalog Container for transformed results
192  * @param[in] wcs World coordinate system under which transformation will take place
193  * @param[in] calib Photometric calibration under which transformation will take place
194  * @throws LengthError Catalog sizes do not match
195  */
196  virtual void operator()(afw::table::SourceCatalog const& inputCatalog,
197  afw::table::BaseCatalog& outputCatalog, afw::geom::SkyWcs const& wcs,
198  afw::image::Calib const& calib) const;
199 
200 private:
201  MagResultKey _magKey;
202 };
203 
212 public:
215 
216 private:
217  bool _throwOnNegative;
218 };
219 
220 } // namespace base
221 } // namespace meas
222 } // namespace lsst
223 
224 #endif // !LSST_MEAS_BASE_FluxUtilities_h_INCLUDED
double FluxErrElement
Definition: constants.h:52
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:74
Key< int > calib
afw::table::Schema schema
double MagErrElement
Definition: constants.h:54
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)
ItemVariant const * other
SchemaMapper * mapper
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:77
FluxResult(Flux flux_, FluxErrElement fluxSigma_)
Constructor from flux and its uncertainty.
Definition: FluxUtilities.h:49
FluxResultKey(afw::table::SubSchema const &s)
Construct from a subschema, assuming flux and fluxSigma subfields.
Definition: FluxUtilities.h:90
table::Key< table::Array< std::uint8_t > > wcs
Flux flux
Measured flux in DN.
Definition: FluxUtilities.h:42
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:85
FluxErrElement fluxSigma
1-Sigma error (sqrt of variance) on flux in DN.
Definition: FluxUtilities.h:43
A reusable result struct for flux measurements.
Definition: FluxUtilities.h:41