LSST Applications 24.1.5,g02d81e74bb+fa3a7a026e,g180d380827+a53a32eff8,g2079a07aa2+86d27d4dc4,g2305ad1205+c0501b3732,g295015adf3+7d3e92f0ec,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+5dd1654d75,g48712c4677+3bf1020dcb,g487adcacf7+065c13d9cf,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+d7ac436cfb,g5a732f18d5+53520f316c,g64a986408d+fa3a7a026e,g858d7b2824+fa3a7a026e,g8a8a8dda67+585e252eca,g99cad8db69+a5a909b84f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+4cf350ccb2,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+f991a0b59f,gc120e1dc64+9ccbfdb8be,gc28159a63d+0e5473021a,gcf0d15dbbd+5dd1654d75,gd96a1ce819+42fd0ee607,gdaeeff99f8+f9a426f77a,ge6526c86ff+0d71447b4b,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+fa3a7a026e
LSST Data Management Base Package
Loading...
Searching...
No Matches
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 127 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 129 of file ExposureFitsReader.cc.

130 {
132 if (primaryMetadata->exists(versionName)) {
133 version = primaryMetadata->getAsInt(versionName);
134 primaryMetadata->remove(versionName);
135 } else {
136 version = 0; // unversioned files are implicitly version 0
137 }
139 throw LSST_EXCEPT(pex::exceptions::TypeError,
140 str(boost::format("Cannot read Exposure FITS version > %i") %
142 }
143
144 // Try to read WCS from image metadata, and if found, strip the keywords used
145 try {
146 wcs = afw::geom::makeSkyWcs(*imageMetadata, true);
147 } catch (lsst::pex::exceptions::TypeError const&) {
148 LOGLS_DEBUG(_log, "No WCS found in FITS metadata");
149 }
150 if (wcs && any(xy0.ne(lsst::geom::Point2I(0, 0)))) {
151 wcs = wcs->copyAtShiftedPixelOrigin(lsst::geom::Extent2D(xy0));
152 }
153
154 // Strip LTV1, LTV2 from imageMetadata, because we don't use it internally
155 imageMetadata->remove("LTV1");
156 imageMetadata->remove("LTV2");
157
158 if (!imageMetadata->exists("INHERIT")) {
159 // New-style exposures put everything but the Wcs in the primary HDU, use
160 // INHERIT keyword in the others. For backwards compatibility, if we don't
161 // find the INHERIT keyword, we ignore the primary HDU metadata and expect
162 // everything to be in the image HDU metadata. Note that we can't merge them,
163 // because they're probably duplicates.
164 metadata = imageMetadata;
165 } else {
166 metadata = primaryMetadata;
167 }
168
169 // Earlier versions persisted Filter as header keyword, version 2 persists FilterLabel as a Storable
170 if (version < 2) {
171 std::string key = "FILTER";
172 if (metadata->exists(key)) {
173 // Original Filter code depended on Boost for string trimming.
174 // DIY to avoid making this module depend on Boost.
175 std::string name = metadata->getAsString(key);
176 size_t end = name.find_last_not_of(' ');
177 filterLabel = makeFilterLabel(name.substr(0, end + 1));
178 }
179 }
180
181 // EXPID keyword used in all versions, but was VisitInfo's responsibility before VisitInfo v3.
182 if (metadata->exists("EXPID")) {
183 exposureId = metadata->getAsInt64("EXPID");
184 }
185
186 visitInfo = std::make_shared<VisitInfo>(*metadata);
188
189 // This keyword is no longer handled by VisitInfo version >= 3.
190 metadata->remove("EXPID");
191
192 // Version 0 persisted Calib FLUXMAG0 in the metadata, >=1 persisted PhotoCalib as a binary table.
193 if (version == 0) {
194 photoCalib = makePhotoCalibFromMetadata(*metadata, true);
195 }
196
197 // Strip MJD-OBS and DATE-OBS from metadata; those may be read by
198 // either SkyWcs or VisitInfo or both, so neither can strip them.
199 metadata->remove("MJD-OBS");
200 metadata->remove("DATE-OBS");
201
202 // Strip DETSER, DETNAME; these are added when writing an Exposure
203 // with a Detector
204 metadata->remove("DETNAME");
205 metadata->remove("DETSER");
206 }
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
T find_last_not_of(T... args)
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:389
std::shared_ptr< PhotoCalib > makePhotoCalibFromMetadata(daf::base::PropertySet &metadata, bool strip=false)
Construct a PhotoCalib from FITS FLUXMAG0/FLUXMAG0ERR keywords.
std::shared_ptr< FilterLabel > makeFilterLabel(std::string const &name)
Convert an old-style single Filter name to a FilterLabel, using available information.
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.

Member Data Documentation

◆ exposureId

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

Definition at line 209 of file ExposureFitsReader.cc.

◆ filterLabel

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

Definition at line 211 of file ExposureFitsReader.cc.

◆ metadata

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

Definition at line 210 of file ExposureFitsReader.cc.

◆ photoCalib

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

Definition at line 213 of file ExposureFitsReader.cc.

◆ version

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

Definition at line 208 of file ExposureFitsReader.cc.

◆ visitInfo

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

Definition at line 214 of file ExposureFitsReader.cc.

◆ wcs

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

Definition at line 212 of file ExposureFitsReader.cc.


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