LSST Applications g070148d5b3+33e5256705,g0d53e28543+25c8b88941,g0da5cf3356+2dd1178308,g1081da9e2a+62d12e78cb,g17e5ecfddb+7e422d6136,g1c76d35bf8+ede3a706f7,g295839609d+225697d880,g2e2c1a68ba+cc1f6f037e,g2ffcdf413f+853cd4dcde,g38293774b4+62d12e78cb,g3b44f30a73+d953f1ac34,g48ccf36440+885b902d19,g4b2f1765b6+7dedbde6d2,g5320a0a9f6+0c5d6105b6,g56b687f8c9+ede3a706f7,g5c4744a4d9+ef6ac23297,g5ffd174ac0+0c5d6105b6,g6075d09f38+66af417445,g667d525e37+2ced63db88,g670421136f+2ced63db88,g71f27ac40c+2ced63db88,g774830318a+463cbe8d1f,g7876bc68e5+1d137996f1,g7985c39107+62d12e78cb,g7fdac2220c+0fd8241c05,g96f01af41f+368e6903a7,g9ca82378b8+2ced63db88,g9d27549199+ef6ac23297,gabe93b2c52+e3573e3735,gb065e2a02a+3dfbe639da,gbc3249ced9+0c5d6105b6,gbec6a3398f+0c5d6105b6,gc9534b9d65+35b9f25267,gd01420fc67+0c5d6105b6,geee7ff78d7+a14128c129,gf63283c776+ede3a706f7,gfed783d017+0c5d6105b6,w.2022.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
ExposureFitsReader.cc
Go to the documentation of this file.
1/*
2 * Developed for the LSST Data Management System.
3 * This product includes software developed by the LSST Project
4 * (https://www.lsst.org).
5 * See the COPYRIGHT file at the top-level directory of this distribution
6 * for details of code ownership.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <map>
23#include <optional>
24#include <regex>
25#include <set>
26
27#include "lsst/log/Log.h"
28
37
38namespace lsst {
39namespace afw {
40namespace image {
41
42namespace {
43
44LOG_LOGGER _log = LOG_GET("lsst.afw.image.fits.ExposureFitsReader");
45
46template <typename T, std::size_t N>
47bool _contains(std::array<T, N> const& array, T const& value) {
48 for (T const& element : array) {
49 if (element == value) {
50 return true;
51 }
52 }
53 return false;
54}
55
56// Map from compatibility "afw name" to correct filter label
57std::map<std::string, FilterLabel> const _AFW_NAMES = {
60 std::make_pair("SOLID", FilterLabel::fromPhysical("solid plate 0.0 0.0")),
61};
62
68bool _isBand(std::string const& name) {
69 static std::set<std::string> const BANDS = {"u", "g", "r", "i", "z", "y", "SH", "PH", "VR", "white"};
70 // Standard band
71 if (BANDS.count(name) > 0) {
72 return true;
73 }
74 // Looks like a narrow-band band
75 if (std::regex_match(name, std::regex("N\\d+"))) {
76 return true;
77 }
78 // Looks like an intermediate-band band; exclude "I2"
79 if (std::regex_match(name, std::regex("I\\d{2,}"))) {
80 return true;
81 }
82 return false;
83}
84
85} // namespace
86
96 static std::string const DEFAULT = "_unknown_";
97 // Avoid turning dummy filters into real FilterLabels.
98 if (name == DEFAULT) {
99 return nullptr;
100 }
101
102 // FilterLabel::from* returns a statically allocated object, so only way
103 // to get it into shared_ptr is to copy it.
104 if (_isBand(name)) {
105 return std::make_shared<FilterLabel>(FilterLabel::fromBand(name));
106 } else {
107 return std::make_shared<FilterLabel>(FilterLabel::fromPhysical(name));
108 }
109}
110
118 if (_AFW_NAMES.count(name) > 0) {
119 return std::make_shared<FilterLabel>(_AFW_NAMES.at(name));
120 }
121 // else name is either a band, a physical filter, or a deprecated alias
122
123 // Unknown filter, no extra info to be gained
125}
126
128public:
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 }
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) {
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 }
207
209 std::optional<table::RecordId> exposureId;
215};
216
218public:
220 PSF = 0,
229 };
230
232 auto popInt = [&metadata](std::string const& name) {
233 // The default of zero will cause archive.get to return a
234 // null/empty pointer, just as if a null/empty pointer was
235 // originally written to the archive.
236 int r = 0;
237 if (metadata.exists(name)) {
238 r = metadata.get<int>(name);
239 // We remove metadata entries to maintaing our practice
240 // of stripped metadata entries that have been used to
241 // construct more structured components.
242 metadata.remove(name);
243 }
244 return r;
245 };
246 _hdu = popInt("AR_HDU");
247 if (_hdu == 0) {
248 _state = ArchiveState::MISSING;
249 } else {
250 --_hdu; // Switch from FITS 1-indexed convention to LSST 0-indexed convention.
251 _state = ArchiveState::PRESENT;
252 }
253 // Read in traditional components using old-style IDs, for backwards compatibility
254 _ids[PSF] = popInt("PSF_ID");
255 _ids[WCS] = popInt("SKYWCS_ID");
256 _ids[COADD_INPUTS] = popInt("COADD_INPUTS_ID");
257 _ids[AP_CORR_MAP] = popInt("AP_CORR_MAP_ID");
258 _ids[VALID_POLYGON] = popInt("VALID_POLYGON_ID");
259 _ids[TRANSMISSION_CURVE] = popInt("TRANSMISSION_CURVE_ID");
260 _ids[DETECTOR] = popInt("DETECTOR_ID");
261 _ids[PHOTOCALIB] = popInt("PHOTOCALIB_ID");
262
263 // "Extra" components use a different keyword convention to avoid collisions with non-persistence IDs
265 for (std::string const& headerKey : metadata) {
266 static std::string const PREFIX = "ARCHIVE_ID_";
267 if (headerKey.substr(0, PREFIX.size()) == PREFIX) {
268 std::string componentName = headerKey.substr(PREFIX.size());
269 int archiveId = metadata.get<int>(headerKey);
270 _genericIds.emplace(componentName, archiveId);
271 if (!_contains(_ids, archiveId)) {
272 _extraIds.emplace(componentName);
273 }
274 toStrip.push_back(headerKey);
275 toStrip.push_back(componentName + "_ID"); // strip corresponding old-style ID, if it exists
276 }
277 }
278 for (std::string const& key : toStrip) {
279 metadata.remove(key);
280 }
281 }
282
292 template <typename T>
294 if (!_ensureLoaded(fitsFile)) {
295 return nullptr;
296 }
297 return _archive.get<T>(_ids[c]);
298 }
299
316 // This method takes a string instead of a strongly typed Key because
317 // readExtraComponents() gets its keys from the FITS metadata.
318 // Using a Key would make the calling code more complicated.
319 template <typename T>
321 if (!_ensureLoaded(fitsFile)) {
322 return nullptr;
323 }
324
325 if (_genericIds.count(c) > 0) {
326 int archiveId = _genericIds.at(c);
327 return _archive.get<T>(archiveId);
328 } else {
329 return nullptr;
330 }
331 }
332
343 afw::fits::Fits* fitsFile) {
345
346 if (!_ensureLoaded(fitsFile)) {
347 return result;
348 }
349
350 // Not safe to call getAll if a component cannot be unpersisted
351 // Instead, look for the archives registered in the metadata
352 for (std::string const& componentName : _extraIds) {
353 try {
354 result.emplace(componentName, readComponent<table::io::Persistable>(fitsFile, componentName));
355 } catch (pex::exceptions::NotFoundError const& err) {
356 LOGLS_WARN(_log,
357 "Could not read component " << componentName << "; skipping: " << err.what());
358 }
359 }
360 return result;
361 }
362
363private:
364 bool _ensureLoaded(afw::fits::Fits* fitsFile) {
365 if (_state == ArchiveState::MISSING) {
366 return false;
367 }
368 if (_state == ArchiveState::PRESENT) {
369 afw::fits::HduMoveGuard guard(*fitsFile, _hdu);
370 _archive = table::io::InputArchive::readFits(*fitsFile);
371 _state = ArchiveState::LOADED;
372 }
373 assert(_state == ArchiveState::LOADED); // constructor body should guarantee it's not UNKNOWN
374 return true;
375 }
376
377 enum class ArchiveState { UNKNOWN, MISSING, PRESENT, LOADED };
378
379 int _hdu = 0;
380 ArchiveState _state = ArchiveState::UNKNOWN;
381 table::io::InputArchive _archive;
383 std::map<std::string, int> _genericIds;
384 std::set<std::string> _extraIds; // _genericIds not included in _ids
385};
386
387ExposureFitsReader::ExposureFitsReader(std::string const& fileName) : _maskedImageReader(fileName) {}
388
389ExposureFitsReader::ExposureFitsReader(fits::MemFileManager& manager) : _maskedImageReader(manager) {}
390
391ExposureFitsReader::ExposureFitsReader(fits::Fits* fitsFile) : _maskedImageReader(fitsFile) {}
392
393ExposureFitsReader::~ExposureFitsReader() noexcept = default;
394
396 return _maskedImageReader.readBBox(origin);
397}
398
400 return _maskedImageReader.readXY0(bbox, origin);
401}
402
404 _ensureReaders();
405 return _metadataReader->version;
406}
407
408std::string ExposureFitsReader::readImageDType() const { return _maskedImageReader.readImageDType(); }
409
410std::string ExposureFitsReader::readMaskDType() const { return _maskedImageReader.readMaskDType(); }
411
413
415 _ensureReaders();
416 return _metadataReader->metadata;
417}
418
419std::optional<table::RecordId> ExposureFitsReader::readExposureId() {
420 _ensureReaders();
421 return _metadataReader->exposureId;
422}
423
425 _ensureReaders();
426 auto r = _archiveReader->readComponent<afw::geom::SkyWcs>(_getFitsFile(), ArchiveReader::WCS);
427 if (!r) {
428 r = _metadataReader->wcs;
429 }
430 return r;
431}
432
434 _ensureReaders();
435 if (_metadataReader->version < 2) {
436 return _metadataReader->filterLabel;
437 } else {
438 return _archiveReader->readComponent<FilterLabel>(_getFitsFile(), ExposureInfo::KEY_FILTER.getId());
439 }
440}
441
443 _ensureReaders();
444 if (_metadataReader->version == 0) {
445 return _metadataReader->photoCalib;
446 } else {
447 return _archiveReader->readComponent<image::PhotoCalib>(_getFitsFile(), ArchiveReader::PHOTOCALIB);
448 }
449}
450
452 _ensureReaders();
453 return _archiveReader->readComponent<detection::Psf>(_getFitsFile(), ArchiveReader::PSF);
454}
455
457 _ensureReaders();
458 return _archiveReader->readComponent<afw::geom::polygon::Polygon>(_getFitsFile(),
460}
461
463 _ensureReaders();
464 return _archiveReader->readComponent<ApCorrMap>(_getFitsFile(), ArchiveReader::AP_CORR_MAP);
465}
466
468 _ensureReaders();
469 return _archiveReader->readComponent<CoaddInputs>(_getFitsFile(), ArchiveReader::COADD_INPUTS);
470}
471
473 _ensureReaders();
474 return _metadataReader->visitInfo;
475}
476
478 _ensureReaders();
479 return _archiveReader->readComponent<TransmissionCurve>(_getFitsFile(),
481}
482
484 _ensureReaders();
485 return _archiveReader->readComponent<cameraGeom::Detector>(_getFitsFile(), ArchiveReader::DETECTOR);
486}
487
489 _ensureReaders();
490 return _archiveReader->readComponent<typehandling::Storable>(_getFitsFile(), componentName);
491}
492
494 _ensureReaders();
495 return _archiveReader->readExtraComponents(_getFitsFile());
496}
497
499 auto result = std::make_shared<ExposureInfo>();
500 result->setMetadata(readMetadata());
501 result->setPhotoCalib(readPhotoCalib());
502 result->setVisitInfo(readVisitInfo());
503 // Override ID set in visitInfo, if necessary
504 std::optional<table::RecordId> exposureId = readExposureId();
505 if (exposureId) {
506 result->setId(*exposureId);
507 }
508 // When reading an ExposureInfo (as opposed to reading individual
509 // components), we warn and try to proceed when a component is present
510 // but can't be read due its serialization factory not being set up
511 // (that's what throws the NotFoundErrors caught below).
512 try {
513 result->setPsf(readPsf());
514 } catch (pex::exceptions::NotFoundError& err) {
515 LOGLS_WARN(_log, "Could not read PSF; setting to null: " << err.what());
516 }
517 try {
518 result->setCoaddInputs(readCoaddInputs());
519 } catch (pex::exceptions::NotFoundError& err) {
520 LOGLS_WARN(_log, "Could not read CoaddInputs; setting to null: " << err.what());
521 }
522 try {
523 result->setApCorrMap(readApCorrMap());
524 } catch (pex::exceptions::NotFoundError& err) {
525 LOGLS_WARN(_log, "Could not read ApCorrMap; setting to null: " << err.what());
526 }
527 try {
528 result->setValidPolygon(readValidPolygon());
529 } catch (pex::exceptions::NotFoundError& err) {
530 LOGLS_WARN(_log, "Could not read ValidPolygon; setting to null: " << err.what());
531 }
532 try {
533 result->setTransmissionCurve(readTransmissionCurve());
534 } catch (pex::exceptions::NotFoundError& err) {
535 LOGLS_WARN(_log, "Could not read TransmissionCurve; setting to null: " << err.what());
536 }
537 try {
538 result->setDetector(readDetector());
539 } catch (pex::exceptions::NotFoundError& err) {
540 LOGLS_WARN(_log, "Could not read Detector; setting to null: " << err.what());
541 }
542 // In the case of WCS, we fall back to the metadata WCS if the one from
543 // the archive can't be read.
544 _ensureReaders();
545 result->setWcs(_metadataReader->wcs);
546 try {
547 auto wcs = _archiveReader->readComponent<afw::geom::SkyWcs>(_getFitsFile(), ArchiveReader::WCS);
548 if (!wcs) {
549 LOGLS_DEBUG(_log, "No WCS found in binary table");
550 } else {
551 result->setWcs(wcs);
552 }
553 } catch (pex::exceptions::NotFoundError& err) {
554 auto msg = str(boost::format("Could not read WCS extension; setting to null: %s") % err.what());
555 if (result->hasWcs()) {
556 msg += " ; using WCS from FITS header";
557 }
558 LOGLS_WARN(_log, msg);
559 }
560 for (const auto& keyValue : readExtraComponents()) {
562 std::string key = keyValue.first;
563 StorablePtr object = std::dynamic_pointer_cast<StorablePtr::element_type>(keyValue.second);
564
565 if (object.use_count() > 0) { // Failed cast guarantees empty pointer, but not a null one
566 result->setComponent(typehandling::makeKey<StorablePtr>(key), object);
567 } else {
568 LOGLS_WARN(_log, "Data corruption: generic component " << key << " is not a Storable; skipping.");
569 }
570 }
571 // Convert old-style Filter to new-style FilterLabel
572 // In newer versions this is handled by readExtraComponents()
573 if (_metadataReader->version < 2 && !result->hasFilter()) {
574 result->setFilter(readFilter());
575 }
576 return result;
577} // namespace image
578
579template <typename ImagePixelT>
581 bool allowUnsafe) {
582 return _maskedImageReader.readImage<ImagePixelT>(bbox, origin, allowUnsafe);
583}
584
585template <typename ImagePixelT>
586ndarray::Array<ImagePixelT, 2, 2> ExposureFitsReader::readImageArray(lsst::geom::Box2I const& bbox,
587 ImageOrigin origin, bool allowUnsafe) {
588 return _maskedImageReader.readImageArray<ImagePixelT>(bbox, origin, allowUnsafe);
589}
590
591template <typename MaskPixelT>
593 bool conformMasks, bool allowUnsafe) {
594 return _maskedImageReader.readMask<MaskPixelT>(bbox, origin, conformMasks, allowUnsafe);
595}
596
597template <typename MaskPixelT>
598ndarray::Array<MaskPixelT, 2, 2> ExposureFitsReader::readMaskArray(lsst::geom::Box2I const& bbox,
599 ImageOrigin origin, bool allowUnsafe) {
600 return _maskedImageReader.readMaskArray<MaskPixelT>(bbox, origin, allowUnsafe);
601}
602
603template <typename VariancePixelT>
605 bool allowUnsafe) {
606 return _maskedImageReader.readVariance<VariancePixelT>(bbox, origin, allowUnsafe);
607}
608
609template <typename VariancePixelT>
610ndarray::Array<VariancePixelT, 2, 2> ExposureFitsReader::readVarianceArray(lsst::geom::Box2I const& bbox,
611 ImageOrigin origin,
612 bool allowUnsafe) {
613 return _maskedImageReader.readVarianceArray<VariancePixelT>(bbox, origin, allowUnsafe);
614}
615
616template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
618 lsst::geom::Box2I const& bbox, ImageOrigin origin, bool conformMasks, bool allowUnsafe) {
619 return _maskedImageReader.read<ImagePixelT, MaskPixelT, VariancePixelT>(bbox, origin, conformMasks,
620 /* needAllHdus= */ false,
621 allowUnsafe);
622}
623
624template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
626 ImageOrigin origin,
627 bool conformMasks,
628 bool allowUnsafe) {
629 auto mi =
630 readMaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>(bbox, origin, conformMasks, allowUnsafe);
632}
633
634void ExposureFitsReader::_ensureReaders() {
635 if (!_metadataReader) {
636 auto metadataReader = std::make_unique<MetadataReader>(_maskedImageReader.readPrimaryMetadata(),
637 _maskedImageReader.readImageMetadata(),
638 _maskedImageReader.readXY0());
639 _archiveReader = std::make_unique<ArchiveReader>(*metadataReader->metadata);
640 _metadataReader = std::move(metadataReader); // deferred for exception safety
641 }
642 assert(_archiveReader); // should always be initialized with _metadataReader.
643}
644
645#define INSTANTIATE(ImagePixelT) \
646 template Exposure<ImagePixelT, MaskPixel, VariancePixel> ExposureFitsReader::read( \
647 lsst::geom::Box2I const&, ImageOrigin, bool, bool); \
648 template Image<ImagePixelT> ExposureFitsReader::readImage(lsst::geom::Box2I const&, ImageOrigin, bool); \
649 template ndarray::Array<ImagePixelT, 2, 2> ExposureFitsReader::readImageArray(lsst::geom::Box2I const&, \
650 ImageOrigin, bool); \
651 template MaskedImage<ImagePixelT, MaskPixel, VariancePixel> ExposureFitsReader::readMaskedImage( \
652 lsst::geom::Box2I const&, ImageOrigin, bool, bool)
653
655INSTANTIATE(int);
656INSTANTIATE(float);
657INSTANTIATE(double);
659
660template Mask<MaskPixel> ExposureFitsReader::readMask(lsst::geom::Box2I const&, ImageOrigin, bool, bool);
661template ndarray::Array<MaskPixel, 2, 2> ExposureFitsReader::readMaskArray(lsst::geom::Box2I const&,
662 ImageOrigin, bool);
663
664template Image<VariancePixel> ExposureFitsReader::readVariance(lsst::geom::Box2I const&, ImageOrigin, bool);
665template ndarray::Array<VariancePixel, 2, 2> ExposureFitsReader::readVarianceArray(lsst::geom::Box2I const&,
666 ImageOrigin, bool);
667
668} // namespace image
669} // namespace afw
670} // namespace lsst
py::object result
Definition: _schema.cc:429
table::Key< std::string > name
Definition: Amplifier.cc:116
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
double element[2]
Definition: BaseTable.cc:90
int end
#define INSTANTIATE(FROMSYS, TOSYS)
Definition: Detector.cc:509
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
LSST DM logging module built on log4cxx.
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
Definition: Log.h:659
#define LOG_GET(logger)
Returns a Log object associated with logger.
Definition: Log.h:75
#define LOG_LOGGER
Definition: Log.h:714
#define LOGLS_DEBUG(logger, message)
Log a debug-level message using an iostream-based interface.
Definition: Log.h:619
Implementation of the Photometric Calibration class.
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:66
table::Key< table::RecordId > exposureId
Definition: VisitInfo.cc:201
T at(T... args)
A representation of a detector in a mosaic camera.
Definition: Detector.h:185
A polymorphic base class for representing an image's Point Spread Function.
Definition: Psf.h:76
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:308
RAII scoped guard for moving the HDU in a Fits object.
Definition: fits.h:792
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:125
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:117
Cartesian polygons.
Definition: Polygon.h:59
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
Definition: ApCorrMap.h:45
A simple Persistable struct containing ExposureCatalogs that record the inputs to a coadd.
Definition: CoaddInputs.h:49
std::shared_ptr< T > readComponent(afw::fits::Fits *fitsFile, std::string c)
Read an arbitrary component, if available.
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.
std::shared_ptr< T > readComponent(afw::fits::Fits *fitsFile, Component c)
Read a known component, if available.
std::shared_ptr< daf::base::PropertyList > metadata
MetadataReader(std::shared_ptr< daf::base::PropertyList > primaryMetadata, std::shared_ptr< daf::base::PropertyList > imageMetadata, lsst::geom::Point2I const &xy0)
A FITS reader class for Exposures and their components.
std::shared_ptr< TransmissionCurve > readTransmissionCurve()
Read the Exposure's transmission curve.
std::string readMaskDType() const
Read a string describing the pixel type of the on-disk image 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< typehandling::Storable > readComponent(std::string const &componentName)
Read an arbitrary non-standard component by name.
std::shared_ptr< afw::geom::SkyWcs > readWcs()
Read the Exposure's world coordinate system.
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::map< std::string, std::shared_ptr< table::io::Persistable > > readExtraComponents()
Read the Exposure's non-standard components.
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.
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 readSerializationVersion()
Read the serialization version number from the header.
ExposureFitsReader(std::string const &fileName)
Construct a FITS reader object.
std::shared_ptr< detection::Psf > readPsf()
Read the Exposure's point-spread function.
std::shared_ptr< afw::geom::polygon::Polygon > readValidPolygon()
Read the polygon describing the region of validity for the Exposure.
Image< ImagePixelT > readImage(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
std::string readVarianceDType() const
Read a string describing the pixel type of the on-disk image plane.
std::shared_ptr< FilterLabel > readFilter()
Read the Exposure's filter information.
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::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< daf::base::PropertyList > readMetadata()
Read the flexible metadata associated with the Exposure.
std::shared_ptr< PhotoCalib > readPhotoCalib()
Read the Exposure's photometric calibration.
std::optional< table::RecordId > readExposureId()
Read the Exposure's exposure ID, if it exists.
std::shared_ptr< ApCorrMap > readApCorrMap()
Read the Exposure's aperture correction map.
ndarray::Array< MaskPixelT, 2, 2 > readMaskArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the mask plane.
std::string readImageDType() 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.
std::shared_ptr< cameraGeom::Detector > readDetector()
Read the Exposure's detector.
std::shared_ptr< ExposureInfo > readExposureInfo()
Read the ExposureInfo containing all non-image components.
std::shared_ptr< VisitInfo > readVisitInfo()
Read the Exposure's visit metadata.
Mask< MaskPixelT > readMask(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, 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.
Definition: Exposure.h:72
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.
static typehandling::Key< std::string, std::shared_ptr< FilterLabel const > > const KEY_FILTER
Standard key for looking up filter information.
Definition: ExposureInfo.h:109
A group of labels for a filter in an exposure or coadd.
Definition: FilterLabel.h:58
static FilterLabel fromBand(std::string const &band)
Construct a FilterLabel from specific inputs.
Definition: FilterLabel.cc:72
static FilterLabel fromBandPhysical(std::string const &band, std::string const &physical)
Construct a FilterLabel from specific inputs.
Definition: FilterLabel.cc:68
static FilterLabel fromPhysical(std::string const &physical)
Construct a FilterLabel from specific inputs.
Definition: FilterLabel.cc:74
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:51
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
std::string readMaskDType() const
Read a string describing the pixel type of the on-disk image plane.
std::shared_ptr< daf::base::PropertyList > readImageMetadata()
Read the FITS header of one of the HDUs.
std::shared_ptr< daf::base::PropertyList > readPrimaryMetadata()
Read the FITS header of one of the HDUs.
std::string readVarianceDType() const
Read a string describing the pixel type of the on-disk image plane.
ndarray::Array< MaskPixelT, 2, 2 > readMaskArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the mask plane.
std::string readImageDType() 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.
ndarray::Array< VariancePixelT, 2, 2 > readVarianceArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
Mask< MaskPixelT > readMask(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool allowUnsafe=false)
Read the mask 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.
Image< ImagePixelT > readImage(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
Image< VariancePixelT > readVariance(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
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 class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:74
The photometric calibration of an exposure.
Definition: PhotoCalib.h:114
A spatially-varying transmission curve as a function of wavelength.
static InputArchive readFits(fits::Fits &fitsfile)
Read an object from an already open FITS object.
std::shared_ptr< Persistable > get(int id) const
Load the Persistable with the given ID and return it.
Interface supporting iteration over heterogenous containers.
Definition: Storable.h:58
Class for storing ordered metadata with comments.
Definition: PropertyList.h:68
T get(std::string const &name) const
Get the last value for a property name (possibly hierarchical).
Definition: PropertyList.cc:62
virtual void remove(std::string const &name)
Remove all values for a property name (possibly hierarchical).
bool exists(std::string const &name) const
Determine if a name (possibly hierarchical) exists.
An integer coordinate rectangle.
Definition: Box.h:55
CoordinateExpr< N > ne(Point< T, N > const &other) const noexcept
Definition: Point.cc:83
virtual char const * what(void) const noexcept
Return a character string summarizing this exception.
Definition: Exception.cc:99
Reports attempts to access elements using an invalid key.
Definition: Runtime.h:151
Reports errors from accepting an object of an unexpected or inappropriate type.
Definition: Runtime.h:167
T count(T... args)
T emplace(T... args)
T make_pair(T... args)
T move(T... args)
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
Definition: VisitInfo.cc:378
std::shared_ptr< PhotoCalib > makePhotoCalibFromMetadata(daf::base::PropertySet &metadata, bool strip=false)
Construct a PhotoCalib from FITS FLUXMAG0/FLUXMAG0ERR keywords.
Definition: PhotoCalib.cc:596
std::shared_ptr< FilterLabel > makeFilterLabel(std::string const &name)
Convert an old-style single Filter name to a FilterLabel, using available information.
std::shared_ptr< FilterLabel > makeFilterLabelDirect(std::string const &name)
Convert an old-style filter name to a FilterLabel without external information.
T push_back(T... args)
T regex_match(T... args)
T size(T... args)
T substr(T... args)