LSST Applications g0fba68d861+539c3c8198,g1ec0fe41b4+f0b7a83aa5,g1fd858c14a+78b1f303e5,g22210bfa2a+8e34e7f00e,g2440f9efcc+8c5ae1fdc5,g3533f9d6cb+f4db8b1b3b,g35bb328faa+8c5ae1fdc5,g3fc7d4f5b9+a4d3a2d8bb,g40d01f57dd+ad4ae80abb,g4178042926+abd409f097,g53246c7159+8c5ae1fdc5,g548d740b8c+47e4a7beb3,g60b5630c4e+f4db8b1b3b,g663da51e9b+e0f2ae43b2,g67b6fd64d1+c104138150,g78460c75b0+7e33a9eb6d,g786e29fd12+668abc6043,g8352419a5c+8c5ae1fdc5,g8852436030+d435302cbd,g89139ef638+c104138150,g8b40312ef5+5b6744d273,g90aefe88b0+c7f866738c,g989de1cb63+c104138150,g9f33ca652e+0b88989aa6,ga2f891cd6c+f4db8b1b3b,gabe3b4be73+8856018cbb,gabf8522325+5cb9e9d408,gb1101e3267+78d08b86ce,gb89ab40317+c104138150,gcf25f946ba+d435302cbd,gd6cbbdb0b4+be834e5da7,gde0f65d7ad+a7114e3dba,ge278dab8ac+fa35eb453c,ge410e46f29+c104138150,gf35d7ec915+97dd712d81,gf5e32f922b+8c5ae1fdc5,gf67bdafdda+c104138150,gffe7e49bb4+f4db8b1b3b,v29.1.0.rc2
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst::afw::image::PhotoCalib Class Referencefinal

The photometric calibration of an exposure. More...

#include <PhotoCalib.h>

Inheritance diagram for lsst::afw::image::PhotoCalib:
lsst::afw::table::io::PersistableFacade< PhotoCalib > lsst::afw::typehandling::Storable lsst::afw::table::io::Persistable

Public Member Functions

 PhotoCalib (PhotoCalib const &)=default
 
 PhotoCalib (PhotoCalib &&)=default
 
PhotoCaliboperator= (PhotoCalib const &)=delete
 
PhotoCaliboperator= (PhotoCalib &&)=delete
 
 ~PhotoCalib () override=default
 
 PhotoCalib ()
 Create a empty, zeroed calibration.
 
 PhotoCalib (double calibrationMean, double calibrationErr=0, lsst::geom::Box2I const &bbox=lsst::geom::Box2I())
 Create a non-spatially-varying calibration.
 
 PhotoCalib (std::shared_ptr< afw::math::BoundedField > calibration, double calibrationErr=0)
 Create a spatially-varying calibration.
 
 PhotoCalib (double calibrationMean, double calibrationErr, std::shared_ptr< afw::math::BoundedField > calibration, bool isConstant)
 Create a calibration with a pre-computed mean.
 
double instFluxToNanojansky (double instFlux, lsst::geom::Point< double, 2 > const &point) const
 Convert instFlux in ADU to nJy at a point in the BoundedField.
 
double instFluxToNanojansky (double instFlux) const
 
Measurement instFluxToNanojansky (double instFlux, double instFluxErr, lsst::geom::Point< double, 2 > const &point) const
 Convert instFlux and error in instFlux (ADU) to nJy and nJy error.
 
Measurement instFluxToNanojansky (double instFlux, double instFluxErr) const
 
Measurement instFluxToNanojansky (const afw::table::SourceRecord &sourceRecord, std::string const &instFluxField) const
 Convert sourceRecord[instFluxField_instFlux] (ADU) at location (sourceRecord.get("x"), sourceRecord.get("y")) (pixels) to flux and flux error (in nJy).
 
ndarray::Array< double, 2, 2 > instFluxToNanojansky (afw::table::SourceCatalog const &sourceCatalog, std::string const &instFluxField) const
 Convert sourceCatalog[instFluxField_instFlux] (ADU) at locations (sourceCatalog.get("x"), sourceCatalog.get("y")) (pixels) to nJy.
 
void instFluxToNanojansky (afw::table::SourceCatalog &sourceCatalog, std::string const &instFluxField, std::string const &outField) const
 Convert sourceCatalog[instFluxField_instFlux] (ADU) at locations (sourceCatalog.get("x"), sourceCatalog.get("y")) (pixels) to nJy and write the results back to sourceCatalog[outField_mag].
 
double instFluxToMagnitude (double instFlux, lsst::geom::Point< double, 2 > const &point) const
 Convert instFlux in ADU to AB magnitude.
 
double instFluxToMagnitude (double instFlux) const
 
Measurement instFluxToMagnitude (double instFlux, double instFluxErr, lsst::geom::Point< double, 2 > const &point) const
 Convert instFlux and error in instFlux (ADU) to AB magnitude and magnitude error.
 
Measurement instFluxToMagnitude (double instFlux, double instFluxErr) const
 
Measurement instFluxToMagnitude (afw::table::SourceRecord const &sourceRecord, std::string const &instFluxField) const
 Convert sourceRecord[instFluxField_instFlux] (ADU) at location (sourceRecord.get("x"), sourceRecord.get("y")) (pixels) to AB magnitude.
 
ndarray::Array< double, 2, 2 > instFluxToMagnitude (afw::table::SourceCatalog const &sourceCatalog, std::string const &instFluxField) const
 Convert sourceCatalog[instFluxField_instFlux] (ADU) at locations (sourceCatalog.get("x"), sourceCatalog.get("y")) (pixels) to AB magnitudes.
 
void instFluxToMagnitude (afw::table::SourceCatalog &sourceCatalog, std::string const &instFluxField, std::string const &outField) const
 Convert instFluxes in a catalog to AB magnitudes and write back into the catalog.
 
MaskedImage< float > calibrateImage (MaskedImage< float > const &maskedImage) const
 Return a flux calibrated image, with pixel values in nJy.
 
MaskedImage< float > calibrateImage (MaskedImage< float > const &maskedImage, bool includeScaleUncertainty) const
 
MaskedImage< float > uncalibrateImage (MaskedImage< float > const &maskedImage) const
 Return a un-calibrated image, with pixel values in ADU (or whatever the original input to this photoCalib was).
 
MaskedImage< float > uncalibrateImage (MaskedImage< float > const &maskedImage, bool includeScaleUncertainty) const
 
afw::table::SourceCatalog calibrateCatalog (afw::table::SourceCatalog const &catalog, std::vector< std::string > const &instFluxFields) const
 Return a flux calibrated catalog, with new _flux, _fluxErr, _mag, and _magErr fields.
 
afw::table::SourceCatalog calibrateCatalog (afw::table::SourceCatalog const &catalog) const
 
double magnitudeToInstFlux (double magnitude, lsst::geom::Point< double, 2 > const &point) const
 Convert AB magnitude to instFlux (ADU).
 
double magnitudeToInstFlux (double magnitude) const
 
double nanojanskyToInstFlux (double nanojansky, lsst::geom::Point< double, 2 > const &point) const
 Convert nanojansky to instFlux (ADU).
 
double nanojanskyToInstFlux (double nanojansky) const
 
double getCalibrationMean () const
 Get the mean photometric calibration.
 
double getCalibrationErr () const
 Get the mean photometric calibration error.
 
bool isConstant () const
 Is this photoCalib spatially constant?
 
double getInstFluxAtZeroMagnitude () const
 Get the magnitude zero point (the instrumental flux corresponding to 0 magnitude).
 
double getLocalCalibration (lsst::geom::Point< double, 2 > const &point) const
 Get the local calibration at a point.
 
std::shared_ptr< afw::math::BoundedFieldcomputeScaledCalibration () const
 Calculates the spatially-variable calibration, normalized by the mean in the valid domain.
 
std::shared_ptr< afw::math::BoundedFieldcomputeScalingTo (std::shared_ptr< PhotoCalib > other) const
 Calculates the scaling between this PhotoCalib and another PhotoCalib.
 
bool operator== (PhotoCalib const &rhs) const
 Two PhotoCalibs are equal if their component bounded fields and calibrationErr are equal.
 
bool operator!= (PhotoCalib const &rhs) const
 Two PhotoCalibs are equal if their component bounded fields and calibrationErr are equal.
 
bool isPersistable () const noexcept override
 Return true if this particular object can be persisted using afw::table::io.
 
std::shared_ptr< typehandling::StorablecloneStorable () const override
 Create a new PhotoCalib that is a copy of this one.
 
std::string toString () const override
 Create a string representation of this object.
 
bool equals (typehandling::Storable const &other) const noexcept override
 Compare this object to another Storable.
 
virtual std::size_t hash_value () const
 Return a hash of this object (optional operation).
 
void writeFits (std::string const &fileName, std::string const &mode="w") const
 Write the object to a regular FITS file.
 
void writeFits (fits::MemFileManager &manager, std::string const &mode="w") const
 Write the object to a FITS image in memory.
 
void writeFits (fits::Fits &fitsfile) const
 Write the object to an already-open FITS object.
 

Static Public Member Functions

static std::shared_ptr< PhotoCalibreadFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object.
 
static std::shared_ptr< PhotoCalibreadFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file.
 
static std::shared_ptr< PhotoCalibreadFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory.
 
static std::shared_ptr< PhotoCalibdynamicCast (std::shared_ptr< Persistable > const &ptr)
 Dynamically cast a shared_ptr.
 

Protected Types

using OutputArchiveHandle = io::OutputArchiveHandle
 

Protected Member Functions

std::string getPersistenceName () const override
 Return the unique name used to persist this object and look up its factory.
 
void write (OutputArchiveHandle &handle) const override
 Write the object to one or more catalogs.
 
virtual std::string getPythonModule () const
 Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.
 

Static Protected Member Functions

template<class T>
static bool singleClassEquals (T const &lhs, Storable const &rhs)
 Test if a Storable is of a particular class and equal to another object.
 

Related Symbols

(Note that these are not member symbols.)

std::ostreamoperator<< (std::ostream &os, Storable const &storable)
 Output operator for Storable.
 

Detailed Description

The photometric calibration of an exposure.

A PhotoCalib is a BoundedField (a function with a specified domain) that converts from post-ISR counts-on-chip (ADU) to flux and magnitude. It is defined such that a calibration of 1 means one count is equal to one nanojansky (nJy, 10^-35 W/m^2/Hz in SI units). The nJy was chosen because it represents a linear flux unit with values in a convenient range (e.g. LSST's single image depth of 24.5 is 575 nJy). See more detailed discussion in: https://pstn-001.lsst.io/

PhotoCalib is immutable.

The spatially varying flux calibration has units of nJy/ADU, and is defined such that, at a position (x,y) in the domain of the boundedField calibration and for a given measured source instFlux:

\[ instFlux*calibration(x,y) = flux [nJy] \]

while the errors (constant on the domain) are defined as:

\[ sqrt((instFluxErr/instFlux)^2 + (calibrationErr/calibration)^2)*flux = fluxErr [nJy] \]

This implies that the conversions from instFlux and instFlux error to magnitude and magnitude error are as follows:

\[ -2.5*log_{10}(instFlux*calibration(x,y)*1e-9/referenceFlux) = magnitude \]

where referenceFlux is the AB Magnitude reference flux from Oke & Gunn 1983 (first equation),

\[ referenceFlux = 1e23 * 10^{(48.6/-2.5)} \]

and

\[ 2.5/log(10)*sqrt((instFluxErr/instFlux)^2 + (calibrationErr/calibration)^2) = magnitudeErr \]

Note that this is independent of referenceFlux.

Definition at line 114 of file PhotoCalib.h.

Member Typedef Documentation

◆ OutputArchiveHandle

using lsst::afw::table::io::Persistable::OutputArchiveHandle = io::OutputArchiveHandle
protectedinherited

Definition at line 108 of file Persistable.h.

Constructor & Destructor Documentation

◆ PhotoCalib() [1/6]

lsst::afw::image::PhotoCalib::PhotoCalib ( PhotoCalib const & )
default

◆ PhotoCalib() [2/6]

lsst::afw::image::PhotoCalib::PhotoCalib ( PhotoCalib && )
default

◆ ~PhotoCalib()

lsst::afw::image::PhotoCalib::~PhotoCalib ( )
overridedefault

◆ PhotoCalib() [3/6]

lsst::afw::image::PhotoCalib::PhotoCalib ( )
inline

Create a empty, zeroed calibration.

Definition at line 127 of file PhotoCalib.h.

127: PhotoCalib(0) {}
PhotoCalib()
Create a empty, zeroed calibration.
Definition PhotoCalib.h:127

◆ PhotoCalib() [4/6]

lsst::afw::image::PhotoCalib::PhotoCalib ( double calibrationMean,
double calibrationErr = 0,
lsst::geom::Box2I const & bbox = lsst::geom::Box2I() )
inlineexplicit

Create a non-spatially-varying calibration.

Parameters
[in]calibrationMeanThe spatially-constant calibration (must be non-negative).
[in]calibrationErrThe error on the calibration (must be non-negative).
[in]bboxThe bounding box on which this PhotoCalib is valid. If not specified, this PhotoCalib is valid at any point (i.e. an empty bbox).

Definition at line 137 of file PhotoCalib.h.

139 : _calibrationMean(calibrationMean), _calibrationErr(calibrationErr), _isConstant(true) {
140 assertNonNegative(_calibrationMean, "Calibration mean");
141 assertNonNegative(_calibrationErr, "Calibration error");
142 ndarray::Array<double, 2, 2> coeffs = ndarray::allocate(ndarray::makeVector(1, 1));
143 coeffs[0][0] = calibrationMean;
145 afw::math::ChebyshevBoundedField(bbox, coeffs));
146 }
T make_shared(T... args)
void assertNonNegative(double value, std::string const &name)
Raise lsst::pex::exceptions::InvalidParameterError if value is not >=0.
Definition PhotoCalib.h:69

◆ PhotoCalib() [5/6]

lsst::afw::image::PhotoCalib::PhotoCalib ( std::shared_ptr< afw::math::BoundedField > calibration,
double calibrationErr = 0 )
inline

Create a spatially-varying calibration.

Parameters
[in]calibrationThe spatially varying photometric calibration (must have non-negative mean).
[in]calibrationErrThe error on the calibration (must be non-negative).

Definition at line 154 of file PhotoCalib.h.

155 : _calibration(calibration),
156 _calibrationMean(computeCalibrationMean(calibration)),
157 _calibrationErr(calibrationErr),
158 _isConstant(false) {
159 assertNonNegative(_calibrationMean, "Calibration (computed via BoundedField.mean()) mean");
160 assertNonNegative(_calibrationErr, "Calibration error");
161 }

◆ PhotoCalib() [6/6]

lsst::afw::image::PhotoCalib::PhotoCalib ( double calibrationMean,
double calibrationErr,
std::shared_ptr< afw::math::BoundedField > calibration,
bool isConstant )
inline

Create a calibration with a pre-computed mean.

Primarily for de-persistence.

Parameters
[in]calibrationMeanThe mean of the calibration() over its bounding box (must be non-negative).
[in]calibrationErrThe error on the calibration (must be non-negative).
[in]calibrationThe spatially varying photometric calibration.
[in]isConstantIs this PhotoCalib spatially constant?

Definition at line 171 of file PhotoCalib.h.

173 : _calibration(calibration),
174 _calibrationMean(calibrationMean),
175 _calibrationErr(calibrationErr),
176 _isConstant(isConstant) {
177 assertNonNegative(_calibrationMean, "Calibration mean");
178 assertNonNegative(_calibrationErr, "Calibration error");
179 }
bool isConstant() const
Is this photoCalib spatially constant?
Definition PhotoCalib.h:472

Member Function Documentation

◆ calibrateCatalog() [1/2]

afw::table::SourceCatalog lsst::afw::image::PhotoCalib::calibrateCatalog ( afw::table::SourceCatalog const & catalog) const

Definition at line 346 of file PhotoCalib.cc.

346 {
347 std::vector<std::string> instFluxFields;
348 static std::string const SUFFIX = "_instFlux";
349 for (auto const &name : catalog.getSchema().getNames()) {
350 // Pick every field ending in "_instFlux", grabbing everything before that prefix.
351 if (name.size() > SUFFIX.size() + 1 &&
352 name.compare(name.size() - SUFFIX.size(), SUFFIX.size(), SUFFIX) == 0) {
353 instFluxFields.emplace_back(name.substr(0, name.size() - 9));
354 }
355 }
356 return calibrateCatalog(catalog, instFluxFields);
357}
afw::table::SourceCatalog calibrateCatalog(afw::table::SourceCatalog const &catalog, std::vector< std::string > const &instFluxFields) const
Return a flux calibrated catalog, with new _flux, _fluxErr, _mag, and _magErr fields.
T emplace_back(T... args)
T size(T... args)

◆ calibrateCatalog() [2/2]

afw::table::SourceCatalog lsst::afw::image::PhotoCalib::calibrateCatalog ( afw::table::SourceCatalog const & catalog,
std::vector< std::string > const & instFluxFields ) const

Return a flux calibrated catalog, with new _flux, _fluxErr, _mag, and _magErr fields.

If the input catalog already has _flux, _mag, _fluxErr, and/or _magErr fields matching instFluxFields, they will be replaced with the new fields.

Parameters
catalogThe source catalog to compute calibrated fluxes for.
instFluxFieldsThe fields to calibrate (optional). If not provided, every field ending with _instFlux will be calibrated.
Returns
A deep copy of the input catalog, with new calibrated flux and magnitude fields. Elements of instFluxFields that have _instFluxErr will be used to compute the _fluxErr and _magErr fields.
Exceptions
lsst::pex::exceptions::NotFoundErrorif any item in instFluxFields does not have a corresponding *_instFlux field in catalog.schema.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 281 of file PhotoCalib.cc.

282 {
283 auto const &inSchema = catalog.getSchema();
284 afw::table::SchemaMapper mapper(inSchema, true); // true: share the alias map
285 mapper.addMinimalSchema(inSchema);
286
287 using FieldD = afw::table::Field<double>;
288
289 struct Keys {
290 table::Key<double> instFlux;
291 table::Key<double> instFluxErr;
292 table::Key<double> flux;
293 table::Key<double> fluxErr;
294 table::Key<double> mag;
295 table::Key<double> magErr;
296 };
297
298 std::vector<Keys> keys;
299 keys.reserve(instFluxFields.size());
300 for (auto const &field : instFluxFields) {
301 Keys newKey;
302 newKey.instFlux = inSchema[inSchema.join(field, "instFlux")];
303 newKey.flux =
304 mapper.addOutputField(FieldD(inSchema.join(field, "flux"), "calibrated flux", "nJy"), true);
305 newKey.mag = mapper.addOutputField(
306 FieldD(inSchema.join(field, "mag"), "calibrated magnitude", "mag(AB)"), true);
307 try {
308 newKey.instFluxErr = inSchema.find<double>(inSchema.join(field, "instFluxErr")).key;
309 newKey.fluxErr = mapper.addOutputField(
310 FieldD(inSchema.join(field, "fluxErr"), "calibrated flux uncertainty", "nJy"), true);
311 newKey.magErr = mapper.addOutputField(
312 FieldD(inSchema.join(field, "magErr"), "calibrated magnitude uncertainty", "mag(AB)"),
313 true);
314 } catch (pex::exceptions::NotFoundError &) {
315 ; // Keys struct defaults to invalid keys; that marks the error as missing.
316 }
317 keys.emplace_back(newKey);
318 }
319
320 // Create the new catalog
321 afw::table::SourceCatalog output(mapper.getOutputSchema());
322 output.insert(mapper, output.begin(), catalog.begin(), catalog.end());
323
324 auto calibration = evaluateCatalog(output);
325
326 // fill in the catalog values
327 int iRec = 0;
328 for (auto &rec : output) {
329 for (auto &key : keys) {
330 double instFlux = rec.get(key.instFlux);
331 double nanojansky = toNanojansky(instFlux, calibration[iRec]);
332 rec.set(key.flux, nanojansky);
333 rec.set(key.mag, toMagnitude(instFlux, calibration[iRec]));
334 if (key.instFluxErr.isValid()) {
335 double instFluxErr = rec.get(key.instFluxErr);
336 rec.set(key.fluxErr, toNanojanskyErr(instFluxErr, calibration[iRec]));
337 rec.set(key.magErr, toMagnitudeErr(instFlux, instFluxErr));
338 }
339 }
340 ++iRec;
341 }
342
343 return output;
344}
SortedCatalogT< SourceRecord > SourceCatalog
Definition fwd.h:85

◆ calibrateImage() [1/2]

MaskedImage< float > lsst::afw::image::PhotoCalib::calibrateImage ( MaskedImage< float > const & maskedImage) const

Return a flux calibrated image, with pixel values in nJy.

Mask pixels are propagated directly from the input image.

Parameters
maskedImageThe masked image to calibrate.
includeScaleUncertaintyDeprecated and ignored; will be removed after v29.
Returns
The calibrated masked image.

Definition at line 248 of file PhotoCalib.cc.

248 {
249 // Deep copy construct, as we're multiplying in-place.
250 auto result = MaskedImage<float>(maskedImage, true);
251 if (_isConstant) {
252 result *= _calibrationMean;
253 } else {
254 _calibration->multiplyImage(result, true); // only in the overlap region
255 }
256 return result;
257}

◆ calibrateImage() [2/2]

MaskedImage< float > lsst::afw::image::PhotoCalib::calibrateImage ( MaskedImage< float > const & maskedImage,
bool includeScaleUncertainty ) const

Definition at line 260 of file PhotoCalib.cc.

261 {
262 return calibrateImage(maskedImage);
263}
MaskedImage< float > calibrateImage(MaskedImage< float > const &maskedImage) const
Return a flux calibrated image, with pixel values in nJy.

◆ cloneStorable()

std::shared_ptr< typehandling::Storable > lsst::afw::image::PhotoCalib::cloneStorable ( ) const
overridevirtual

Create a new PhotoCalib that is a copy of this one.

Reimplemented from lsst::afw::typehandling::Storable.

Definition at line 226 of file PhotoCalib.cc.

226 {
227 return std::make_unique<PhotoCalib>(*this);
228}

◆ computeScaledCalibration()

std::shared_ptr< math::BoundedField > lsst::afw::image::PhotoCalib::computeScaledCalibration ( ) const

Calculates the spatially-variable calibration, normalized by the mean in the valid domain.

This value is defined, for instFlux at (x,y), such that:

\[ instFlux*computeScaledCalibration()(x,y)*getCalibrationMean() = instFluxToNanojansky(instFlux, (x,y)) \]

See also
PhotoCalib::getCalibrationMean()
Returns
The normalized spatially-variable calibration.

Definition at line 209 of file PhotoCalib.cc.

209 {
210 return *(_calibration) / _calibrationMean;
211}

◆ computeScalingTo()

std::shared_ptr< math::BoundedField > lsst::afw::image::PhotoCalib::computeScalingTo ( std::shared_ptr< PhotoCalib > other) const

Calculates the scaling between this PhotoCalib and another PhotoCalib.

The BoundedFields of these PhotoCalibs must have the same BBoxes (or one or both must be empty).

With:

  • c = instFlux at position (x,y)
  • this = this PhotoCalib
  • other = other PhotoCalib
  • return = BoundedField returned by this method the return value from this method is defined as:

    \[ this.instFluxToNanojansky(c, (x,y))*return(x, y) = other.instFluxToNanojansky(c, (x,y)) \]

Parameters
[in]otherThe PhotoCalib to scale to.
Returns
The BoundedField as defined above.
Warning
Not implemented yet: See DM-10154.

Definition at line 213 of file PhotoCalib.cc.

213 {
214 throw LSST_EXCEPT(pex::exceptions::LogicError, "Not Implemented: See DM-10154.");
215}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48

◆ dynamicCast()

Dynamically cast a shared_ptr.

Dynamically cast a shared pointer and raise on failure.

You must provide an explicit template instantiation in the .cc file for each class that inherits from PersistableFacade. Designed to work around RTTI issues on macOS with hidden symbols;

Exceptions
lsst::pex::exceptions::LogicErrorif the cast fails

param[in] ptr The pointer to be cast.

Returns
The cast pointer.
Exceptions
lsst::pex::exceptions::TypeErrorIf the dynamic cast fails.

Definition at line 218 of file Persistable.cc.

18 {
20 if (!result) {
21 throw LSST_EXCEPT(pex::exceptions::TypeError, "Dynamic pointer cast failed");
22 }
23 return result;
24}
A CRTP facade class for subclasses of Persistable.
T dynamic_pointer_cast(T... args)

◆ equals()

bool lsst::afw::image::PhotoCalib::equals ( typehandling::Storable const & other) const
overridevirtualnoexcept

Compare this object to another Storable.

Returns
*this == other if other is a PhotoCalib; otherwise false.

Reimplemented from lsst::afw::typehandling::Storable.

Definition at line 240 of file PhotoCalib.cc.

240 {
241 return singleClassEquals(*this, other);
242}
static bool singleClassEquals(T const &lhs, Storable const &rhs)
Test if a Storable is of a particular class and equal to another object.
Definition Storable.h:151

◆ getCalibrationErr()

double lsst::afw::image::PhotoCalib::getCalibrationErr ( ) const
inline

Get the mean photometric calibration error.

This value is defined such that for some instFluxErr, instFlux, and flux:

\[ sqrt((instFluxErr/instFlux)^2 + (calibrationErr/calibration(x,y))^2)*flux = fluxErr [nJy] \]

See also
PhotoCalib::computeScaledCalibration(), getCalibrationMean()
Returns
The calibration error.

Definition at line 465 of file PhotoCalib.h.

465{ return _calibrationErr; }

◆ getCalibrationMean()

double lsst::afw::image::PhotoCalib::getCalibrationMean ( ) const
inline

Get the mean photometric calibration.

This value is defined, for instFlux at (x,y), such that:

\[ instFlux*computeScaledCalibration()(x,y)*getCalibrationMean() = instFluxToNanojansky(instFlux, (x,y)) \]

See also
PhotoCalib::computeScaledCalibration(), getCalibrationErr(), getInstFluxAtZeroMagnitude()
Returns
The spatial mean of this calibration.

Definition at line 451 of file PhotoCalib.h.

451{ return _calibrationMean; }

◆ getInstFluxAtZeroMagnitude()

double lsst::afw::image::PhotoCalib::getInstFluxAtZeroMagnitude ( ) const
inline

Get the magnitude zero point (the instrumental flux corresponding to 0 magnitude).

This value is defined such that:

\[ instFluxToMagnitude(getInstFluxAtZeroMagnitude()) == 0 \]

See also
PhotoCalib::computeScaledCalibration(), getCalibrationMean()
Returns
The instFlux magnitude zero point.

Definition at line 486 of file PhotoCalib.h.

486{ return cpputils::referenceFlux / _calibrationMean; }
const double referenceFlux
The Oke & Gunn (1983) AB magnitude reference flux, in nJy (often approximated as 3631....
Definition Magnitude.h:46

◆ getLocalCalibration()

double lsst::afw::image::PhotoCalib::getLocalCalibration ( lsst::geom::Point< double, 2 > const & point) const
inline

Get the local calibration at a point.

This value is defined such that:

\[ instFluxToNanojansky(instFlux, point) == localCalibration * inst \]

Use getCalibrationErr() to get the spatially constant error on the calibration.

Parameters
[in]pointThe position that magnitude is to be converted at.
See also
getCalibrationMean(), getCalibrationErr()
Returns
The local calibration at a point.

Definition at line 504 of file PhotoCalib.h.

504{ return evaluate(point); }

◆ getPersistenceName()

std::string lsst::afw::image::PhotoCalib::getPersistenceName ( ) const
overrideprotectedvirtual

Return the unique name used to persist this object and look up its factory.

Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 506 of file PhotoCalib.cc.

506{ return getPhotoCalibPersistenceName(); }

◆ getPythonModule()

std::string lsst::afw::table::io::Persistable::getPythonModule ( ) const
protectedvirtualinherited

Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.

Must be less than ArchiveIndexSchema::MAX_MODULE_LENGTH characters.

Will be ignored if empty.

Reimplemented in lsst::afw::cameraGeom::Detector, lsst::afw::cameraGeom::DetectorCollection, lsst::afw::cameraGeom::TransformMap, lsst::afw::detection::Footprint, lsst::afw::detection::GaussianPsf, lsst::afw::geom::SkyWcs, lsst::afw::geom::SpanSet, lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >, lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >, lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >, lsst::afw::geom::Transform< Point2Endpoint, GenericEndpoint >, lsst::afw::geom::Transform< Point2Endpoint, GenericEndpoint >, lsst::afw::geom::Transform< Point2Endpoint, Point2Endpoint >, lsst::afw::geom::Transform< Point2Endpoint, Point2Endpoint >, lsst::afw::geom::Transform< Point2Endpoint, SpherePointEndpoint >, lsst::afw::geom::Transform< Point2Endpoint, SpherePointEndpoint >, lsst::afw::image::ApCorrMap, lsst::afw::image::CoaddInputs, lsst::afw::image::FilterLabel, lsst::afw::image::TransmissionCurve, lsst::afw::math::BilinearWarpingKernel, lsst::afw::math::ChebyshevBoundedField, lsst::afw::math::Function< ReturnT >, lsst::afw::math::Function< Kernel::Pixel >, lsst::afw::math::Kernel, lsst::afw::math::LanczosWarpingKernel, lsst::afw::math::NearestWarpingKernel, lsst::afw::math::PixelAreaBoundedField, lsst::afw::math::ProductBoundedField, lsst::afw::math::TransformBoundedField, lsst::afw::math::WarpingControl, lsst::afw::typehandling::StorableHelper< Base >, lsst::meas::algorithms::CoaddBoundedField, lsst::meas::algorithms::CoaddPsf, lsst::meas::algorithms::KernelPsf, lsst::meas::algorithms::WarpedPsf, lsst::meas::extensions::psfex::PsfexPsf, and lsst::meas::modelfit::Mixture.

Definition at line 36 of file Persistable.cc.

36{ return std::string(); }

◆ hash_value()

std::size_t lsst::afw::typehandling::Storable::hash_value ( ) const
virtualinherited

Return a hash of this object (optional operation).

Exceptions
UnsupportedOperationExceptionThrown if this object is not hashable.
Note
C++ subclass authors are responsible for any associated specializations of std::hash.
When called on Python classes, this method delegates to __hash__ if it exists.

Reimplemented in lsst::afw::geom::polygon::Polygon, lsst::afw::image::FilterLabel, lsst::afw::image::VisitInfo, and lsst::afw::typehandling::StorableHelper< Base >.

Definition at line 44 of file Storable.cc.

44 {
45 throw LSST_EXCEPT(UnsupportedOperationException, "Hashes are not supported.");
46}

◆ instFluxToMagnitude() [1/7]

void lsst::afw::image::PhotoCalib::instFluxToMagnitude ( afw::table::SourceCatalog & sourceCatalog,
std::string const & instFluxField,
std::string const & outField ) const

Convert instFluxes in a catalog to AB magnitudes and write back into the catalog.

Convert sourceCatalog[instFluxField_instFlux] (ADU) at locations (sourceCatalog.get("x"), sourceCatalog.get("y")) (pixels) to AB magnitudes and write the results back to sourceCatalog[outField_mag].

Parameters
[in]sourceCatalogThe source catalog to get instFlux and position from.
[in]instFluxFieldThe instFlux field: Keys of the form "*_instFlux" and "*_instFluxErr" must exist. For example: instFluxField="slot_PsfFlux" will use the fields named: "slot_PsfFlux_instFlux", "slot_PsfFlux_instFluxErr"
[in]outFieldThe field to write the magnitudes and magnitude errors to. Keys of the form "*_instFlux", "*_instFluxErr", *_mag", and "*_magErr" must exist in the schema.

Definition at line 177 of file PhotoCalib.cc.

178 {
179 auto instFluxKey = sourceCatalog.getSchema().find<double>(instFluxField + "_instFlux").key;
180 auto instFluxErrKey = sourceCatalog.getSchema().find<double>(instFluxField + "_instFluxErr").key;
181 auto magKey = sourceCatalog.getSchema().find<double>(outField + "_mag").key;
182 auto magErrKey = sourceCatalog.getSchema().find<double>(outField + "_magErr").key;
183 for (auto &record : sourceCatalog) {
184 auto result = instFluxToMagnitude(record.get(instFluxKey), record.get(instFluxErrKey),
185 record.getCentroid());
186 record.set(magKey, result.value);
187 record.set(magErrKey, result.error);
188 }
189}
double instFluxToMagnitude(double instFlux, lsst::geom::Point< double, 2 > const &point) const
Convert instFlux in ADU to AB magnitude.

◆ instFluxToMagnitude() [2/7]

ndarray::Array< double, 2, 2 > lsst::afw::image::PhotoCalib::instFluxToMagnitude ( afw::table::SourceCatalog const & sourceCatalog,
std::string const & instFluxField ) const

Convert sourceCatalog[instFluxField_instFlux] (ADU) at locations (sourceCatalog.get("x"), sourceCatalog.get("y")) (pixels) to AB magnitudes.

Parameters
[in]sourceCatalogThe source catalog to get instFlux and position from.
[in]instFluxFieldThe instFlux field: Keys of the form "*_instFlux" and "*_instFluxErr" must exist. For example: instFluxField="slot_PsfFlux" will use the fields named: "slot_PsfFlux_instFlux", "slot_PsfFlux_instFluxErr"
Returns
The magnitudes and magnitude errors for the sources.

Definition at line 169 of file PhotoCalib.cc.

170 {
171 ndarray::Array<double, 2, 2> result =
172 ndarray::allocate(ndarray::makeVector(int(sourceCatalog.size()), 2));
173 instFluxToMagnitudeArray(sourceCatalog, instFluxField, result);
174 return result;
175}

◆ instFluxToMagnitude() [3/7]

Measurement lsst::afw::image::PhotoCalib::instFluxToMagnitude ( afw::table::SourceRecord const & sourceRecord,
std::string const & instFluxField ) const

Convert sourceRecord[instFluxField_instFlux] (ADU) at location (sourceRecord.get("x"), sourceRecord.get("y")) (pixels) to AB magnitude.

Parameters
[in]sourceRecordThe source record to get instFlux and position from.
[in]instFluxFieldThe instFlux field: Keys of the form "*_instFlux" and "*_instFluxErr" must exist. For example: instFluxField="slot_PsfFlux" will use the fields named: "slot_PsfFlux_instFlux", "slot_PsfFlux_instFluxErr"
Returns
The magnitude and magnitude error for this source.

Definition at line 161 of file PhotoCalib.cc.

162 {
163 auto position = sourceRecord.getCentroid();
164 auto instFluxKey = sourceRecord.getSchema().find<double>(instFluxField + "_instFlux").key;
165 auto instFluxErrKey = sourceRecord.getSchema().find<double>(instFluxField + "_instFluxErr").key;
166 return instFluxToMagnitude(sourceRecord.get(instFluxKey), sourceRecord.get(instFluxErrKey), position);
167}

◆ instFluxToMagnitude() [4/7]

double lsst::afw::image::PhotoCalib::instFluxToMagnitude ( double instFlux) const

Definition at line 142 of file PhotoCalib.cc.

142 {
143 return toMagnitude(instFlux, _calibrationMean);
144}

◆ instFluxToMagnitude() [5/7]

Measurement lsst::afw::image::PhotoCalib::instFluxToMagnitude ( double instFlux,
double instFluxErr ) const

Definition at line 155 of file PhotoCalib.cc.

155 {
156 double magnitude = toMagnitude(instFlux, _calibrationMean);
157 double error = toMagnitudeErr(instFlux, instFluxErr);
158 return Measurement(magnitude, error);
159}

◆ instFluxToMagnitude() [6/7]

Measurement lsst::afw::image::PhotoCalib::instFluxToMagnitude ( double instFlux,
double instFluxErr,
lsst::geom::Point< double, 2 > const & point ) const

Convert instFlux and error in instFlux (ADU) to AB magnitude and magnitude error.

If passed point, use the exact calculation at that point, otherwise, use the mean scaling factor.

Parameters
[in]instFluxThe source instFlux in ADU.
[in]instFluxErrThe instFlux error (standard deviation).
[in]pointThe point that instFlux is measured at.
Returns
The AB magnitude and error.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 146 of file PhotoCalib.cc.

147 {
148 double calibration, error, magnitude;
149 calibration = evaluate(point);
150 magnitude = toMagnitude(instFlux, calibration);
151 error = toMagnitudeErr(instFlux, instFluxErr);
152 return Measurement(magnitude, error);
153}

◆ instFluxToMagnitude() [7/7]

double lsst::afw::image::PhotoCalib::instFluxToMagnitude ( double instFlux,
lsst::geom::Point< double, 2 > const & point ) const

Convert instFlux in ADU to AB magnitude.

If passed point, use the exact calculation at that point, otherwise, use the mean scaling factor.

Parameters
[in]instFluxThe source instFlux in ADU.
[in]pointThe point that instFlux is measured at.
Returns
The AB magnitude.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 138 of file PhotoCalib.cc.

138 {
139 return toMagnitude(instFlux, evaluate(point));
140}

◆ instFluxToNanojansky() [1/7]

void lsst::afw::image::PhotoCalib::instFluxToNanojansky ( afw::table::SourceCatalog & sourceCatalog,
std::string const & instFluxField,
std::string const & outField ) const

Convert sourceCatalog[instFluxField_instFlux] (ADU) at locations (sourceCatalog.get("x"), sourceCatalog.get("y")) (pixels) to nJy and write the results back to sourceCatalog[outField_mag].

Parameters
[in]sourceCatalogThe source catalog to get instFlux and position from.
[in]instFluxFieldThe instFlux field: Keys of the form "*_instFlux" and "*_instFluxErr" must exist. For example: instFluxField="slot_PsfFlux" will use the fields named: "slot_PsfFlux_instFlux", "slot_PsfFlux_instFluxErr"
[in]outFieldThe field to write the nJy and magnitude errors to. Keys of the form "*_instFlux" and "*_instFluxErr" must exist in the schema.

Definition at line 122 of file PhotoCalib.cc.

123 {
124 auto instFluxKey = sourceCatalog.getSchema().find<double>(instFluxField + "_instFlux").key;
125 auto instFluxErrKey = sourceCatalog.getSchema().find<double>(instFluxField + "_instFluxErr").key;
126 auto nanojanskyKey = sourceCatalog.getSchema().find<double>(outField + "_flux").key;
127 auto nanojanskyErrKey = sourceCatalog.getSchema().find<double>(outField + "_fluxErr").key;
128 for (auto &record : sourceCatalog) {
129 auto result = instFluxToNanojansky(record.get(instFluxKey), record.get(instFluxErrKey),
130 record.getCentroid());
131 record.set(nanojanskyKey, result.value);
132 record.set(nanojanskyErrKey, result.error);
133 }
134}
double instFluxToNanojansky(double instFlux, lsst::geom::Point< double, 2 > const &point) const
Convert instFlux in ADU to nJy at a point in the BoundedField.
Definition PhotoCalib.cc:84

◆ instFluxToNanojansky() [2/7]

ndarray::Array< double, 2, 2 > lsst::afw::image::PhotoCalib::instFluxToNanojansky ( afw::table::SourceCatalog const & sourceCatalog,
std::string const & instFluxField ) const

Convert sourceCatalog[instFluxField_instFlux] (ADU) at locations (sourceCatalog.get("x"), sourceCatalog.get("y")) (pixels) to nJy.

Parameters
[in]sourceCatalogThe source catalog to get instFlux and position from.
[in]instFluxFieldThe instFlux field: Keys of the form "*_instFlux" and "*_instFluxErr" must exist. For example: instFluxField="slot_PsfFlux" will use the fields named: "slot_PsfFlux_instFlux", "slot_PsfFlux_instFluxErr"
Returns
The flux in nJy and error for this source.

Definition at line 114 of file PhotoCalib.cc.

115 {
116 ndarray::Array<double, 2, 2> result =
117 ndarray::allocate(ndarray::makeVector(int(sourceCatalog.size()), 2));
118 instFluxToNanojanskyArray(sourceCatalog, instFluxField, result);
119 return result;
120}

◆ instFluxToNanojansky() [3/7]

Measurement lsst::afw::image::PhotoCalib::instFluxToNanojansky ( const afw::table::SourceRecord & sourceRecord,
std::string const & instFluxField ) const

Convert sourceRecord[instFluxField_instFlux] (ADU) at location (sourceRecord.get("x"), sourceRecord.get("y")) (pixels) to flux and flux error (in nJy).

Parameters
[in]sourceRecordThe source record to get instFlux and position from.
[in]instFluxFieldThe instFlux field: Keys of the form "*_instFlux" and "*_instFluxErr" must exist. For example: instFluxField="slot_PsfFlux" will use the fields named: "slot_PsfFlux_instFlux", "slot_PsfFlux_instFluxErr"
Returns
The flux in nJy and error for this source.

Definition at line 107 of file PhotoCalib.cc.

108 {
109 auto position = sourceRecord.getCentroid();
110 auto instFluxKey = sourceRecord.getSchema().find<double>(instFluxField + "_instFlux").key;
111 auto instFluxErrKey = sourceRecord.getSchema().find<double>(instFluxField + "_instFluxErr").key;
112 return instFluxToNanojansky(sourceRecord.get(instFluxKey), sourceRecord.get(instFluxErrKey), position);
113}

◆ instFluxToNanojansky() [4/7]

double lsst::afw::image::PhotoCalib::instFluxToNanojansky ( double instFlux) const

Definition at line 88 of file PhotoCalib.cc.

88 {
89 return toNanojansky(instFlux, _calibrationMean);
90}

◆ instFluxToNanojansky() [5/7]

Measurement lsst::afw::image::PhotoCalib::instFluxToNanojansky ( double instFlux,
double instFluxErr ) const

Definition at line 101 of file PhotoCalib.cc.

101 {
102 double nanojansky = toNanojansky(instFlux, _calibrationMean);
103 double error = toNanojanskyErr(instFluxErr, _calibrationMean);
104 return Measurement(nanojansky, error);
105}

◆ instFluxToNanojansky() [6/7]

Measurement lsst::afw::image::PhotoCalib::instFluxToNanojansky ( double instFlux,
double instFluxErr,
lsst::geom::Point< double, 2 > const & point ) const

Convert instFlux and error in instFlux (ADU) to nJy and nJy error.

If passed point, use the exact calculation at that point, otherwise, use the mean scaling factor.

Parameters
[in]instFluxThe source fluxinstFlux in ADU.
[in]instFluxErrThe instFlux error.
[in]pointThe point that instFlux is measured at.
Returns
The flux in nJy and error.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 92 of file PhotoCalib.cc.

93 {
94 double calibration, error, nanojansky;
95 calibration = evaluate(point);
96 nanojansky = toNanojansky(instFlux, calibration);
97 error = toNanojanskyErr(instFluxErr, calibration);
98 return Measurement(nanojansky, error);
99}

◆ instFluxToNanojansky() [7/7]

double lsst::afw::image::PhotoCalib::instFluxToNanojansky ( double instFlux,
lsst::geom::Point< double, 2 > const & point ) const

Convert instFlux in ADU to nJy at a point in the BoundedField.

If passed point, use the exact calculation at that point, otherwise, use the mean scaling factor.

Parameters
[in]instFluxThe source instFlux in ADU.
[in]pointThe point that instFlux is measured at.
Returns
The flux in nJy.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 84 of file PhotoCalib.cc.

84 {
85 return toNanojansky(instFlux, evaluate(point));
86}

◆ isConstant()

bool lsst::afw::image::PhotoCalib::isConstant ( ) const
inline

Is this photoCalib spatially constant?

Returns
Is the calibration spatially constant?

Definition at line 472 of file PhotoCalib.h.

472{ return _isConstant; }

◆ isPersistable()

bool lsst::afw::image::PhotoCalib::isPersistable ( ) const
inlineoverridevirtualnoexcept

Return true if this particular object can be persisted using afw::table::io.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 550 of file PhotoCalib.h.

550{ return true; }

◆ magnitudeToInstFlux() [1/2]

double lsst::afw::image::PhotoCalib::magnitudeToInstFlux ( double magnitude) const

Definition at line 193 of file PhotoCalib.cc.

193 {
194 return toInstFluxFromMagnitude(magnitude, _calibrationMean);
195}

◆ magnitudeToInstFlux() [2/2]

double lsst::afw::image::PhotoCalib::magnitudeToInstFlux ( double magnitude,
lsst::geom::Point< double, 2 > const & point ) const

Convert AB magnitude to instFlux (ADU).

If passed point, use the exact calculation at that point, otherwise, use the mean scaling factor.

Useful for inserting fake sources into an image.

Parameters
[in]magnitudeThe AB magnitude to convert.
[in]pointThe position that magnitude is to be converted at.
Returns
Source instFlux in ADU.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 197 of file PhotoCalib.cc.

197 {
198 return toInstFluxFromMagnitude(magnitude, evaluate(point));
199}

◆ nanojanskyToInstFlux() [1/2]

double lsst::afw::image::PhotoCalib::nanojanskyToInstFlux ( double nanojansky) const

Definition at line 201 of file PhotoCalib.cc.

201 {
202 return toInstFluxFromNanojansky(nanojansky, _calibrationMean);
203}

◆ nanojanskyToInstFlux() [2/2]

double lsst::afw::image::PhotoCalib::nanojanskyToInstFlux ( double nanojansky,
lsst::geom::Point< double, 2 > const & point ) const

Convert nanojansky to instFlux (ADU).

If passed point, use the exact calculation at that point, otherwise, use the mean scaling factor.

Useful for computing expected instrumental flux from reference catalog sources.

Parameters
[in]nanojanskyThe flux in nanojanksies to convert.
[in]pointThe position that flux is to be converted at.
Returns
Source instFlux in ADU.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 205 of file PhotoCalib.cc.

205 {
206 return toInstFluxFromNanojansky(nanojansky, evaluate(point));
207}

◆ operator!=()

bool lsst::afw::image::PhotoCalib::operator!= ( PhotoCalib const & rhs) const
inline

Two PhotoCalibs are equal if their component bounded fields and calibrationErr are equal.

Definition at line 548 of file PhotoCalib.h.

548{ return !(*this == rhs); }

◆ operator=() [1/2]

PhotoCalib & lsst::afw::image::PhotoCalib::operator= ( PhotoCalib && )
delete

◆ operator=() [2/2]

PhotoCalib & lsst::afw::image::PhotoCalib::operator= ( PhotoCalib const & )
delete

◆ operator==()

bool lsst::afw::image::PhotoCalib::operator== ( PhotoCalib const & rhs) const

Two PhotoCalibs are equal if their component bounded fields and calibrationErr are equal.

Definition at line 217 of file PhotoCalib.cc.

217 {
218 return (_calibrationMean == rhs._calibrationMean && _calibrationErr == rhs._calibrationErr &&
219 (*_calibration) == *(rhs._calibration));
220}

◆ readFits() [1/3]

static std::shared_ptr< PhotoCalib > lsst::afw::table::io::PersistableFacade< PhotoCalib >::readFits ( fits::Fits & fitsfile)
inlinestaticinherited

Read an object from an already open FITS object.

Parameters
[in]fitsfileFITS object to read from, already positioned at the desired HDU.

Definition at line 183 of file Persistable.h.

183 {
185 }
static std::shared_ptr< PhotoCalib > dynamicCast(std::shared_ptr< Persistable > const &ptr)

◆ readFits() [2/3]

static std::shared_ptr< PhotoCalib > lsst::afw::table::io::PersistableFacade< PhotoCalib >::readFits ( fits::MemFileManager & manager,
int hdu = fits::DEFAULT_HDU )
inlinestaticinherited

Read an object from a FITS file in memory.

Parameters
[in]managerManager for the memory to read from.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 205 of file Persistable.h.

205 {
207 }

◆ readFits() [3/3]

static std::shared_ptr< PhotoCalib > lsst::afw::table::io::PersistableFacade< PhotoCalib >::readFits ( std::string const & fileName,
int hdu = fits::DEFAULT_HDU )
inlinestaticinherited

Read an object from a regular FITS file.

Parameters
[in]fileNameName of the file to read.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 194 of file Persistable.h.

194 {
196 }

◆ singleClassEquals()

template<class T>
static bool lsst::afw::typehandling::Storable::singleClassEquals ( T const & lhs,
Storable const & rhs )
inlinestaticprotectedinherited

Test if a Storable is of a particular class and equal to another object.

This method template simplifies implementations of equals that delegate to operator== without supporting cross-class comparisons.

Template Parameters
TThe class expected of the two objects to be compared.
Parameters
lhs,rhsThe objects to compare. Note that rhs need not be a T, while lhs must be.
Returns
true if rhs is a T and lhs == rhs; false otherwise.
Exception Safety
Provides the same level of exception safety as operator==. Most implementations of operator== do not throw.
Note
This method template calls operator== with both arguments of compile-time type T const&. Its use is not recommended if there would be any ambiguity as to which operator== gets picked by overload resolution.

This method template is typically called from equals as:

bool MyType::equals(Storable const& other) const noexcept {
    return singleClassEquals(*this, other);
}

Definition at line 151 of file Storable.h.

151 {
152 auto typedRhs = dynamic_cast<T const*>(&rhs);
153 if (typedRhs != nullptr) {
154 return lhs == *typedRhs;
155 } else {
156 return false;
157 }
158 }

◆ toString()

std::string lsst::afw::image::PhotoCalib::toString ( ) const
overridevirtual

Create a string representation of this object.

Reimplemented from lsst::afw::typehandling::Storable.

Definition at line 230 of file PhotoCalib.cc.

230 {
231 std::stringstream buffer;
232 if (_isConstant)
233 buffer << "spatially constant with ";
234 else
235 buffer << *_calibration << " with ";
236 buffer << "mean: " << _calibrationMean << " error: " << _calibrationErr;
237 return buffer.str();
238}
T str(T... args)

◆ uncalibrateImage() [1/2]

MaskedImage< float > lsst::afw::image::PhotoCalib::uncalibrateImage ( MaskedImage< float > const & maskedImage) const

Return a un-calibrated image, with pixel values in ADU (or whatever the original input to this photoCalib was).

Mask pixels are propagated directly from the input image.

Parameters
maskedImageThe masked image with pixel units of nJy to uncalibrate.
includeScaleUncertaintyDeprecated and ignored; will be removed after v29.
Returns
The uncalibrated masked image.

Definition at line 265 of file PhotoCalib.cc.

265 {
266 // Deep copy construct, as we're multiplying in-place.
267 auto result = MaskedImage<float>(maskedImage, true);
268 if (_isConstant) {
269 result /= _calibrationMean;
270 } else {
271 _calibration->divideImage(result, true); // only in the overlap region
272 }
273 return result;
274}

◆ uncalibrateImage() [2/2]

MaskedImage< float > lsst::afw::image::PhotoCalib::uncalibrateImage ( MaskedImage< float > const & maskedImage,
bool includeScaleUncertainty ) const

Definition at line 276 of file PhotoCalib.cc.

277 {
278 return uncalibrateImage(maskedImage);
279}
MaskedImage< float > uncalibrateImage(MaskedImage< float > const &maskedImage) const
Return a un-calibrated image, with pixel values in ADU (or whatever the original input to this photoC...

◆ write()

void lsst::afw::image::PhotoCalib::write ( OutputArchiveHandle & handle) const
overrideprotectedvirtual

Write the object to one or more catalogs.

The handle object passed to this function provides an interface for adding new catalogs and adding nested objects to the same archive (while checking for duplicates). See OutputArchiveHandle for more information.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 508 of file PhotoCalib.cc.

508 {
509 PhotoCalibSchema const &keys = PhotoCalibSchema::get();
510 table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
511 auto record = catalog.addNew();
512 record->set(keys.calibrationMean, _calibrationMean);
513 record->set(keys.calibrationErr, _calibrationErr);
514 record->set(keys.isConstant, _isConstant);
515 record->set(keys.field, handle.put(_calibration));
516 record->set(keys.version, SERIALIZATION_VERSION);
517 handle.saveCatalog(catalog);
518}
CatalogT< BaseRecord > BaseCatalog
Definition fwd.h:72

◆ writeFits() [1/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::Fits & fitsfile) const
inherited

Write the object to an already-open FITS object.

Parameters
[in]fitsfileOpen FITS object to write to.

Definition at line 18 of file Persistable.cc.

18 {
19 OutputArchive archive;
20 archive.put(this);
21 archive.writeFits(fitsfile);
22}

◆ writeFits() [2/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::MemFileManager & manager,
std::string const & mode = "w" ) const
inherited

Write the object to a FITS image in memory.

Parameters
[in]managerName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

Definition at line 29 of file Persistable.cc.

29 {
30 fits::Fits fitsfile(manager, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
31 writeFits(fitsfile);
32}
void writeFits(std::string const &fileName, std::string const &mode="w") const
Write the object to a regular FITS file.

◆ writeFits() [3/3]

void lsst::afw::table::io::Persistable::writeFits ( std::string const & fileName,
std::string const & mode = "w" ) const
inherited

Write the object to a regular FITS file.

Parameters
[in]fileNameName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

Definition at line 24 of file Persistable.cc.

24 {
25 fits::Fits fitsfile(fileName, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
26 writeFits(fitsfile);
27}

Friends And Related Symbol Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream & os,
Storable const & storable )
related

Output operator for Storable.

Parameters
osthe desired output stream
storablethe object to print
Returns
a reference to os
Exceptions
UnsupportedOperationExceptionThrown if storable does not have an implementation of Storable::toString.

Definition at line 174 of file Storable.h.

174 {
175 return os << storable.toString();
176}

The documentation for this class was generated from the following files: