LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst::afw::image::ExposureFitsReader::MetadataReader Class Reference

Public Member Functions

 MetadataReader (std::shared_ptr< daf::base::PropertyList > primaryMetadata, std::shared_ptr< daf::base::PropertyList > imageMetadata, lsst::geom::Point2I const &xy0)
 

Public Attributes

int version
 
std::optional< table::RecordIdexposureId
 
std::shared_ptr< daf::base::PropertyListmetadata
 
std::shared_ptr< FilterLabelfilterLabel
 
std::shared_ptr< afw::geom::SkyWcswcs
 
std::shared_ptr< PhotoCalibphotoCalib
 
std::shared_ptr< VisitInfovisitInfo
 

Detailed Description

Definition at line 230 of file ExposureFitsReader.cc.

Constructor & Destructor Documentation

◆ MetadataReader()

lsst::afw::image::ExposureFitsReader::MetadataReader::MetadataReader ( std::shared_ptr< daf::base::PropertyList primaryMetadata,
std::shared_ptr< daf::base::PropertyList imageMetadata,
lsst::geom::Point2I const &  xy0 
)
inline

Definition at line 232 of file ExposureFitsReader.cc.

233  {
235  if (primaryMetadata->exists(versionName)) {
236  version = primaryMetadata->getAsInt(versionName);
237  primaryMetadata->remove(versionName);
238  } else {
239  version = 0; // unversioned files are implicitly version 0
240  }
242  throw LSST_EXCEPT(pex::exceptions::TypeError,
243  str(boost::format("Cannot read Exposure FITS version > %i") %
245  }
246 
247  // Try to read WCS from image metadata, and if found, strip the keywords used
248  try {
249  wcs = afw::geom::makeSkyWcs(*imageMetadata, true);
250  } catch (lsst::pex::exceptions::TypeError const&) {
251  LOGLS_DEBUG(_log, "No WCS found in FITS metadata");
252  }
253  if (wcs && any(xy0.ne(lsst::geom::Point2I(0, 0)))) {
254  wcs = wcs->copyAtShiftedPixelOrigin(lsst::geom::Extent2D(xy0));
255  }
256 
257  // Strip LTV1, LTV2 from imageMetadata, because we don't use it internally
258  imageMetadata->remove("LTV1");
259  imageMetadata->remove("LTV2");
260 
261  if (!imageMetadata->exists("INHERIT")) {
262  // New-style exposures put everything but the Wcs in the primary HDU, use
263  // INHERIT keyword in the others. For backwards compatibility, if we don't
264  // find the INHERIT keyword, we ignore the primary HDU metadata and expect
265  // everything to be in the image HDU metadata. Note that we can't merge them,
266  // because they're probably duplicates.
267  metadata = imageMetadata;
268  } else {
269  metadata = primaryMetadata;
270  }
271 
272  // Earlier versions persisted Filter as header keyword, version 2 persists FilterLabel as a Storable
273  if (version < 2) {
274  std::string key = "FILTER";
275  if (metadata->exists(key)) {
276  // Original Filter code depended on Boost for string trimming.
277  // DIY to avoid making this module depend on Boost.
278  std::string name = metadata->getAsString(key);
279  size_t end = name.find_last_not_of(' ');
280  filterLabel = makeFilterLabel(name.substr(0, end + 1));
281  }
282  }
283 
284  // EXPID keyword used in all versions, but was VisitInfo's responsibility before VisitInfo v3.
285  if (metadata->exists("EXPID")) {
286  exposureId = metadata->getAsInt64("EXPID");
287  }
288 
289  visitInfo = std::make_shared<VisitInfo>(*metadata);
291 
292  // This keyword is no longer handled by VisitInfo version >= 3.
293  metadata->remove("EXPID");
294 
295  // Version 0 persisted Calib FLUXMAG0 in the metadata, >=1 persisted PhotoCalib as a binary table.
296  if (version == 0) {
298  }
299 
300  // Strip MJD-OBS and DATE-OBS from metadata; those may be read by
301  // either SkyWcs or VisitInfo or both, so neither can strip them.
302  metadata->remove("MJD-OBS");
303  metadata->remove("DATE-OBS");
304 
305  // Strip DETSER, DETNAME; these are added when writing an Exposure
306  // with a Detector
307  metadata->remove("DETNAME");
308  metadata->remove("DETSER");
309  }
table::Key< std::string > name
Definition: Amplifier.cc:116
int end
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
#define LOGLS_DEBUG(logger, message)
Log a debug-level message using an iostream-based interface.
Definition: Log.h:619
std::shared_ptr< daf::base::PropertyList > metadata
static int getFitsSerializationVersion()
Get the version of FITS serialization that this ExposureInfo understands.
static std::string const & getFitsSerializationVersionName()
Get the version of FITS serialization version info name.
Reports errors from accepting an object of an unexpected or inappropriate type.
Definition: Runtime.h:167
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition: SkyWcs.cc:521
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
Definition: VisitInfo.cc:346
std::shared_ptr< PhotoCalib > makePhotoCalibFromMetadata(daf::base::PropertySet &metadata, bool strip=false)
Construct a PhotoCalib from FITS FLUXMAG0/FLUXMAG0ERR keywords.
Definition: PhotoCalib.cc:595
std::shared_ptr< FilterLabel > makeFilterLabel(Filter const &filter)
Convert an old-style Filter to a FilterLabel.
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

Member Data Documentation

◆ exposureId

std::optional<table::RecordId> lsst::afw::image::ExposureFitsReader::MetadataReader::exposureId

Definition at line 312 of file ExposureFitsReader.cc.

◆ filterLabel

std::shared_ptr<FilterLabel> lsst::afw::image::ExposureFitsReader::MetadataReader::filterLabel

Definition at line 314 of file ExposureFitsReader.cc.

◆ metadata

std::shared_ptr<daf::base::PropertyList> lsst::afw::image::ExposureFitsReader::MetadataReader::metadata

Definition at line 313 of file ExposureFitsReader.cc.

◆ photoCalib

std::shared_ptr<PhotoCalib> lsst::afw::image::ExposureFitsReader::MetadataReader::photoCalib

Definition at line 316 of file ExposureFitsReader.cc.

◆ version

int lsst::afw::image::ExposureFitsReader::MetadataReader::version

Definition at line 311 of file ExposureFitsReader.cc.

◆ visitInfo

std::shared_ptr<VisitInfo> lsst::afw::image::ExposureFitsReader::MetadataReader::visitInfo

Definition at line 317 of file ExposureFitsReader.cc.

◆ wcs

std::shared_ptr<afw::geom::SkyWcs> lsst::afw::image::ExposureFitsReader::MetadataReader::wcs

Definition at line 315 of file ExposureFitsReader.cc.


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