LSSTApplications  17.0+1,17.0+10,17.0+16,17.0+17,17.0+2,17.0+3,17.0+4,17.0-1-g377950a+9,17.0.1-1-g444bd44+10,17.0.1-1-g46e6382+11,17.0.1-1-g4d4fbc4+4,17.0.1-1-g5f4ed7e,17.0.1-1-g703d48b+6,17.0.1-1-g8de6c91,17.0.1-1-g9deacb5+10,17.0.1-1-gf4e0155+11,17.0.1-1-gfc65f5f+10,17.0.1-1-gfc6fb1f+5,17.0.1-2-g3bdf598,17.0.1-2-g3e5d191+1,17.0.1-2-ga5d6a7c+5,17.0.1-2-gd73ec07+11,17.0.1-3-gcbbb95d+5,17.0.1-3-geaa4c8a+4,17.0.1-4-gf25f8e6+1,17.0.1-5-g19503fb,17.0.1-5-g5a10bbc+2,17.0.1-5-ga118c797,17.0.1-6-g640019af,17.0.1-6-g7bb9714,17.0.1-7-gf7766dbc3,17.0.1-8-g879df34,w.2019.13
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | List of all members
lsst::afw::image::Calib Class Reference

Describe an exposure's calibration. More...

#include <Calib.h>

Inheritance diagram for lsst::afw::image::Calib:
lsst::afw::table::io::PersistableFacade< Calib > lsst::afw::table::io::Persistable

Public Member Functions

 Calib () noexcept
 ctor More...
 
 Calib (double fluxMag0)
 ctor from a given fluxMagnitude zero point More...
 
 Calib (std::vector< std::shared_ptr< Calib const >> const &calibs)
 ctor from a vector of Calibs More...
 
 Calib (std::shared_ptr< lsst::daf::base::PropertySet const >)
 ctor More...
 
 Calib (Calib const &) noexcept
 
 Calib (Calib &&) noexcept
 
Caliboperator= (Calib const &) noexcept
 
Caliboperator= (Calib &&) noexcept
 
 ~Calib () noexcept override
 
void setFluxMag0 (double fluxMag0, double fluxMag0Err=0.0)
 Set the flux of a zero-magnitude object. More...
 
void setFluxMag0 (std::pair< double, double > fluxMag0AndErr)
 
std::pair< double, double > getFluxMag0 () const
 Return the flux, and error in flux, of a zero-magnitude object. More...
 
double getFlux (double const mag) const
 Return a flux (in ADUs) given a magnitude. More...
 
std::pair< double, double > getFlux (double const mag, double const magErr) const
 Return a flux and flux error (in ADUs) given a magnitude and magnitude error. More...
 
ndarray::Array< double, 1 > getFlux (ndarray::Array< double const, 1 > const &mag) const
 
std::pair< ndarray::Array< double, 1 >, ndarray::Array< double, 1 > > getFlux (ndarray::Array< double const, 1 > const &mag, ndarray::Array< double const, 1 > const &magErr) const
 
double getMagnitude (double const flux) const
 Return a magnitude given a flux. More...
 
std::pair< double, double > getMagnitude (double const flux, double const fluxErr) const
 Return a magnitude and magnitude error given a flux and flux error. More...
 
ndarray::Array< double, 1 > getMagnitude (ndarray::Array< double const, 1 > const &flux) const
 
std::pair< ndarray::Array< double, 1 >, ndarray::Array< double, 1 > > getMagnitude (ndarray::Array< double const, 1 > const &flux, ndarray::Array< double const, 1 > const &fluxErr) const
 
bool operator== (Calib const &rhs) const noexcept
 Are two Calibs identical? More...
 
bool operator!= (Calib const &rhs) const noexcept
 
std::size_t hash_value () const noexcept
 Return a hash of this object. More...
 
Caliboperator*= (double const scale)
 
Caliboperator/= (double const scale)
 
bool isPersistable () const noexcept override
 Return true if this particular object can be persisted using afw::table::io. More...
 
void writeFits (std::string const &fileName, std::string const &mode="w") const
 Write the object to a regular FITS file. More...
 
void writeFits (fits::MemFileManager &manager, std::string const &mode="w") const
 Write the object to a FITS image in memory. More...
 
void writeFits (fits::Fits &fitsfile) const
 Write the object to an already-open FITS object. More...
 

Static Public Member Functions

static void setThrowOnNegativeFlux (bool raiseException) noexcept
 Set whether Calib should throw an exception when asked to convert a flux to a magnitude. More...
 
static bool getThrowOnNegativeFlux () noexcept
 Tell me whether Calib will throw an exception if asked to convert a flux to a magnitude. More...
 
static std::shared_ptr< CalibreadFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< CalibreadFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< CalibreadFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 
static std::shared_ptr< CalibdynamicCast (std::shared_ptr< Persistable > const &ptr)
 Dynamically cast a shared_ptr. More...
 

Protected Types

typedef io::OutputArchiveHandle OutputArchiveHandle
 

Protected Member Functions

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

Detailed Description

Describe an exposure's calibration.

Definition at line 95 of file Calib.h.

Member Typedef Documentation

◆ OutputArchiveHandle

typedef io::OutputArchiveHandle lsst::afw::table::io::Persistable::OutputArchiveHandle
protectedinherited

Definition at line 108 of file Persistable.h.

Constructor & Destructor Documentation

◆ Calib() [1/6]

lsst::afw::image::Calib::Calib ( )
explicitnoexcept

ctor

Definition at line 106 of file Calib.cc.

106 : _fluxMag0(0.0), _fluxMag0Err(0.0) {}

◆ Calib() [2/6]

lsst::afw::image::Calib::Calib ( double  fluxMag0)
explicit

ctor from a given fluxMagnitude zero point

Definition at line 107 of file Calib.cc.

107 : _fluxMag0(fluxMag0), _fluxMag0Err(0.0) {}
table::Key< double > fluxMag0
Definition: Calib.cc:378

◆ Calib() [3/6]

lsst::afw::image::Calib::Calib ( std::vector< std::shared_ptr< Calib const >> const &  calibs)
explicit

ctor from a vector of Calibs

Parameters
calibsSet of calibs to be merged
Note
All the input calibs must have the same zeropoint; throw InvalidParameterError if this isn't true

Definition at line 108 of file Calib.cc.

108  : _fluxMag0(0.0), _fluxMag0Err(0.0) {
109  if (calibs.empty()) {
111  "You must provide at least one input Calib");
112  }
113 
114  double const fluxMag00 = calibs[0]->_fluxMag0;
115  double const fluxMag0Err0 = calibs[0]->_fluxMag0Err;
116 
117  for (std::vector<std::shared_ptr<Calib const>>::const_iterator ptr = calibs.begin(); ptr != calibs.end();
118  ++ptr) {
119  Calib const& calib = **ptr;
120 
121  if (::fabs(fluxMag00 - calib._fluxMag0) > std::numeric_limits<double>::epsilon() ||
122  ::fabs(fluxMag0Err0 - calib._fluxMag0Err) > std::numeric_limits<double>::epsilon()) {
124  (boost::format("You may only combine calibs with the same fluxMag0: "
125  "%g +- %g v %g +- %g") %
126  calib.getFluxMag0().first % calib.getFluxMag0().second %
127  calibs[0]->getFluxMag0().first % calibs[0]->getFluxMag0().second)
128  .str());
129  }
130  }
131 }
uint64_t * ptr
Definition: RangeSet.cc:88
T empty(T... args)
Calib() noexcept
ctor
Definition: Calib.cc:106
T epsilon(T... args)
T end(T... args)
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:168
T fabs(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
STL class.
T begin(T... args)
Reports invalid arguments.
Definition: Runtime.h:66

◆ Calib() [4/6]

lsst::afw::image::Calib::Calib ( std::shared_ptr< lsst::daf::base::PropertySet const >  metadata)
explicit

ctor

Definition at line 133 of file Calib.cc.

133  {
134  double fluxMag0 = 0.0, fluxMag0Err = 0.0;
135 
136  auto key = "FLUXMAG0";
137  if (metadata->exists(key)) {
138  fluxMag0 = metadata->getAsDouble(key);
139 
140  key = "FLUXMAG0ERR";
141  if (metadata->exists(key)) {
142  fluxMag0Err = metadata->getAsDouble(key);
143  }
144  }
145 
146  _fluxMag0 = fluxMag0;
147  _fluxMag0Err = fluxMag0Err;
148 }
Key< U > key
Definition: Schema.cc:281
table::Key< double > fluxMag0
Definition: Calib.cc:378
table::Key< double > fluxMag0Err
Definition: Calib.cc:379

◆ Calib() [5/6]

lsst::afw::image::Calib::Calib ( Calib const &  )
defaultnoexcept

◆ Calib() [6/6]

lsst::afw::image::Calib::Calib ( Calib &&  )
defaultnoexcept

◆ ~Calib()

lsst::afw::image::Calib::~Calib ( )
overridedefaultnoexcept

Member Function Documentation

◆ 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 18 of file Persistable.cc.

18  {
20  if (!result) {
21  throw LSST_EXCEPT(pex::exceptions::TypeError, "Dynamic pointer cast failed");
22  }
23  return result;
24 }
uint64_t * ptr
Definition: RangeSet.cc:88
py::object result
Definition: schema.cc:322
T dynamic_pointer_cast(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ getFlux() [1/4]

double lsst::afw::image::Calib::getFlux ( double const  mag) const

Return a flux (in ADUs) given a magnitude.

Parameters
magthe magnitude of the object

Definition at line 242 of file Calib.cc.

242  {
243  checkNegativeFlux0(_fluxMag0);
244  return convertToFlux(_fluxMag0, mag);
245 }

◆ getFlux() [2/4]

std::pair< double, double > lsst::afw::image::Calib::getFlux ( double const  mag,
double const  magErr 
) const

Return a flux and flux error (in ADUs) given a magnitude and magnitude error.

Assumes that the errors are small and uncorrelated.

Parameters
magthe magnitude of the object
magErrthe error in the magnitude

Definition at line 257 of file Calib.cc.

257  {
258  checkNegativeFlux0(_fluxMag0);
259  double const flux = convertToFlux(_fluxMag0, mag);
260  double const fluxErr = convertToFluxErr(_fluxMag0Err / _fluxMag0, flux, magSigma);
261  return std::make_pair(flux, fluxErr);
262 }
T make_pair(T... args)

◆ getFlux() [3/4]

ndarray::Array< double, 1 > lsst::afw::image::Calib::getFlux ( ndarray::Array< double const, 1 > const &  mag) const

Definition at line 246 of file Calib.cc.

246  {
247  checkNegativeFlux0(_fluxMag0);
248  ndarray::Array<double, 1> flux = ndarray::allocate(mag.size());
249  ndarray::Array<double const, 1>::Iterator inIter = mag.begin();
250  ndarray::Array<double, 1>::Iterator outIter = flux.begin();
251  for (; inIter != mag.end(); ++inIter, ++outIter) {
252  *outIter = convertToFlux(_fluxMag0, *inIter);
253  }
254  return flux;
255 }
FastFinder::Iterator Iterator
Definition: FastFinder.cc:179

◆ getFlux() [4/4]

std::pair< ndarray::Array< double, 1 >, ndarray::Array< double, 1 > > lsst::afw::image::Calib::getFlux ( ndarray::Array< double const, 1 > const &  mag,
ndarray::Array< double const, 1 > const &  magErr 
) const

Definition at line 264 of file Calib.cc.

265  {
266  checkNegativeFlux0(_fluxMag0);
267  if (mag.size() != magErr.size()) {
268  throw LSST_EXCEPT(
270  (boost::format("Size of mag (%d) and magErr (%d) don't match") % mag.size() % magErr.size())
271  .str());
272  }
273 
274  ndarray::Array<double, 1> flux = ndarray::allocate(mag.size());
275  ndarray::Array<double, 1> fluxErr = ndarray::allocate(mag.size());
276  ndarray::Array<double const, 1>::Iterator magIter = mag.begin();
277  ndarray::Array<double const, 1>::Iterator magErrIter = magErr.begin();
278  ndarray::Array<double, 1>::Iterator fluxIter = flux.begin();
279  ndarray::Array<double, 1>::Iterator fluxErrIter = fluxErr.begin();
280 
281  double fluxMag0InvSNR = _fluxMag0Err / _fluxMag0;
282  for (; magIter != mag.end(); ++magIter, ++magErrIter, ++fluxIter, ++fluxErrIter) {
283  *fluxIter = convertToFlux(_fluxMag0, *magIter);
284  *fluxErrIter = convertToFluxErr(fluxMag0InvSNR, *fluxIter, *magErrIter);
285  }
286 
287  return std::make_pair(flux, fluxErr);
288 }
Reports attempts to exceed implementation-defined length limits for some classes. ...
Definition: Runtime.h:76
FastFinder::Iterator Iterator
Definition: FastFinder.cc:179
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:168
T make_pair(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ getFluxMag0()

std::pair< double, double > lsst::afw::image::Calib::getFluxMag0 ( ) const

Return the flux, and error in flux, of a zero-magnitude object.

Definition at line 198 of file Calib.cc.

198 { return std::make_pair(_fluxMag0, _fluxMag0Err); }
T make_pair(T... args)

◆ getMagnitude() [1/4]

double lsst::afw::image::Calib::getMagnitude ( double const  flux) const

Return a magnitude given a flux.

Parameters
fluxthe measured flux of the object (ADUs)

Definition at line 290 of file Calib.cc.

290  {
291  checkNegativeFlux0(_fluxMag0);
292  if (isNegativeFlux(flux, Calib::getThrowOnNegativeFlux())) {
294  }
295  return convertToMag(_fluxMag0, flux);
296 }
static bool getThrowOnNegativeFlux() noexcept
Tell me whether Calib will throw an exception if asked to convert a flux to a magnitude.
Definition: Calib.cc:152
T quiet_NaN(T... args)

◆ getMagnitude() [2/4]

std::pair< double, double > lsst::afw::image::Calib::getMagnitude ( double const  flux,
double const  fluxErr 
) const

Return a magnitude and magnitude error given a flux and flux error.

Parameters
fluxthe measured flux of the object (ADUs)
fluxErrthe error in the measured flux (ADUs)

Definition at line 298 of file Calib.cc.

298  {
299  checkNegativeFlux0(_fluxMag0);
300  if (isNegativeFlux(flux, Calib::getThrowOnNegativeFlux())) {
302  return std::make_pair(NaN, NaN);
303  }
304 
305  double mag, magErr;
306  convertToMagWithErr(&mag, &magErr, _fluxMag0, _fluxMag0Err, flux, fluxErr);
307  return std::make_pair(mag, magErr);
308 }
static bool getThrowOnNegativeFlux() noexcept
Tell me whether Calib will throw an exception if asked to convert a flux to a magnitude.
Definition: Calib.cc:152
T make_pair(T... args)
T quiet_NaN(T... args)

◆ getMagnitude() [3/4]

ndarray::Array< double, 1 > lsst::afw::image::Calib::getMagnitude ( ndarray::Array< double const, 1 > const &  flux) const

Definition at line 310 of file Calib.cc.

310  {
311  checkNegativeFlux0(_fluxMag0);
312  ndarray::Array<double, 1> mag = ndarray::allocate(flux.size());
313  ndarray::Array<double const, 1>::Iterator fluxIter = flux.begin();
314  ndarray::Array<double, 1>::Iterator magIter = mag.begin();
315  int nonPositive = 0;
316  for (; fluxIter != flux.end(); ++fluxIter, ++magIter) {
317  if (isNegativeFlux(*fluxIter, false)) {
318  ++nonPositive;
320  continue;
321  }
322  *magIter = convertToMag(_fluxMag0, *fluxIter);
323  }
324  if (nonPositive && Calib::getThrowOnNegativeFlux()) {
326  (boost::format("Flux must be >= 0: %d non-positive seen") % nonPositive).str());
327  }
328  return mag;
329 }
Reports arguments outside the domain of an operation.
Definition: Runtime.h:57
static bool getThrowOnNegativeFlux() noexcept
Tell me whether Calib will throw an exception if asked to convert a flux to a magnitude.
Definition: Calib.cc:152
FastFinder::Iterator Iterator
Definition: FastFinder.cc:179
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:168
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
T quiet_NaN(T... args)

◆ getMagnitude() [4/4]

std::pair< ndarray::Array< double, 1 >, ndarray::Array< double, 1 > > lsst::afw::image::Calib::getMagnitude ( ndarray::Array< double const, 1 > const &  flux,
ndarray::Array< double const, 1 > const &  fluxErr 
) const

Definition at line 331 of file Calib.cc.

332  {
333  checkNegativeFlux0(_fluxMag0);
334  if (flux.size() != fluxErr.size()) {
336  (boost::format("Size of flux (%d) and fluxErr (%d) don't match") % flux.size() %
337  fluxErr.size())
338  .str());
339  }
340 
341  ndarray::Array<double, 1> mag = ndarray::allocate(flux.size());
342  ndarray::Array<double, 1> magErr = ndarray::allocate(flux.size());
343  ndarray::Array<double const, 1>::Iterator fluxIter = flux.begin();
344  ndarray::Array<double const, 1>::Iterator fluxErrIter = fluxErr.begin();
345  ndarray::Array<double, 1>::Iterator magIter = mag.begin();
346  ndarray::Array<double, 1>::Iterator magErrIter = magErr.begin();
347  int nonPositive = 0;
348  for (; fluxIter != flux.end(); ++fluxIter, ++fluxErrIter, ++magIter, ++magErrIter) {
349  if (isNegativeFlux(*fluxIter, false)) {
350  ++nonPositive;
352  *magIter = NaN;
353  *magErrIter = NaN;
354  continue;
355  }
356  double f, df;
357  convertToMagWithErr(&f, &df, _fluxMag0, _fluxMag0Err, *fluxIter, *fluxErrIter);
358  *magIter = f;
359  *magErrIter = df;
360  }
361  if (nonPositive && Calib::getThrowOnNegativeFlux()) {
363  (boost::format("Flux must be >= 0: %d non-positive seen") % nonPositive).str());
364  }
365  return std::make_pair(mag, magErr);
366 }
Reports attempts to exceed implementation-defined length limits for some classes. ...
Definition: Runtime.h:76
Reports arguments outside the domain of an operation.
Definition: Runtime.h:57
static bool getThrowOnNegativeFlux() noexcept
Tell me whether Calib will throw an exception if asked to convert a flux to a magnitude.
Definition: Calib.cc:152
FastFinder::Iterator Iterator
Definition: FastFinder.cc:179
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:168
T make_pair(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
T quiet_NaN(T... args)

◆ getPersistenceName()

std::string lsst::afw::image::Calib::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 434 of file Calib.cc.

434 { return getCalibPersistenceName(); }

◆ getPythonModule()

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

◆ getThrowOnNegativeFlux()

bool lsst::afw::image::Calib::getThrowOnNegativeFlux ( )
staticnoexcept

Tell me whether Calib will throw an exception if asked to convert a flux to a magnitude.

Definition at line 152 of file Calib.cc.

152 { return _throwOnNegativeFlux; }

◆ hash_value()

std::size_t lsst::afw::image::Calib::hash_value ( ) const
noexcept

Return a hash of this object.

Definition at line 184 of file Calib.cc.

184  {
185  // Completely arbitrary seed
186  return utils::hashCombine(17, _fluxMag0, _fluxMag0Err);
187 }
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition: hashCombine.h:35

◆ isPersistable()

bool lsst::afw::image::Calib::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 210 of file Calib.h.

210 { return true; }

◆ operator!=()

bool lsst::afw::image::Calib::operator!= ( Calib const &  rhs) const
inlinenoexcept

Definition at line 199 of file Calib.h.

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

◆ operator*=()

Calib & lsst::afw::image::Calib::operator*= ( double const  scale)

Definition at line 446 of file Calib.cc.

446  {
447  _fluxMag0 *= scale;
448  _fluxMag0Err *= scale;
449  return *this;
450 }
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:109

◆ operator/=()

Calib& lsst::afw::image::Calib::operator/= ( double const  scale)
inline

Definition at line 205 of file Calib.h.

205  {
206  (*this) *= 1.0 / scale;
207  return *this;
208  }
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:109

◆ operator=() [1/2]

Calib & lsst::afw::image::Calib::operator= ( Calib const &  )
defaultnoexcept

◆ operator=() [2/2]

Calib & lsst::afw::image::Calib::operator= ( Calib &&  )
defaultnoexcept

◆ operator==()

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

Are two Calibs identical?

Note
Maybe this should be an approximate comparison

Definition at line 180 of file Calib.cc.

180  {
181  return _fluxMag0 == rhs._fluxMag0 && _fluxMag0Err == rhs._fluxMag0Err;
182 }

◆ readFits() [1/3]

static std::shared_ptr<Calib > lsst::afw::table::io::PersistableFacade< Calib >::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  {
184  return dynamicCast(Persistable::_readFits(fitsfile));
185  }
static std::shared_ptr< Calib > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18

◆ readFits() [2/3]

static std::shared_ptr<Calib > lsst::afw::table::io::PersistableFacade< Calib >::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  {
195  return dynamicCast(Persistable::_readFits(fileName, hdu));
196  }
static std::shared_ptr< Calib > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18

◆ readFits() [3/3]

static std::shared_ptr<Calib > lsst::afw::table::io::PersistableFacade< Calib >::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  {
206  return dynamicCast(Persistable::_readFits(manager, hdu));
207  }
static std::shared_ptr< Calib > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18

◆ setFluxMag0() [1/2]

void lsst::afw::image::Calib::setFluxMag0 ( double  fluxMag0,
double  fluxMag0Err = 0.0 
)

Set the flux of a zero-magnitude object.

Parameters
fluxMag0The flux in question (ADUs)
fluxMag0ErrThe error in the flux (ADUs)

Definition at line 189 of file Calib.cc.

189  {
190  _fluxMag0 = fluxMag0;
191  _fluxMag0Err = fluxMag0Err;
192 }
table::Key< double > fluxMag0
Definition: Calib.cc:378
table::Key< double > fluxMag0Err
Definition: Calib.cc:379

◆ setFluxMag0() [2/2]

void lsst::afw::image::Calib::setFluxMag0 ( std::pair< double, double >  fluxMag0AndErr)
Parameters
fluxMag0AndErrThe flux and error (ADUs)

Definition at line 193 of file Calib.cc.

193  {
194  _fluxMag0 = fluxMag0AndErr.first;
195  _fluxMag0Err = fluxMag0AndErr.second;
196 }

◆ setThrowOnNegativeFlux()

void lsst::afw::image::Calib::setThrowOnNegativeFlux ( bool  raiseException)
staticnoexcept

Set whether Calib should throw an exception when asked to convert a flux to a magnitude.

Parameters
raiseExceptionShould the exception be raised?

Definition at line 150 of file Calib.cc.

150 { _throwOnNegativeFlux = raiseException; }

◆ write()

void lsst::afw::image::Calib::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 436 of file Calib.cc.

436  {
437  CalibKeys const keys{};
438  table::BaseCatalog cat = handle.makeCatalog(keys.schema);
439  std::shared_ptr<table::BaseRecord> record = cat.addNew();
441  record->set(keys.fluxMag0, fluxMag0.first);
442  record->set(keys.fluxMag0Err, fluxMag0.second);
443  handle.saveCatalog(cat);
444 }
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71
table::Key< double > fluxMag0
Definition: Calib.cc:378
std::pair< double, double > getFluxMag0() const
Return the flux, and error in flux, of a zero-magnitude object.
Definition: Calib.cc:198

◆ writeFits() [1/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 }
void writeFits(std::string const &fileName, std::string const &mode="w") const
Write the object to a regular FITS file.
Definition: Persistable.cc:24

◆ 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.
Definition: Persistable.cc:24

◆ writeFits() [3/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 }

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