LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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:44
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:340
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:95
afw::table::Schema schema
Definition: GaussianPsf.cc:41
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19
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.
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)
Add a pair of _flux, _fluxSigma fields to a Schema, and return a FluxResultKey that points to them...
FluxResult()
Default constructor; initializes everything to NaN.
Base for flux measurement transformations.
Describe an exposure&#39;s calibration.
Definition: Calib.h:82
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
bool isValid() const
Return true if the key was initialized to valid offset.
Definition: Key.h:83
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
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)
Add a pair of _mag, _magErr fields to a Schema, and return a MagResultKey that points to them...
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.
Abstract base class for all C++ measurement transformations.
Definition: Transform.h:82
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
Convenience base class that combines the OutputFunctorKey and InputFunctorKey.
Definition: FunctorKey.h:70
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...