29 #ifndef LSST_AFW_IMAGE_CALIB_H
30 #define LSST_AFW_IMAGE_CALIB_H
35 #include "ndarray_fwd.h"
36 #include "lsst/base.h"
37 #include "lsst/daf/base/DateTime.h"
49 namespace cameraGeom {
54 static double const JanskysPerABFlux = 3631.0;
57 inline double abMagFromFlux(
double flux) {
return -2.5 * std::log10(flux / JanskysPerABFlux); }
61 return std::abs(fluxErr / (-0.4 * flux * std::log(10)));
65 inline double fluxFromABMag(
double mag) {
return std::pow(10.0, -0.4 * mag) * JanskysPerABFlux; }
69 return std::abs(-0.4 * magErr *
fluxFromABMag(mag) * std::log(10.0));
93 explicit Calib(std::vector<std::shared_ptr<Calib const>>
const& calibs);
97 explicit Calib(std::shared_ptr<lsst::daf::base::PropertySet const>);
109 void setFluxMag0(std::pair<double, double> fluxMag0AndSigma);
120 double getFlux(
double const mag)
const;
130 std::pair<double, double>
getFlux(
double const mag,
double const magErr)
const;
132 ndarray::Array<double, 1>
getFlux(ndarray::Array<double const, 1>
const& mag)
const;
134 std::pair<ndarray::Array<double, 1>, ndarray::Array<double, 1>>
getFlux(
135 ndarray::Array<double const, 1>
const& mag, ndarray::Array<double const, 1>
const& magErr)
const;
150 std::pair<double, double>
getMagnitude(
double const flux,
double const fluxErr)
const;
152 ndarray::Array<double, 1>
getMagnitude(ndarray::Array<double const, 1>
const& flux)
const;
154 std::pair<ndarray::Array<double, 1>, ndarray::Array<double, 1>>
getMagnitude(
155 ndarray::Array<double const, 1>
const& flux,
156 ndarray::Array<double const, 1>
const& fluxErr)
const;
178 (*this) *= 1.0 /
scale;
191 double _fluxMag0Sigma;
195 static bool _throwOnNegativeFlux;
211 #endif // LSST_AFW_IMAGE_CALIB_H
Calib & operator/=(double const scale)
double abMagErrFromFluxErr(double fluxErr, double flux)
Compute AB magnitude error from flux and flux error in Janskys.
double fluxErrFromABMagErr(double magErr, double mag)
Compute flux error in Janskys from AB magnitude error and AB magnitude.
table::Key< double > fluxMag0Sigma
double abMagFromFlux(double flux)
Compute AB magnitude from flux in Janskys.
Describe an exposure's calibration.
Calib & operator*=(double const scale)
A base class for objects that can be persisted via afw::table::io Archive classes.
double fluxFromABMag(double mag)
Compute flux in Janskys from AB magnitude.
bool operator==(Calib const &rhs) const
Are two Calibs identical?
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
static void setThrowOnNegativeFlux(bool raiseException)
Set whether Calib should throw an exception when asked to convert a flux to a magnitude.
std::pair< double, double > getFluxMag0() const
Return the flux, and error in flux, of a zero-magnitude object.
int stripCalibKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Calib-related keywords from the metadata.
double getFlux(double const mag) const
Return a flux (in ADUs) given a magnitude.
lsst::daf::base::PropertySet PropertySet
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
void setFluxMag0(double fluxMag0, double fluxMag0Sigma=0.0)
Set the flux of a zero-magnitude object.
io::OutputArchiveHandle OutputArchiveHandle
static bool getThrowOnNegativeFlux()
Tell me whether Calib will throw an exception if asked to convert a flux to a magnitude.
table::Key< double > fluxMag0
bool operator!=(Calib const &rhs) const
A CRTP facade class for subclasses of Persistable.
double getMagnitude(double const flux) const
Return a magnitude given a flux.
bool isPersistable() const
Return true if this particular object can be persisted using afw::table::io.