48 if (primaryMetadata->exists(versionName)) {
49 version = primaryMetadata->getAsInt(versionName);
50 primaryMetadata->remove(versionName);
71 imageMetadata->remove(
"LTV1");
72 imageMetadata->remove(
"LTV2");
74 if (!imageMetadata->exists(
"INHERIT")) {
88 visitInfo = std::make_shared<VisitInfo>(*metadata);
98 metadata->remove(
"MJD-OBS");
99 metadata->remove(
"DATE-OBS");
103 metadata->remove(
"DETNAME");
104 metadata->remove(
"DETSER");
144 _hdu = popInt(
"AR_HDU");
146 _state = ArchiveState::MISSING;
149 _state = ArchiveState::PRESENT;
151 _ids[PSF] = popInt(
"PSF_ID");
152 _ids[WCS] = popInt(
"SKYWCS_ID");
153 _ids[COADD_INPUTS] = popInt(
"COADD_INPUTS_ID");
154 _ids[AP_CORR_MAP] = popInt(
"AP_CORR_MAP_ID");
155 _ids[VALID_POLYGON] = popInt(
"VALID_POLYGON_ID");
156 _ids[TRANSMISSION_CURVE] = popInt(
"TRANSMISSION_CURVE_ID");
157 _ids[DETECTOR] = popInt(
"DETECTOR_ID");
158 _ids[PHOTOCALIB] = popInt(
"PHOTOCALIB_ID");
161 template <
typename T>
163 if (!_ensureLoaded(fitsFile)) {
171 if (_state == ArchiveState::MISSING) {
174 if (_state == ArchiveState::PRESENT) {
177 _state = ArchiveState::LOADED;
179 assert(_state == ArchiveState::LOADED);
183 enum class ArchiveState {
UNKNOWN, MISSING, PRESENT, LOADED };
200 return _maskedImageReader.
readBBox(origin);
204 return _maskedImageReader.
readXY0(bbox, origin);
215 return _metadataReader->metadata;
222 r = _metadataReader->wcs;
229 return _metadataReader->filter;
234 if (_metadataReader->version == 0) {
235 return _metadataReader->photoCalib;
264 return _metadataReader->visitInfo;
279 auto result = std::make_shared<ExposureInfo>();
291 LOGLS_WARN(_log,
"Could not read PSF; setting to null: " << err.
what());
296 LOGLS_WARN(_log,
"Could not read CoaddInputs; setting to null: " << err.
what());
301 LOGLS_WARN(_log,
"Could not read ApCorrMap; setting to null: " << err.
what());
306 LOGLS_WARN(_log,
"Could not read ValidPolygon; setting to null: " << err.
what());
311 LOGLS_WARN(_log,
"Could not read TransmissionCurve; setting to null: " << err.
what());
316 LOGLS_WARN(_log,
"Could not read Detector; setting to null: " << err.
what());
321 result->setWcs(_metadataReader->wcs);
330 auto msg =
str(
boost::format(
"Could not read WCS extension; setting to null: %s") % err.
what());
332 msg +=
" ; using WCS from FITS header";
339 template <
typename ImagePixelT>
342 return _maskedImageReader.
readImage<ImagePixelT>(
bbox, origin, allowUnsafe);
345 template <
typename ImagePixelT>
351 template <
typename MaskPixelT>
353 bool conformMasks,
bool allowUnsafe) {
354 return _maskedImageReader.
readMask<MaskPixelT>(
bbox, origin, conformMasks, allowUnsafe);
357 template <
typename MaskPixelT>
363 template <
typename VariancePixelT>
366 return _maskedImageReader.
readVariance<VariancePixelT>(
bbox, origin, allowUnsafe);
369 template <
typename VariancePixelT>
376 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
379 return _maskedImageReader.
read<ImagePixelT, MaskPixelT, VariancePixelT>(
bbox, origin, conformMasks,
384 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
390 readMaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>(
bbox, origin, conformMasks, allowUnsafe);
394 void ExposureFitsReader::_ensureReaders() {
395 if (!_metadataReader) {
396 auto metadataReader = std::make_unique<MetadataReader>(_maskedImageReader.
readPrimaryMetadata(),
399 _archiveReader = std::make_unique<ArchiveReader>(*metadataReader->metadata);
400 _metadataReader =
std::move(metadataReader);
402 assert(_archiveReader);
405 #define INSTANTIATE(ImagePixelT) \ 406 template Exposure<ImagePixelT, MaskPixel, VariancePixel> ExposureFitsReader::read( \ 407 lsst::geom::Box2I const&, ImageOrigin, bool, bool); \ 408 template Image<ImagePixelT> ExposureFitsReader::readImage(lsst::geom::Box2I const&, ImageOrigin, bool); \ 409 template ndarray::Array<ImagePixelT, 2, 2> ExposureFitsReader::readImageArray(lsst::geom::Box2I const&, \ 410 ImageOrigin, bool); \ 411 template MaskedImage<ImagePixelT, MaskPixel, VariancePixel> ExposureFitsReader::readMaskedImage( \ 412 lsst::geom::Box2I const&, ImageOrigin, bool, bool) #define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
static std::string const & getFitsSerializationVersionName()
Get the version of FITS serialization version info name.
std::shared_ptr< T > readComponent(afw::fits::Fits *fitsFile, Component c)
std::shared_ptr< PhotoCalib > makePhotoCalibFromMetadata(daf::base::PropertySet &metadata, bool strip=false)
Construct a PhotoCalib from FITS FLUXMAG0/FLUXMAG0ERR keywords.
lsst::geom::Box2I readBBox(ImageOrigin origin=PARENT)
Read the bounding box of the on-disk image.
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
A spatially-varying transmission curve as a function of wavelength.
std::shared_ptr< ExposureInfo > readExposureInfo()
Read the ExposureInfo containing all non-image components.
CoordinateExpr< N > ne(Point< T, N > const &other) const noexcept
lsst::geom::Box2I readBBox(ImageOrigin origin=PARENT)
Read the bounding box of the on-disk image.
Image< VariancePixelT > readVariance(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
The photometric calibration of an exposure.
Class for storing ordered metadata with comments.
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
A class to contain the data, WCS, and other information needed to describe an image of the sky...
std::string readVarianceDType() const
Read a string describing the pixel type of the on-disk image plane.
std::shared_ptr< CoaddInputs > readCoaddInputs()
Read the Exposure's coadd input catalogs.
ndarray::Array< MaskPixelT, 2, 2 > readMaskArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the mask plane.
Image< VariancePixelT > readVariance(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.
ndarray::Array< VariancePixelT, 2, 2 > readVarianceArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
ArchiveReader(daf::base::PropertyList &metadata)
std::shared_ptr< VisitInfo > readVisitInfo()
Read the Exposure's visit metadata.
Image< ImagePixelT > readImage(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
static int getFitsSerializationVersion()
Get the version of FITS serialization that this ExposureInfo understands.
ExposureFitsReader(std::string const &fileName)
Construct a FITS reader object.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
std::shared_ptr< PhotoCalib > readPhotoCalib()
Read the Exposure's photometric calibration.
Rotation angle is unknown.
table::Key< table::Array< std::uint8_t > > wcs
Image< ImagePixelT > readImage(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
std::string readImageDType() const
Read a string describing the pixel type of the on-disk image plane.
LSST DM logging module built on log4cxx.
Filter readFilter()
Read the Exposure's filter.
virtual void remove(std::string const &name)
Remove all values for a property name (possibly hierarchical).
Reports attempts to access elements using an invalid key.
virtual char const * what(void) const noexcept
Return a character string summarizing this exception.
std::shared_ptr< afw::geom::polygon::Polygon > readValidPolygon()
Read the polygon describing the region of validity for the Exposure.
~ExposureFitsReader() noexcept
#define LOGLS_DEBUG(logger, message)
Log a debug-level message using an iostream-based interface.
A base class for image defects.
Represent a 2-dimensional array of bitmask pixels.
Lifetime-management for memory that goes into FITS memory files.
std::string readImageDType() const
Read a string describing the pixel type of the on-disk image plane.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
A class to manipulate images, masks, and variance as a single object.
std::shared_ptr< daf::base::PropertyList > readPrimaryMetadata()
Read the FITS header of one of the HDUs.
bool exists(std::string const &name) const
Determine if a name (possibly hierarchical) exists.
std::string readMaskDType() const
Read a string describing the pixel type of the on-disk image plane.
Holds an integer identifier for an LSST filter.
std::shared_ptr< afw::geom::SkyWcs > readWcs()
Read the Exposure's world coordinate system.
std::shared_ptr< io::OutputArchive > _archive
Mask< MaskPixelT > readMask(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool allowUnsafe=false)
Read the mask plane.
ndarray::Array< VariancePixelT, 2, 2 > readVarianceArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
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.
std::shared_ptr< ApCorrMap > readApCorrMap()
Read the Exposure's aperture correction map.
std::string readMaskDType() const
Read a string describing the pixel type of the on-disk image plane.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
T get(std::string const &name) const
Get the last value for a property name (possibly hierarchical).
Information about a CCD or other imaging detector.
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< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
std::string readVarianceDType() const
Read a string describing the pixel type of the on-disk image plane.
ndarray::Array< ImagePixelT, 2, 2 > readImageArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
#define INSTANTIATE(ImagePixelT)
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
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< cameraGeom::Detector > readDetector()
Read the Exposure's detector.
ndarray::Array< MaskPixelT, 2, 2 > readMaskArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the mask plane.
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.
std::shared_ptr< daf::base::PropertyList > readMetadata()
Read the flexible metadata associated with the Exposure.
std::shared_ptr< daf::base::PropertyList > readImageMetadata()
Read the FITS header of one of the HDUs.
std::shared_ptr< detection::Psf > readPsf()
Read the Exposure's point-spread function.
Mask< MaskPixelT > readMask(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool allowUnsafe=false)
Read the mask plane.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
Reports errors from accepting an object of an unexpected or inappropriate type.
#define LOG_GET(logger)
Returns a Log object associated with logger.
A polymorphic base class for representing an image's Point Spread Function.
std::shared_ptr< TransmissionCurve > readTransmissionCurve()
Read the Exposure's transmission curve.
An integer coordinate rectangle.
A class to represent a 2-dimensional array of pixels.
ndarray::Array< ImagePixelT, 2, 2 > readImageArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
RAII scoped guard for moving the HDU in a Fits object.
Implementation of the Photometric Calibration class.
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.