23 #ifndef LSST_AFW_IMAGE_PHOTOCALIB_H 24 #define LSST_AFW_IMAGE_PHOTOCALIB_H 34 #include "boost/format.hpp" 73 (boost::format(
"%s must be positive: %.3g") % name % value).str());
140 : _calibrationMean(calibrationMean), _calibrationErr(
calibrationErr), _isConstant(true) {
143 ndarray::Array<double, 2, 2> coeffs = ndarray::allocate(ndarray::makeVector(1, 1));
145 _calibration = std::make_shared<afw::math::ChebyshevBoundedField>(
156 : _calibration(calibration),
157 _calibrationMean(computeCalibrationMean(calibration)),
160 assertNonNegative(_calibrationMean,
"Calibration (computed via BoundedField.mean()) mean");
174 : _calibration(calibration),
175 _calibrationMean(calibrationMean),
176 _calibrationErr(calibrationErr),
177 _isConstant(isConstant) {
195 double instFluxToNanojansky(
double instFlux)
const;
208 Measurement instFluxToNanojansky(
double instFlux,
double instFluxErr,
212 Measurement instFluxToNanojansky(
double instFlux,
double instFluxErr)
const;
270 double instFluxToMagnitude(
double instFlux)
const;
283 Measurement instFluxToMagnitude(
double instFlux,
double instFluxErr,
287 Measurement instFluxToMagnitude(
double instFlux,
double instFluxErr)
const;
346 bool includeScaleUncertainty =
true)
const;
385 double magnitudeToInstFlux(
double magnitude)
const;
480 [[deprecated(
"No-op: PhotoCalib never throws on negative instFlux. Will remove after v18.")]]
static void 485 [[deprecated(
"No-op: PhotoCalib never throws on negative instFlux. Will remove after v18.")]]
static bool 494 [deprecated(
"For backwards compatibility with Calib; use `instFluxToMagnitude` instead. To be " 495 "removed after v18.")]]
double 497 return instFluxToMagnitude(instFlux);
504 [deprecated(
"For backwards compatibility with Calib; use `instFluxToMagnitude` instead. To be " 505 "removed after v18.")]] ndarray::Array<double, 1>
506 getMagnitude(ndarray::Array<double const, 1>
const &instFlux)
const;
508 [deprecated(
"For backwards compatibility with Calib; use `instFluxToMagnitude` instead. To be " 511 auto result = instFluxToMagnitude(instFlux, instFluxErr);
512 return std::make_pair<const double &, const double &>(
result.value,
result.error);
515 "For backwards compatibility with Calib; use `instFluxToMagnitude` instead. To be " 517 getMagnitude(ndarray::Array<double const, 1>
const &instFlux,
518 ndarray::Array<double const, 1>
const &instFluxErr)
const;
524 "For backwards compatibility with Calib; use `magnitudeToInstFlux` instead. To be removed " 525 "after v18.")]]
double 527 return magnitudeToInstFlux(magnitude);
534 "For backwards compatibility with Calib: use `getCalibrationMean`, `getCalibrationErr`, or " 537 return std::make_pair<double, double>(getInstFluxAtZeroMagnitude(),
542 "PhotoCalib is immutable: create a new one with the calibration factor and calibration error," 543 " or create it like an old Calib object with makePhotoCalibFromCalibZeroPoint.")]]
void 546 "PhotoCalib is immutable: create a new `PhotoCalib` with the calibration" 547 " factor and error, or create it like an old Calib object with " 548 "`makePhotoCalibFromCalibZeroPoint`.";
563 double _calibrationMean;
566 double _calibrationErr;
580 ndarray::Array<double, 1> evaluateArray(ndarray::Array<double, 1>
const &xx,
581 ndarray::Array<double, 1>
const &yy)
const;
593 ndarray::Array<double, 2, 2>
result)
const;
596 ndarray::Array<double, 2, 2> result)
const;
631 #endif // LSST_AFW_IMAGE_PHOTOCALIB_H std::shared_ptr< PhotoCalib > makePhotoCalibFromMetadata(daf::base::PropertySet &metadata, bool strip=false)
Construct a PhotoCalib from FITS FLUXMAG0/FLUXMAG0ERR keywords.
table::Key< double > calibrationErr
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
std::shared_ptr< PhotoCalib > makePhotoCalibFromCalibZeroPoint(double instFluxMag0, double instFluxMag0Err)
Construct a PhotoCalib from the deprecated Calib-style instFluxMag0/instFluxMag0Err values...
PhotoCalib(double calibrationMean, double calibrationErr, std::shared_ptr< afw::math::BoundedField > calibration, bool isConstant)
Create a calibration with a pre-computed mean.
static bool getThrowOnNegativeFlux() noexcept
No-op: for backwards compatibility with Calib (always returns false).
std::ostream & operator<<(std::ostream &os, Measurement const &measurement)
double getCalibrationMean() const
Get the mean photometric calibration.
An object passed to Persistable::write to allow it to persist itself.
The photometric calibration of an exposure.
table::Key< table::Flag > isConstant
bool operator!=(PhotoCalib const &rhs) const
Two PhotoCalibs are equal if their component bounded fields and calibrationErr are equal...
ItemVariant const * other
table::Key< double > calibrationMean
PhotoCalib(double calibrationMean, double calibrationErr=0, lsst::geom::Box2I const &bbox=lsst::geom::Box2I())
Create a non-spatially-varying calibration.
A base class for objects that can be persisted via afw::table::io Archive classes.
A base class for image defects.
static void setThrowOnNegativeFlux(bool raiseException) noexcept
No-op: for backwards compatibility with Calib.
PhotoCalib(std::shared_ptr< afw::math::BoundedField > calibration, double calibrationErr=0)
Create a spatially-varying calibration.
A class to manipulate images, masks, and variance as a single object.
PhotoCalib()
Create a empty, zeroed calibration.
void setFluxMag0(double, double=0) const
Invalid for PhotoCalib: this only exists to provide the user an informative error message...
Measurement(double value, double error)
std::pair< double, double > getMagnitude(double instFlux, double instFluxErr) const
std::unique_ptr< SchemaItem< U > > result
double getCalibrationErr() const
Get the mean photometric calibration error.
#define LSST_EXCEPT(type,...)
A BoundedField based on 2-d Chebyshev polynomials of the first kind.
std::pair< double, double > getFluxMag0() const
Get the magnitude zero point (the instrumental flux corresponding to 0 magnitude).
double getMagnitude(double instFlux) const
Record class that contains measurements made on a single exposure.
void assertNonNegative(double value, std::string const &name)
Raise lsst::pex::exceptions::InvalidParameterError if value is not >=0.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
const double referenceFlux
A CRTP facade class for subclasses of Persistable.
double getFlux(double magnitude) const
double getInstFluxAtZeroMagnitude() const
Get the magnitude zero point (the instrumental flux corresponding to 0 magnitude).