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
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 
77 
80  afw::table::Key<meas::base::Flux> const & flux, // namespace qualification to unconfuse swig
81  afw::table::Key<FluxErrElement> const & fluxSigma
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 
116 
119 
120 private:
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 
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:
178 };
179 
191 class FluxTransform : public BaseTransform {
192 public:
193  FluxTransform(std::string const & name, afw::table::SchemaMapper & mapper);
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:
210 };
211 
220 public:
223 private:
225 };
226 
227 }}} // lsst::meas::base
228 
229 #endif // !LSST_MEAS_BASE_FluxUtilities_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
double FluxErrElement
Definition: constants.h:50
bool operator==(FluxResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying flux and fluxSigma Keys...
virtual void operator()(afw::table::SourceCatalog const &inputCatalog, afw::table::BaseCatalog &outputCatalog, afw::image::Wcs const &wcs, afw::image::Calib const &calib) const
MagResultKey(afw::table::SubSchema const &s)
Construct from a subschema, assuming mag and magErr subfields.
A proxy type for name lookups in a Schema.
Definition: Schema.h:330
table::Key< std::string > name
Definition: ApCorrMap.cc:71
FluxResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: FluxUtilities.h:76
virtual void set(afw::table::BaseRecord &record, FluxResult const &other) const
Set a FluxResult in the given record.
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
double MagErrElement
Definition: constants.h:52
A FunctorKey for MagResult.
bool isValid() const
Return true if the key was initialized to valid offset.
Definition: Key.h:83
A reusable result struct for magnitudes.
tbl::Key< int > wcs
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
afw::table::Key< Mag > _magKey
static FluxResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)
FluxResult()
Default constructor; initializes everything to NaN.
afw::table::Key< MagErrElement > _magErrKey
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
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
afw::table::Key< Flux > _flux
bool isValid() const
Return True if both the flux and fluxSigma Keys are valid.
Flux flux
Measured flux in DN.
Definition: FluxUtilities.h:38
tbl::Schema schema
MagResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:56
static MagResultKey addFields(afw::table::Schema &schema, std::string const &name)
FluxTransform(std::string const &name, afw::table::SchemaMapper &mapper)
Base class for all records.
Definition: BaseRecord.h:27
A class used as a handle to a particular field in a table.
Definition: fwd.h:44
virtual void set(afw::table::BaseRecord &record, MagResult const &magResult) const
Set a MagResult in the given record.
afw::table::Key< meas::base::Flux > getFlux() const
Return the underlying flux Key.
afw::table::Key< FluxErrElement > getFluxSigma() const
Return the underlying fluxSigma Key.
FluxErrElement fluxSigma
1-Sigma error (sqrt of variance) on flux in DN.
Definition: FluxUtilities.h:39
afw::table::Key< FluxErrElement > _fluxSigma
A reusable result struct for flux measurements.
Definition: FluxUtilities.h:37
bool operator!=(FluxResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying flux and fluxSigma Keys...