LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Calib.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 //
31 #ifndef LSST_AFW_IMAGE_CALIB_H
32 #define LSST_AFW_IMAGE_CALIB_H
33 
34 #include <cmath>
35 #include <utility>
36 #include "boost/shared_ptr.hpp"
37 #include "ndarray_fwd.h"
38 #include "lsst/base.h"
39 #include "lsst/daf/base/DateTime.h"
40 #include "lsst/afw/geom/Point.h"
42 
43 namespace lsst {
44 namespace daf {
45  namespace base {
46  class PropertySet;
47  }
48 }
49 
50 namespace afw {
51 namespace cameraGeom {
52  class Detector;
53 }
54 namespace image {
55 
56 static double const JanskysPerABFlux = 3631.0;
57 
59 inline double abMagFromFlux(double flux) {
60  return -2.5*std::log10(flux/JanskysPerABFlux);
61 }
62 
64 inline double abMagErrFromFluxErr(double fluxErr, double flux) {
65  return std::abs(fluxErr/(-0.4*flux*std::log(10)));
66 }
67 
69 inline double fluxFromABMag(double mag) {
70  return std::pow(10.0, -0.4*mag)*JanskysPerABFlux;
71 }
72 
74 inline double fluxErrFromABMagErr(double magErr, double mag) {
75  return std::abs(-0.4*magErr*fluxFromABMag(mag)*std::log(10.0));
76 }
77 
83 public :
84  typedef boost::shared_ptr<Calib> Ptr;
85  typedef boost::shared_ptr<Calib const> ConstPtr;
86 
87  explicit Calib();
88  explicit Calib(std::vector<CONST_PTR(Calib)> const& calibs);
90 
93  lsst::daf::base::DateTime getMidTime(boost::shared_ptr<const lsst::afw::cameraGeom::Detector>,
94  lsst::afw::geom::Point2I const&) const;
95 
96  void setExptime(double exptime);
97  double getExptime() const;
98 
99  void setFluxMag0(double fluxMag0, double fluxMag0Sigma=0.0);
100  void setFluxMag0(std::pair<double, double> fluxMag0AndSigma);
101  std::pair<double, double> getFluxMag0() const;
102 
103  double getFlux(double const mag) const;
104 
105  std::pair<double, double> getFlux(double const mag, double const magErr) const;
106 
108 
109  std::pair< ndarray::Array<double,1>, ndarray::Array<double,1> > getFlux(
110  ndarray::Array<double const,1> const & mag,
111  ndarray::Array<double const,1> const & magErr
112  ) const;
113 
114  double getMagnitude(double const flux) const;
115 
116  std::pair<double, double> getMagnitude(double const flux, double const fluxErr) const;
117 
119 
120  std::pair< ndarray::Array<double,1>,ndarray::Array<double,1> > getMagnitude(
121  ndarray::Array<double const,1> const & flux,
122  ndarray::Array<double const,1> const & fluxErr
123  ) const;
124 
125  static void setThrowOnNegativeFlux(bool raiseException);
126  static bool getThrowOnNegativeFlux();
127  /*
128  * Compare two Calibs
129  */
130  bool operator==(Calib const& rhs) const;
131  bool operator!=(Calib const& rhs) const { return !(*this == rhs); }
132 
133  bool isPersistable() const { return true; }
134 
135 protected:
136 
137  virtual std::string getPersistenceName() const;
138 
139  virtual void write(OutputArchiveHandle & handle) const;
140 
141 private:
143  double _exptime;
144  double _fluxMag0;
146  static bool _throwOnNegativeFlux;
147 };
148 
149 namespace detail {
151 }
152 
153 }}} // lsst::afw::image
154 
155 #endif // LSST_AFW_IMAGE_CALIB_H
A coordinate class intended to represent absolute positions.
Class for handling dates/times, including MJD, UTC, and TAI.
Definition: DateTime.h:58
table::Key< double > fluxMag0Sigma
Definition: Calib.cc:487
double abMagErrFromFluxErr(double fluxErr, double flux)
Compute AB magnitude error from flux and flux error in Janskys.
Definition: Calib.h:64
double fluxErrFromABMagErr(double magErr, double mag)
Compute flux error in Janskys from AB magnitude error and AB magnitude.
Definition: Calib.h:74
#define PTR(...)
Definition: base.h:41
table::Key< boost::int64_t > midTime
Definition: Calib.cc:484
Forward declarations and default template parameters for ndarray.
double abMagFromFlux(double flux)
Compute AB magnitude from flux in Janskys.
Definition: Calib.h:59
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
double fluxFromABMag(double mag)
Compute flux in Janskys from AB magnitude.
Definition: Calib.h:69
bool operator==(Calib const &rhs) const
Definition: Calib.cc:197
def log
Definition: log.py:85
void setExptime(double exptime)
Definition: Calib.cc:241
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
Definition: Calib.cc:535
static void setThrowOnNegativeFlux(bool raiseException)
Definition: Calib.cc:138
double getExptime() const
Definition: Calib.cc:249
std::pair< double, double > getFluxMag0() const
Definition: Calib.cc:274
static bool _throwOnNegativeFlux
Definition: Calib.h:146
Interface for DateTime class.
int stripCalibKeywords(boost::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Calib.cc:159
double getFlux(double const mag) const
Definition: Calib.cc:329
A multidimensional strided array.
Definition: Array.h:47
Class for storing generic metadata.
Definition: PropertySet.h:82
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
Definition: Calib.cc:537
boost::shared_ptr< Calib const > ConstPtr
Definition: Calib.h:85
void setFluxMag0(double fluxMag0, double fluxMag0Sigma=0.0)
Definition: Calib.cc:257
#define CONST_PTR(...)
Definition: base.h:47
io::OutputArchiveHandle OutputArchiveHandle
Definition: Persistable.h:114
static bool getThrowOnNegativeFlux()
Definition: Calib.cc:148
table::Key< double > fluxMag0
Definition: Calib.cc:486
bool operator!=(Calib const &rhs) const
Definition: Calib.h:131
lsst::daf::base::DateTime getMidTime() const
Definition: Calib.cc:219
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:182
lsst::daf::base::DateTime _midTime
Definition: Calib.h:142
double getMagnitude(double const flux) const
Definition: Calib.cc:391
bool isPersistable() const
Return true if this particular object can be persisted using afw::table::io.
Definition: Calib.h:133
boost::shared_ptr< Calib > Ptr
Definition: Calib.h:84
void setMidTime(lsst::daf::base::DateTime const &midTime)
Definition: Calib.cc:210