49 if (primaryMetadata->exists(versionName)) {
50 version = primaryMetadata->getAsInt(versionName);
51 primaryMetadata->remove(versionName);
72 imageMetadata->remove(
"LTV1");
73 imageMetadata->remove(
"LTV2");
75 if (!imageMetadata->exists(
"INHERIT")) {
89 visitInfo = std::make_shared<VisitInfo>(*metadata);
97 metadata->remove(
"MJD-OBS");
98 metadata->remove(
"DATE-OBS");
102 metadata->remove(
"DETNAME");
103 metadata->remove(
"DETSER");
141 _hdu = popInt(
"AR_HDU");
143 _state = ArchiveState::MISSING;
146 _state = ArchiveState::PRESENT;
148 _ids[PSF] = popInt(
"PSF_ID");
149 _ids[WCS] = popInt(
"SKYWCS_ID");
150 _ids[COADD_INPUTS] = popInt(
"COADD_INPUTS_ID");
151 _ids[AP_CORR_MAP] = popInt(
"AP_CORR_MAP_ID");
152 _ids[VALID_POLYGON] = popInt(
"VALID_POLYGON_ID");
153 _ids[TRANSMISSION_CURVE] = popInt(
"TRANSMISSION_CURVE_ID");
154 _ids[DETECTOR] = popInt(
"DETECTOR_ID");
157 template <
typename T>
159 if (!_ensureLoaded(fitsFile)) {
167 if (_state == ArchiveState::MISSING) {
170 if (_state == ArchiveState::PRESENT) {
173 _state = ArchiveState::LOADED;
175 assert(_state == ArchiveState::LOADED);
179 enum class ArchiveState {
UNKNOWN, MISSING, PRESENT, LOADED };
196 return _maskedImageReader.
readBBox(origin);
200 return _maskedImageReader.
readXY0(bbox, origin);
211 return _metadataReader->metadata;
218 r = _metadataReader->wcs;
225 return _metadataReader->filter;
230 return _metadataReader->calib;
256 return _metadataReader->visitInfo;
271 auto result = std::make_shared<ExposureInfo>();
283 LOGLS_WARN(_log,
"Could not read PSF; setting to null: " << err.
what());
288 LOGLS_WARN(_log,
"Could not read CoaddInputs; setting to null: " << err.
what());
293 LOGLS_WARN(_log,
"Could not read ApCorrMap; setting to null: " << err.
what());
298 LOGLS_WARN(_log,
"Could not read ValidPolygon; setting to null: " << err.
what());
303 LOGLS_WARN(_log,
"Could not read TransmissionCurve; setting to null: " << err.
what());
308 LOGLS_WARN(_log,
"Could not read Detector; setting to null: " << err.
what());
313 result->setWcs(_metadataReader->wcs);
322 auto msg =
str(
boost::format(
"Could not read WCS extension; setting to null: %s") % err.
what());
324 msg +=
" ; using WCS from FITS header";
331 template <
typename ImagePixelT>
334 return _maskedImageReader.
readImage<ImagePixelT>(
bbox, origin, allowUnsafe);
337 template <
typename ImagePixelT>
343 template <
typename MaskPixelT>
345 bool conformMasks,
bool allowUnsafe) {
346 return _maskedImageReader.
readMask<MaskPixelT>(
bbox, origin, conformMasks, allowUnsafe);
349 template <
typename MaskPixelT>
355 template <
typename VariancePixelT>
358 return _maskedImageReader.
readVariance<VariancePixelT>(
bbox, origin, allowUnsafe);
361 template <
typename VariancePixelT>
368 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
371 return _maskedImageReader.
read<ImagePixelT, MaskPixelT, VariancePixelT>(
bbox, origin, conformMasks,
376 template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
382 readMaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>(
bbox, origin, conformMasks, allowUnsafe);
386 void ExposureFitsReader::_ensureReaders() {
387 if (!_metadataReader) {
388 auto metadataReader = std::make_unique<MetadataReader>(_maskedImageReader.
readPrimaryMetadata(),
391 _archiveReader = std::make_unique<ArchiveReader>(*metadataReader->metadata);
392 _metadataReader =
std::move(metadataReader);
394 assert(_archiveReader);
397 #define INSTANTIATE(ImagePixelT) \ 398 template Exposure<ImagePixelT, MaskPixel, VariancePixel> ExposureFitsReader::read( \ 399 lsst::geom::Box2I const&, ImageOrigin, bool, bool); \ 400 template Image<ImagePixelT> ExposureFitsReader::readImage(lsst::geom::Box2I const&, ImageOrigin, bool); \ 401 template ndarray::Array<ImagePixelT, 2, 2> ExposureFitsReader::readImageArray(lsst::geom::Box2I const&, \ 402 ImageOrigin, bool); \ 403 template MaskedImage<ImagePixelT, MaskPixel, VariancePixel> ExposureFitsReader::readMaskedImage( \ 404 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)
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.
std::shared_ptr< Calib > readCalib()
Read the Exposure's photometric calibration.
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...
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.
int stripCalibKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Calib-related keywords from the metadata.
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.
table::Key< int > version
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.
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.
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.