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;
272 double instFluxToMagnitude(
double instFlux)
const;
285 Measurement instFluxToMagnitude(
double instFlux,
double instFluxErr,
289 Measurement instFluxToMagnitude(
double instFlux,
double instFluxErr)
const;
350 bool includeScaleUncertainty =
true)
const;
366 double magnitudeToInstFlux(
double magnitude)
const;
461 [[deprecated(
"No-op: PhotoCalib never throws on negative instFlux. Will remove after v18.")]]
static void 466 [[deprecated(
"No-op: PhotoCalib never throws on negative instFlux. Will remove after v18.")]]
static bool 475 [deprecated(
"For backwards compatibility with Calib; use `instFluxToMagnitude` instead. To be " 476 "removed after v18.")]]
double 478 return instFluxToMagnitude(instFlux);
485 [deprecated(
"For backwards compatibility with Calib; use `instFluxToMagnitude` instead. To be " 486 "removed after v18.")]] ndarray::Array<double, 1>
487 getMagnitude(ndarray::Array<double const, 1>
const &instFlux)
const;
489 [deprecated(
"For backwards compatibility with Calib; use `instFluxToMagnitude` instead. To be " 492 auto result = instFluxToMagnitude(instFlux, instFluxErr);
493 return std::make_pair<const double &, const double &>(
result.value,
result.error);
496 "For backwards compatibility with Calib; use `instFluxToMagnitude` instead. To be " 498 getMagnitude(ndarray::Array<double const, 1>
const &instFlux,
499 ndarray::Array<double const, 1>
const &instFluxErr)
const;
505 "For backwards compatibility with Calib; use `magnitudeToInstFlux` instead. To be removed " 506 "after v18.")]]
double 508 return magnitudeToInstFlux(magnitude);
515 "For backwards compatibility with Calib: use `getCalibrationMean`, `getCalibrationErr`, or " 518 return std::make_pair<double, double>(getInstFluxAtZeroMagnitude(),
523 "PhotoCalib is immutable: create a new one with the calibration factor and calibration error," 524 " or create it like an old Calib object with makePhotoCalibFromCalibZeroPoint.")]]
void 527 "PhotoCalib is immutable: create a new `PhotoCalib` with the calibration" 528 " factor and error, or create it like an old Calib object with " 529 "`makePhotoCalibFromCalibZeroPoint`.";
544 double _calibrationMean;
547 double _calibrationErr;
565 ndarray::Array<double, 2, 2>
result)
const;
568 ndarray::Array<double, 2, 2> result)
const;
603 #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).