LSSTApplications
19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
41 template <
typename T, std::
size_t N>
43 for (T
const&
element : array) {
58 if (primaryMetadata->exists(versionName)) {
59 version = primaryMetadata->getAsInt(versionName);
60 primaryMetadata->remove(versionName);
66 str(
boost::format(
"Cannot read Exposure FITS version >= %i") %
81 imageMetadata->remove(
"LTV1");
82 imageMetadata->remove(
"LTV2");
84 if (!imageMetadata->exists(
"INHERIT")) {
154 _hdu = popInt(
"AR_HDU");
156 _state = ArchiveState::MISSING;
159 _state = ArchiveState::PRESENT;
162 _ids[
PSF] = popInt(
"PSF_ID");
163 _ids[
WCS] = popInt(
"SKYWCS_ID");
168 _ids[
DETECTOR] = popInt(
"DETECTOR_ID");
175 if (headerKey.substr(0, PREFIX.
size()) == PREFIX) {
177 int archiveId = metadata.get<
int>(headerKey);
178 if (!_contains(_ids, archiveId)) {
179 _extraIds.
emplace(componentName, archiveId);
182 toStrip.
push_back(componentName +
"_ID");
186 metadata.remove(
key);
199 template <
typename T>
201 if (!_ensureLoaded(fitsFile)) {
204 return _archive.
get<T>(_ids[c]);
220 if (!_ensureLoaded(fitsFile)) {
226 for (
auto const& keyValue : _extraIds) {
228 int archiveId = keyValue.second;
231 result.emplace(componentName, _archive.
get(archiveId));
234 "Could not read component " << componentName <<
"; skipping: " << err.
what());
242 if (_state == ArchiveState::MISSING) {
245 if (_state == ArchiveState::PRESENT) {
248 _state = ArchiveState::LOADED;
250 assert(_state == ArchiveState::LOADED);
254 enum class ArchiveState { UNKNOWN, MISSING, PRESENT, LOADED };
257 ArchiveState _state = ArchiveState::UNKNOWN;
258 table::io::InputArchive _archive;
272 return _maskedImageReader.
readBBox(origin);
287 return _metadataReader->metadata;
294 r = _metadataReader->wcs;
301 return _metadataReader->filter;
306 if (_metadataReader->version == 0) {
307 return _metadataReader->photoCalib;
336 return _metadataReader->visitInfo;
352 return _archiveReader->readExtraComponents(_getFitsFile());
356 auto result = std::make_shared<ExposureInfo>();
368 LOGLS_WARN(_log,
"Could not read PSF; setting to null: " << err.
what());
373 LOGLS_WARN(_log,
"Could not read CoaddInputs; setting to null: " << err.
what());
378 LOGLS_WARN(_log,
"Could not read ApCorrMap; setting to null: " << err.
what());
383 LOGLS_WARN(_log,
"Could not read ValidPolygon; setting to null: " << err.
what());
388 LOGLS_WARN(_log,
"Could not read TransmissionCurve; setting to null: " << err.
what());
393 LOGLS_WARN(_log,
"Could not read Detector; setting to null: " << err.
what());
398 result->setWcs(_metadataReader->wcs);
407 auto msg = str(
boost::format(
"Could not read WCS extension; setting to null: %s") % err.
what());
409 msg +=
" ; using WCS from FITS header";
416 StorablePtr
object = std::dynamic_pointer_cast<StorablePtr::element_type>(keyValue.second);
418 if (
object.use_count() > 0) {
419 result->setComponent(typehandling::makeKey<StorablePtr>(
key),
object);
421 LOGLS_WARN(_log,
"Data corruption: generic component " <<
key <<
" is not a Storable; skipping.");
427 template <
typename ImagePixelT>
430 return _maskedImageReader.
readImage<ImagePixelT>(
bbox, origin, allowUnsafe);
433 template <
typename ImagePixelT>
439 template <
typename MaskPixelT>
441 bool conformMasks,
bool allowUnsafe) {
442 return _maskedImageReader.
readMask<MaskPixelT>(
bbox, origin, conformMasks, allowUnsafe);
445 template <
typename MaskPixelT>
451 template <
typename VariancePixelT>
454 return _maskedImageReader.
readVariance<VariancePixelT>(
bbox, origin, allowUnsafe);
457 template <
typename VariancePixelT>
464 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
467 return _maskedImageReader.
read<ImagePixelT, MaskPixelT, VariancePixelT>(
bbox, origin, conformMasks,
472 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
478 readMaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>(
bbox, origin, conformMasks, allowUnsafe);
482 void ExposureFitsReader::_ensureReaders() {
483 if (!_metadataReader) {
484 auto metadataReader = std::make_unique<MetadataReader>(_maskedImageReader.
readPrimaryMetadata(),
487 _archiveReader = std::make_unique<ArchiveReader>(*metadataReader->metadata);
488 _metadataReader =
std::move(metadataReader);
490 assert(_archiveReader);
493 #define INSTANTIATE(ImagePixelT) \
494 template Exposure<ImagePixelT, MaskPixel, VariancePixel> ExposureFitsReader::read( \
495 lsst::geom::Box2I const&, ImageOrigin, bool, bool); \
496 template Image<ImagePixelT> ExposureFitsReader::readImage(lsst::geom::Box2I const&, ImageOrigin, bool); \
497 template ndarray::Array<ImagePixelT, 2, 2> ExposureFitsReader::readImageArray(lsst::geom::Box2I const&, \
498 ImageOrigin, bool); \
499 template MaskedImage<ImagePixelT, MaskPixel, VariancePixel> ExposureFitsReader::readMaskedImage( \
500 lsst::geom::Box2I const&, ImageOrigin, bool, bool)
Image< ImagePixelT > readImage(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > readMaskedImage(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool allowUnsafe=false)
Read the MaskedImage.
std::shared_ptr< daf::base::PropertyList > readPrimaryMetadata()
Read the FITS header of one of the HDUs.
ndarray::Array< VariancePixelT, 2, 2 > readVarianceArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
int stripFilterKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Filter-related keywords from the metadata.
ExposureFitsReader(std::string const &fileName)
Construct a FITS reader object.
Represent a 2-dimensional array of bitmask pixels.
std::shared_ptr< PhotoCalib > makePhotoCalibFromMetadata(daf::base::PropertySet &metadata, bool strip=false)
Construct a PhotoCalib from FITS FLUXMAG0/FLUXMAG0ERR keywords.
ndarray::Array< MaskPixelT, 2, 2 > readMaskArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the mask plane.
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Filter readFilter()
Read the Exposure's filter.
Image< VariancePixelT > readVariance(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
table::Key< table::Array< std::uint8_t > > wcs
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Reports attempts to access elements using an invalid key.
Holds an integer identifier for an LSST filter.
ndarray::Array< MaskPixelT, 2, 2 > readMaskArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the mask plane.
RAII scoped guard for moving the HDU in a Fits object.
lsst::geom::Box2I readBBox(ImageOrigin origin=PARENT)
Read the bounding box of the on-disk image.
ArchiveReader(daf::base::PropertyList &metadata)
std::map< std::string, std::shared_ptr< table::io::Persistable > > readExtraComponents(afw::fits::Fits *fitsFile)
Read the components that are stored using arbitrary-component support.
Class for storing ordered metadata with comments.
bool exists(std::string const &name) const
Determine if a name (possibly hierarchical) exists.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
std::map< std::string, std::shared_ptr< table::io::Persistable > > readExtraComponents()
Read the Exposure's non-standard components.
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
std::string readImageDType() const
Read a string describing the pixel type of the on-disk image plane.
Lifetime-management for memory that goes into FITS memory files.
std::shared_ptr< cameraGeom::Detector > readDetector()
Read the Exposure's detector.
std::string readVarianceDType() const
Read a string describing the pixel type of the on-disk image plane.
static int getFitsSerializationVersion()
Get the version of FITS serialization that this ExposureInfo understands.
T get(std::string const &name) const
Get the last value for a property name (possibly hierarchical).
std::string readVarianceDType() const
Read a string describing the pixel type of the on-disk image plane.
std::shared_ptr< ExposureInfo > readExposureInfo()
Read the ExposureInfo containing all non-image components.
#define LOGLS_WARN(logger, message)
Image< VariancePixelT > readVariance(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
A class to manipulate images, masks, and variance as a single object.
std::shared_ptr< daf::base::PropertyList > readMetadata()
Read the flexible metadata associated with the Exposure.
std::shared_ptr< afw::geom::SkyWcs > readWcs()
Read the Exposure's world coordinate system.
std::shared_ptr< CoaddInputs > readCoaddInputs()
Read the Exposure's coadd input catalogs.
Image< ImagePixelT > readImage(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
std::string readMaskDType() const
Read a string describing the pixel type of the on-disk image plane.
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
static std::string const & getFitsSerializationVersionName()
Get the version of FITS serialization version info name.
Mask< MaskPixelT > readMask(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool allowUnsafe=false)
Read the mask plane.
The photometric calibration of an exposure.
lsst::geom::Point2I readXY0(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT)
Read the image origin from the on-disk image or a subimage thereof.
std::shared_ptr< T > readComponent(afw::fits::Fits *fitsFile, Component c)
Read a known component, if available.
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > read(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool needAllHdus=false, bool allowUnsafe=false)
Read the full MaskedImage.
lsst::geom::Point2I readXY0(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT)
Read the image origin from the on-disk image or a subimage thereof.
A base class for image defects.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
#define LOGLS_DEBUG(logger, message)
std::shared_ptr< ApCorrMap > readApCorrMap()
Read the Exposure's aperture correction map.
A spatially-varying transmission curve as a function of wavelength.
A FITS reader class for Exposures and their components.
std::shared_ptr< TransmissionCurve > readTransmissionCurve()
Read the Exposure's transmission curve.
ndarray::Array< ImagePixelT, 2, 2 > readImageArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
std::shared_ptr< daf::base::PropertyList > readImageMetadata()
Read the FITS header of one of the HDUs.
std::string readMaskDType() const
Read a string describing the pixel type of the on-disk image plane.
Implementation of the Photometric Calibration class.
std::string readImageDType() const
Read a string describing the pixel type of the on-disk image plane.
std::shared_ptr< VisitInfo > readVisitInfo()
Read the Exposure's visit metadata.
An integer coordinate rectangle.
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
std::shared_ptr< afw::geom::polygon::Polygon > readValidPolygon()
Read the polygon describing the region of validity for the Exposure.
Mask< MaskPixelT > readMask(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool allowUnsafe=false)
Read the mask plane.
virtual void remove(std::string const &name)
Remove all values for a property name (possibly hierarchical).
A polymorphic base class for representing an image's Point Spread Function.
Reports errors from accepting an object of an unexpected or inappropriate type.
std::shared_ptr< detection::Psf > readPsf()
Read the Exposure's point-spread function.
std::shared_ptr< PhotoCalib > readPhotoCalib()
Read the Exposure's photometric calibration.
Exposure< ImagePixelT, MaskPixelT, VariancePixelT > read(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool allowUnsafe=false)
Read the full Exposure.
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
#define INSTANTIATE(ImagePixelT)
ndarray::Array< VariancePixelT, 2, 2 > readVarianceArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
virtual char const * what(void) const noexcept
Return a character string summarizing this exception.
ndarray::Array< ImagePixelT, 2, 2 > readImageArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
LSST DM logging module built on log4cxx.
~ExposureFitsReader() noexcept
A representation of a detector in a mosaic camera.