LSSTApplications  20.0.0
LSSTDataManagementBasePackage
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 "lsst/log/Log.h"
23 
26 #include "lsst/afw/geom/SkyWcs.h"
29 #include "lsst/afw/detection/Psf.h"
32 
33 namespace lsst {
34 namespace afw {
35 namespace image {
36 
37 namespace {
38 
39 LOG_LOGGER _log = LOG_GET("afw.image.fits.ExposureFitsReader");
40 
41 template <typename T, std::size_t N>
42 bool _contains(std::array<T, N> const& array, T const& value) {
43  for (T const& element : array) {
44  if (element == value) {
45  return true;
46  }
47  }
48  return false;
49 }
50 
51 } // namespace
52 
54 public:
58  if (primaryMetadata->exists(versionName)) {
59  version = primaryMetadata->getAsInt(versionName);
60  primaryMetadata->remove(versionName);
61  } else {
62  version = 0; // unversioned files are implicitly version 0
63  }
66  str(boost::format("Cannot read Exposure FITS version >= %i") %
68  }
69 
70  // Try to read WCS from image metadata, and if found, strip the keywords used
71  try {
72  wcs = afw::geom::makeSkyWcs(*imageMetadata, true);
73  } catch (lsst::pex::exceptions::TypeError const&) {
74  LOGLS_DEBUG(_log, "No WCS found in FITS metadata");
75  }
76  if (wcs && any(xy0.ne(lsst::geom::Point2I(0, 0)))) {
77  wcs = wcs->copyAtShiftedPixelOrigin(lsst::geom::Extent2D(xy0));
78  }
79 
80  // Strip LTV1, LTV2 from imageMetadata, because we don't use it internally
81  imageMetadata->remove("LTV1");
82  imageMetadata->remove("LTV2");
83 
84  if (!imageMetadata->exists("INHERIT")) {
85  // New-style exposures put everything but the Wcs in the primary HDU, use
86  // INHERIT keyword in the others. For backwards compatibility, if we don't
87  // find the INHERIT keyword, we ignore the primary HDU metadata and expect
88  // everything to be in the image HDU metadata. Note that we can't merge them,
89  // because they're probably duplicates.
90  metadata = imageMetadata;
91  } else {
92  metadata = primaryMetadata;
93  }
94 
95  filter = Filter(metadata, true);
97 
98  visitInfo = std::make_shared<VisitInfo>(*metadata);
100 
101  // Version 0 persisted Calib FLUXMAG0 in the metadata, >=1 persisted PhotoCalib as a binary table.
102  if (version == 0) {
104  }
105 
106  // Strip MJD-OBS and DATE-OBS from metadata; those may be read by
107  // either SkyWcs or VisitInfo or both, so neither can strip them.
108  metadata->remove("MJD-OBS");
109  metadata->remove("DATE-OBS");
110 
111  // Strip DETSER, DETNAME; these are added when writing an Exposure
112  // with a Detector
113  metadata->remove("DETNAME");
114  metadata->remove("DETSER");
115  }
116 
117  int version;
123 };
124 
126 public:
127  enum Component {
128  PSF = 0,
137  };
138 
140  auto popInt = [&metadata](std::string const& name) {
141  // The default of zero will cause archive.get to return a
142  // null/empty pointer, just as if a null/empty pointer was
143  // originally written to the archive.
144  int r = 0;
145  if (metadata.exists(name)) {
146  r = metadata.get<int>(name);
147  // We remove metadata entries to maintaing our practice
148  // of stripped metadata entries that have been used to
149  // construct more structured components.
150  metadata.remove(name);
151  }
152  return r;
153  };
154  _hdu = popInt("AR_HDU");
155  if (_hdu == 0) {
156  _state = ArchiveState::MISSING;
157  } else {
158  --_hdu; // Switch from FITS 1-indexed convention to LSST 0-indexed convention.
159  _state = ArchiveState::PRESENT;
160  }
161  // Read in traditional components using old-style IDs, for backwards compatibility
162  _ids[PSF] = popInt("PSF_ID");
163  _ids[WCS] = popInt("SKYWCS_ID");
164  _ids[COADD_INPUTS] = popInt("COADD_INPUTS_ID");
165  _ids[AP_CORR_MAP] = popInt("AP_CORR_MAP_ID");
166  _ids[VALID_POLYGON] = popInt("VALID_POLYGON_ID");
167  _ids[TRANSMISSION_CURVE] = popInt("TRANSMISSION_CURVE_ID");
168  _ids[DETECTOR] = popInt("DETECTOR_ID");
169  _ids[PHOTOCALIB] = popInt("PHOTOCALIB_ID");
170 
171  // "Extra" components use a different keyword convention to avoid collisions with non-persistence IDs
172  std::vector<std::string> toStrip;
173  for (std::string const& headerKey : metadata) {
174  static std::string const PREFIX = "ARCHIVE_ID_";
175  if (headerKey.substr(0, PREFIX.size()) == PREFIX) {
176  std::string componentName = headerKey.substr(PREFIX.size());
177  int archiveId = metadata.get<int>(headerKey);
178  if (!_contains(_ids, archiveId)) {
179  _extraIds.emplace(componentName, archiveId);
180  }
181  toStrip.push_back(headerKey);
182  toStrip.push_back(componentName + "_ID"); // strip corresponding old-style ID, if it exists
183  }
184  }
185  for (std::string const& key : toStrip) {
186  metadata.remove(key);
187  }
188  }
189 
199  template <typename T>
201  if (!_ensureLoaded(fitsFile)) {
202  return nullptr;
203  }
204  return _archive.get<T>(_ids[c]);
205  }
206 
217  afw::fits::Fits* fitsFile) {
219 
220  if (!_ensureLoaded(fitsFile)) {
221  return result;
222  }
223 
224  // Not safe to call getAll if a component cannot be unpersisted
225  // Instead, look for the archives registered in the metadata
226  for (auto const& keyValue : _extraIds) {
227  std::string componentName = keyValue.first;
228  int archiveId = keyValue.second;
229 
230  try {
231  result.emplace(componentName, _archive.get(archiveId));
232  } catch (pex::exceptions::NotFoundError const& err) {
233  LOGLS_WARN(_log,
234  "Could not read component " << componentName << "; skipping: " << err.what());
235  }
236  }
237  return result;
238  }
239 
240 private:
241  bool _ensureLoaded(afw::fits::Fits* fitsFile) {
242  if (_state == ArchiveState::MISSING) {
243  return false;
244  }
245  if (_state == ArchiveState::PRESENT) {
246  afw::fits::HduMoveGuard guard(*fitsFile, _hdu);
247  _archive = table::io::InputArchive::readFits(*fitsFile);
248  _state = ArchiveState::LOADED;
249  }
250  assert(_state == ArchiveState::LOADED); // constructor body should guarantee it's not UNKNOWN
251  return true;
252  }
253 
254  enum class ArchiveState { UNKNOWN, MISSING, PRESENT, LOADED };
255 
256  int _hdu = 0;
257  ArchiveState _state = ArchiveState::UNKNOWN;
258  table::io::InputArchive _archive;
260  std::map<std::string, int> _extraIds;
261 };
262 
263 ExposureFitsReader::ExposureFitsReader(std::string const& fileName) : _maskedImageReader(fileName) {}
264 
265 ExposureFitsReader::ExposureFitsReader(fits::MemFileManager& manager) : _maskedImageReader(manager) {}
266 
267 ExposureFitsReader::ExposureFitsReader(fits::Fits* fitsFile) : _maskedImageReader(fitsFile) {}
268 
269 ExposureFitsReader::~ExposureFitsReader() noexcept = default;
270 
272  return _maskedImageReader.readBBox(origin);
273 }
274 
276  return _maskedImageReader.readXY0(bbox, origin);
277 }
278 
279 std::string ExposureFitsReader::readImageDType() const { return _maskedImageReader.readImageDType(); }
280 
281 std::string ExposureFitsReader::readMaskDType() const { return _maskedImageReader.readMaskDType(); }
282 
284 
286  _ensureReaders();
287  return _metadataReader->metadata;
288 }
289 
291  _ensureReaders();
292  auto r = _archiveReader->readComponent<afw::geom::SkyWcs>(_getFitsFile(), ArchiveReader::WCS);
293  if (!r) {
294  r = _metadataReader->wcs;
295  }
296  return r;
297 }
298 
300  _ensureReaders();
301  return _metadataReader->filter;
302 }
303 
305  _ensureReaders();
306  if (_metadataReader->version == 0) {
307  return _metadataReader->photoCalib;
308  } else {
309  return _archiveReader->readComponent<image::PhotoCalib>(_getFitsFile(), ArchiveReader::PHOTOCALIB);
310  }
311 }
312 
314  _ensureReaders();
315  return _archiveReader->readComponent<detection::Psf>(_getFitsFile(), ArchiveReader::PSF);
316 }
317 
319  _ensureReaders();
320  return _archiveReader->readComponent<afw::geom::polygon::Polygon>(_getFitsFile(),
322 }
323 
325  _ensureReaders();
326  return _archiveReader->readComponent<ApCorrMap>(_getFitsFile(), ArchiveReader::AP_CORR_MAP);
327 }
328 
330  _ensureReaders();
331  return _archiveReader->readComponent<CoaddInputs>(_getFitsFile(), ArchiveReader::COADD_INPUTS);
332 }
333 
335  _ensureReaders();
336  return _metadataReader->visitInfo;
337 }
338 
340  _ensureReaders();
341  return _archiveReader->readComponent<TransmissionCurve>(_getFitsFile(),
343 }
344 
346  _ensureReaders();
347  return _archiveReader->readComponent<cameraGeom::Detector>(_getFitsFile(), ArchiveReader::DETECTOR);
348 }
349 
351  _ensureReaders();
352  return _archiveReader->readExtraComponents(_getFitsFile());
353 }
354 
356  auto result = std::make_shared<ExposureInfo>();
357  result->setMetadata(readMetadata());
358  result->setFilter(readFilter());
359  result->setPhotoCalib(readPhotoCalib());
360  result->setVisitInfo(readVisitInfo());
361  // When reading an ExposureInfo (as opposed to reading individual
362  // components), we warn and try to proceed when a component is present
363  // but can't be read due its serialization factory not being set up
364  // (that's what throws the NotFoundErrors caught below).
365  try {
366  result->setPsf(readPsf());
367  } catch (pex::exceptions::NotFoundError& err) {
368  LOGLS_WARN(_log, "Could not read PSF; setting to null: " << err.what());
369  }
370  try {
371  result->setCoaddInputs(readCoaddInputs());
372  } catch (pex::exceptions::NotFoundError& err) {
373  LOGLS_WARN(_log, "Could not read CoaddInputs; setting to null: " << err.what());
374  }
375  try {
376  result->setApCorrMap(readApCorrMap());
377  } catch (pex::exceptions::NotFoundError& err) {
378  LOGLS_WARN(_log, "Could not read ApCorrMap; setting to null: " << err.what());
379  }
380  try {
381  result->setValidPolygon(readValidPolygon());
382  } catch (pex::exceptions::NotFoundError& err) {
383  LOGLS_WARN(_log, "Could not read ValidPolygon; setting to null: " << err.what());
384  }
385  try {
386  result->setTransmissionCurve(readTransmissionCurve());
387  } catch (pex::exceptions::NotFoundError& err) {
388  LOGLS_WARN(_log, "Could not read TransmissionCurve; setting to null: " << err.what());
389  }
390  try {
391  result->setDetector(readDetector());
392  } catch (pex::exceptions::NotFoundError& err) {
393  LOGLS_WARN(_log, "Could not read Detector; setting to null: " << err.what());
394  }
395  // In the case of WCS, we fall back to the metadata WCS if the one from
396  // the archive can't be read.
397  _ensureReaders();
398  result->setWcs(_metadataReader->wcs);
399  try {
400  auto wcs = _archiveReader->readComponent<afw::geom::SkyWcs>(_getFitsFile(), ArchiveReader::WCS);
401  if (!wcs) {
402  LOGLS_DEBUG(_log, "No WCS found in binary table");
403  } else {
404  result->setWcs(wcs);
405  }
406  } catch (pex::exceptions::NotFoundError& err) {
407  auto msg = str(boost::format("Could not read WCS extension; setting to null: %s") % err.what());
408  if (result->hasWcs()) {
409  msg += " ; using WCS from FITS header";
410  }
411  LOGLS_WARN(_log, msg);
412  }
413  for (auto keyValue : readExtraComponents()) {
415  std::string key = keyValue.first;
416  StorablePtr object = std::dynamic_pointer_cast<StorablePtr::element_type>(keyValue.second);
417 
418  if (object.use_count() > 0) { // Failed cast guarantees empty pointer, but not a null one
419  result->setComponent(typehandling::makeKey<StorablePtr>(key), object);
420  } else {
421  LOGLS_WARN(_log, "Data corruption: generic component " << key << " is not a Storable; skipping.");
422  }
423  }
424  return result;
425 } // namespace image
426 
427 template <typename ImagePixelT>
429  bool allowUnsafe) {
430  return _maskedImageReader.readImage<ImagePixelT>(bbox, origin, allowUnsafe);
431 }
432 
433 template <typename ImagePixelT>
434 ndarray::Array<ImagePixelT, 2, 2> ExposureFitsReader::readImageArray(lsst::geom::Box2I const& bbox,
435  ImageOrigin origin, bool allowUnsafe) {
436  return _maskedImageReader.readImageArray<ImagePixelT>(bbox, origin, allowUnsafe);
437 }
438 
439 template <typename MaskPixelT>
441  bool conformMasks, bool allowUnsafe) {
442  return _maskedImageReader.readMask<MaskPixelT>(bbox, origin, conformMasks, allowUnsafe);
443 }
444 
445 template <typename MaskPixelT>
446 ndarray::Array<MaskPixelT, 2, 2> ExposureFitsReader::readMaskArray(lsst::geom::Box2I const& bbox,
447  ImageOrigin origin, bool allowUnsafe) {
448  return _maskedImageReader.readMaskArray<MaskPixelT>(bbox, origin, allowUnsafe);
449 }
450 
451 template <typename VariancePixelT>
453  bool allowUnsafe) {
454  return _maskedImageReader.readVariance<VariancePixelT>(bbox, origin, allowUnsafe);
455 }
456 
457 template <typename VariancePixelT>
458 ndarray::Array<VariancePixelT, 2, 2> ExposureFitsReader::readVarianceArray(lsst::geom::Box2I const& bbox,
459  ImageOrigin origin,
460  bool allowUnsafe) {
461  return _maskedImageReader.readVarianceArray<VariancePixelT>(bbox, origin, allowUnsafe);
462 }
463 
464 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
466  lsst::geom::Box2I const& bbox, ImageOrigin origin, bool conformMasks, bool allowUnsafe) {
467  return _maskedImageReader.read<ImagePixelT, MaskPixelT, VariancePixelT>(bbox, origin, conformMasks,
468  /* needAllHdus= */ false,
469  allowUnsafe);
470 }
471 
472 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
474  ImageOrigin origin,
475  bool conformMasks,
476  bool allowUnsafe) {
477  auto mi =
478  readMaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>(bbox, origin, conformMasks, allowUnsafe);
480 }
481 
482 void ExposureFitsReader::_ensureReaders() {
483  if (!_metadataReader) {
484  auto metadataReader = std::make_unique<MetadataReader>(_maskedImageReader.readPrimaryMetadata(),
485  _maskedImageReader.readImageMetadata(),
486  _maskedImageReader.readXY0());
487  _archiveReader = std::make_unique<ArchiveReader>(*metadataReader->metadata);
488  _metadataReader = std::move(metadataReader); // deferred for exception safety
489  }
490  assert(_archiveReader); // should always be initialized with _metadataReader.
491 }
492 
493 #define INSTANTIATE(ImagePixelT) \
494  template Exposure<ImagePixelT, MaskPixel, VariancePixel> ExposureFitsReader::read( \
495  lsst::geom::Box2I const&, ImageOrigin, bool, bool); \
496  template Image<ImagePixelT> ExposureFitsReader::readImage(lsst::geom::Box2I const&, ImageOrigin, bool); \
497  template ndarray::Array<ImagePixelT, 2, 2> ExposureFitsReader::readImageArray(lsst::geom::Box2I const&, \
498  ImageOrigin, bool); \
499  template MaskedImage<ImagePixelT, MaskPixel, VariancePixel> ExposureFitsReader::readMaskedImage( \
500  lsst::geom::Box2I const&, ImageOrigin, bool, bool)
501 
503 INSTANTIATE(int);
504 INSTANTIATE(float);
505 INSTANTIATE(double);
507 
508 template Mask<MaskPixel> ExposureFitsReader::readMask(lsst::geom::Box2I const&, ImageOrigin, bool, bool);
509 template ndarray::Array<MaskPixel, 2, 2> ExposureFitsReader::readMaskArray(lsst::geom::Box2I const&,
510  ImageOrigin, bool);
511 
512 template Image<VariancePixel> ExposureFitsReader::readVariance(lsst::geom::Box2I const&, ImageOrigin, bool);
513 template ndarray::Array<VariancePixel, 2, 2> ExposureFitsReader::readVarianceArray(lsst::geom::Box2I const&,
514  ImageOrigin, bool);
515 
516 } // namespace image
517 } // namespace afw
518 } // namespace lsst
lsst::afw::image::MaskedImageFitsReader::readImage
Image< ImagePixelT > readImage(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
Definition: MaskedImageFitsReader.cc:131
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
LOG_LOGGER
#define LOG_LOGGER
Definition: Log.h:703
lsst::afw::image::ExposureFitsReader::readMaskedImage
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.
Definition: ExposureFitsReader.cc:465
lsst::afw::image::MaskedImageFitsReader::readPrimaryMetadata
std::shared_ptr< daf::base::PropertyList > readPrimaryMetadata()
Read the FITS header of one of the HDUs.
Definition: MaskedImageFitsReader.cc:100
std::string
STL class.
std::shared_ptr
STL class.
lsst::afw::image::MaskedImageFitsReader::readVarianceArray
ndarray::Array< VariancePixelT, 2, 2 > readVarianceArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
Definition: MaskedImageFitsReader.cc:163
lsst::afw::image::detail::stripFilterKeywords
int stripFilterKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Filter-related keywords from the metadata.
Definition: Filter.cc:132
lsst::afw::image::ExposureFitsReader::ExposureFitsReader
ExposureFitsReader(std::string const &fileName)
Construct a FITS reader object.
Definition: ExposureFitsReader.cc:263
lsst::afw::image::Mask
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
Psf.h
lsst::afw::image::makePhotoCalibFromMetadata
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::move
T move(T... args)
lsst::afw::image::MaskedImageFitsReader::readMaskArray
ndarray::Array< MaskPixelT, 2, 2 > readMaskArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the mask plane.
Definition: MaskedImageFitsReader.cc:150
TransmissionCurve.h
lsst::afw::image::Exposure
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition: Exposure.h:72
lsst::afw::image::ExposureFitsReader::readFilter
Filter readFilter()
Read the Exposure's filter.
Definition: ExposureFitsReader.cc:299
lsst::afw::image::ExposureFitsReader::readVariance
Image< VariancePixelT > readVariance(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
Definition: ExposureFitsReader.cc:452
wcs
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
lsst::afw::image::ExposureFitsReader::ArchiveReader::PHOTOCALIB
@ PHOTOCALIB
Definition: ExposureFitsReader.cc:135
lsst::afw::fits::Fits
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
std::vector< std::string >
std::string::size
T size(T... args)
lsst::pex::exceptions::NotFoundError
Reports attempts to access elements using an invalid key.
Definition: Runtime.h:151
lsst::afw::image::Filter
Holds an integer identifier for an LSST filter.
Definition: Filter.h:141
lsst::afw::image::ExposureFitsReader::MetadataReader::wcs
std::shared_ptr< afw::geom::SkyWcs > wcs
Definition: ExposureFitsReader.cc:120
lsst::afw::image::ExposureFitsReader::readMaskArray
ndarray::Array< MaskPixelT, 2, 2 > readMaskArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the mask plane.
Definition: ExposureFitsReader.cc:446
lsst::afw::fits::HduMoveGuard
RAII scoped guard for moving the HDU in a Fits object.
Definition: fits.h:724
pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
lsst::afw::image::ExposureFitsReader::readBBox
lsst::geom::Box2I readBBox(ImageOrigin origin=PARENT)
Read the bounding box of the on-disk image.
Definition: ExposureFitsReader.cc:271
lsst::afw::image::ExposureFitsReader::ArchiveReader::ArchiveReader
ArchiveReader(daf::base::PropertyList &metadata)
Definition: ExposureFitsReader.cc:139
lsst::afw
Definition: imageAlgorithm.dox:1
std::map::emplace
T emplace(T... args)
lsst::afw::image::ExposureFitsReader::ArchiveReader::readExtraComponents
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.
Definition: ExposureFitsReader.cc:216
LOG_GET
#define LOG_GET(logger)
Definition: Log.h:75
version
Definition: version.py:1
lsst::daf::base::PropertyList
Class for storing ordered metadata with comments.
Definition: PropertyList.h:68
lsst::daf::base::PropertySet::exists
bool exists(std::string const &name) const
Determine if a name (possibly hierarchical) exists.
SkyWcs.h
lsst::afw::image::ExposureFitsReader::readExtraComponents
std::map< std::string, std::shared_ptr< table::io::Persistable > > readExtraComponents()
Read the Exposure's non-standard components.
Definition: ExposureFitsReader.cc:350
lsst::afw::geom::SkyWcs
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:117
lsst::afw::image::MaskedImageFitsReader::readImageDType
std::string readImageDType() const
Read a string describing the pixel type of the on-disk image plane.
Definition: MaskedImageFitsReader.cc:66
lsst::afw::fits::MemFileManager
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:121
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
lsst::afw::image::ExposureFitsReader::readDetector
std::shared_ptr< cameraGeom::Detector > readDetector()
Read the Exposure's detector.
Definition: ExposureFitsReader.cc:345
lsst::afw::image::MaskedImageFitsReader::readVarianceDType
std::string readVarianceDType() const
Read a string describing the pixel type of the on-disk image plane.
Definition: MaskedImageFitsReader.cc:70
lsst::afw::image::ExposureInfo::getFitsSerializationVersion
static int getFitsSerializationVersion()
Get the version of FITS serialization that this ExposureInfo understands.
Definition: ExposureInfo.cc:131
lsst::daf::base::PropertyList::get
T get(std::string const &name) const
Get the last value for a property name (possibly hierarchical).
Definition: PropertyList.cc:61
lsst::afw::image::ExposureFitsReader::readVarianceDType
std::string readVarianceDType() const
Read a string describing the pixel type of the on-disk image plane.
Definition: ExposureFitsReader.cc:283
std::vector::push_back
T push_back(T... args)
lsst::afw::image::ExposureFitsReader::readExposureInfo
std::shared_ptr< ExposureInfo > readExposureInfo()
Read the ExposureInfo containing all non-image components.
Definition: ExposureFitsReader.cc:355
LOGLS_WARN
#define LOGLS_WARN(logger, message)
Definition: Log.h:648
lsst::afw::image::ExposureFitsReader::MetadataReader::version
int version
Definition: ExposureFitsReader.cc:117
lsst::afw::image::MaskedImageFitsReader::readVariance
Image< VariancePixelT > readVariance(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
Definition: MaskedImageFitsReader.cc:157
lsst::afw::image::MaskedImage
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
lsst::afw::image::ExposureFitsReader::readMetadata
std::shared_ptr< daf::base::PropertyList > readMetadata()
Read the flexible metadata associated with the Exposure.
Definition: ExposureFitsReader.cc:285
lsst::afw::geom::polygon::Polygon
Cartesian polygons.
Definition: Polygon.h:59
lsst::afw::image::ExposureFitsReader::readWcs
std::shared_ptr< afw::geom::SkyWcs > readWcs()
Read the Exposure's world coordinate system.
Definition: ExposureFitsReader.cc:290
lsst::afw::image::ExposureFitsReader::readCoaddInputs
std::shared_ptr< CoaddInputs > readCoaddInputs()
Read the Exposure's coadd input catalogs.
Definition: ExposureFitsReader.cc:329
lsst::afw::image::ExposureFitsReader::readImage
Image< ImagePixelT > readImage(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
Definition: ExposureFitsReader.cc:428
lsst::afw::image::ExposureFitsReader::readMaskDType
std::string readMaskDType() const
Read a string describing the pixel type of the on-disk image plane.
Definition: ExposureFitsReader.cc:281
lsst::afw::image::ExposureFitsReader::MetadataReader::photoCalib
std::shared_ptr< PhotoCalib > photoCalib
Definition: ExposureFitsReader.cc:121
std::array
STL class.
lsst::geom::any
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
Definition: CoordinateExpr.h:89
lsst::afw::image::ExposureInfo::getFitsSerializationVersionName
static std::string const & getFitsSerializationVersionName()
Get the version of FITS serialization version info name.
Definition: ExposureInfo.cc:139
lsst::afw::image::ExposureFitsReader::MetadataReader::visitInfo
std::shared_ptr< VisitInfo > visitInfo
Definition: ExposureFitsReader.cc:122
lsst::afw::image::ExposureFitsReader::readMask
Mask< MaskPixelT > readMask(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool allowUnsafe=false)
Read the mask plane.
Definition: ExposureFitsReader.cc:440
lsst::afw::image::PhotoCalib
The photometric calibration of an exposure.
Definition: PhotoCalib.h:114
std::uint16_t
lsst::afw::image::MaskedImageFitsReader::readXY0
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.
Definition: MaskedImageFitsReader.cc:76
std::map
STL class.
lsst::afw::image::ExposureFitsReader::ArchiveReader::readComponent
std::shared_ptr< T > readComponent(afw::fits::Fits *fitsFile, Component c)
Read a known component, if available.
Definition: ExposureFitsReader.cc:200
lsst::afw::image::MaskedImageFitsReader::read
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.
Definition: MaskedImageFitsReader.cc:170
result
py::object result
Definition: _schema.cc:429
lsst::afw::image::ExposureFitsReader::readXY0
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.
Definition: ExposureFitsReader.cc:275
ExposureFitsReader.h
lsst::afw::image::ExposureFitsReader::ArchiveReader::WCS
@ WCS
Definition: ExposureFitsReader.cc:129
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::image::ExposureFitsReader::ArchiveReader
Definition: ExposureFitsReader.cc:125
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::image::ExposureFitsReader::ArchiveReader::N_ARCHIVE_COMPONENTS
@ N_ARCHIVE_COMPONENTS
Definition: ExposureFitsReader.cc:136
LOGLS_DEBUG
#define LOGLS_DEBUG(logger, message)
Definition: Log.h:608
Polygon.h
std::string::substr
T substr(T... args)
lsst::afw::image::ExposureFitsReader::readApCorrMap
std::shared_ptr< ApCorrMap > readApCorrMap()
Read the Exposure's aperture correction map.
Definition: ExposureFitsReader.cc:324
lsst::afw::image::TransmissionCurve
A spatially-varying transmission curve as a function of wavelength.
Definition: TransmissionCurve.h:61
lsst::geom
Definition: geomOperators.dox:4
lsst::afw::image::ExposureFitsReader
A FITS reader class for Exposures and their components.
Definition: ExposureFitsReader.h:42
lsst::afw::image::ExposureFitsReader::readTransmissionCurve
std::shared_ptr< TransmissionCurve > readTransmissionCurve()
Read the Exposure's transmission curve.
Definition: ExposureFitsReader.cc:339
lsst::afw::image::MaskedImageFitsReader::readImageArray
ndarray::Array< ImagePixelT, 2, 2 > readImageArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
Definition: MaskedImageFitsReader.cc:137
lsst::afw::image::MaskedImageFitsReader::readImageMetadata
std::shared_ptr< daf::base::PropertyList > readImageMetadata()
Read the FITS header of one of the HDUs.
Definition: MaskedImageFitsReader.cc:106
lsst::afw::image::MaskedImageFitsReader::readMaskDType
std::string readMaskDType() const
Read a string describing the pixel type of the on-disk image plane.
Definition: MaskedImageFitsReader.cc:68
PhotoCalib.h
Implementation of the Photometric Calibration class.
key
Key< U > key
Definition: Schema.cc:281
lsst::afw::table::io::InputArchive::readFits
static InputArchive readFits(fits::Fits &fitsfile)
Read an object from an already open FITS object.
Definition: InputArchive.cc:186
lsst::geom::Point< int, 2 >
lsst::afw::image::ExposureFitsReader::MetadataReader::filter
Filter filter
Definition: ExposureFitsReader.cc:119
lsst::afw::image::CoaddInputs
A simple Persistable struct containing ExposureCatalogs that record the inputs to a coadd.
Definition: CoaddInputs.h:49
lsst::afw::image::ExposureFitsReader::readImageDType
std::string readImageDType() const
Read a string describing the pixel type of the on-disk image plane.
Definition: ExposureFitsReader.cc:279
lsst::afw::image::ExposureFitsReader::readVisitInfo
std::shared_ptr< VisitInfo > readVisitInfo()
Read the Exposure's visit metadata.
Definition: ExposureFitsReader.cc:334
lsst::afw::image::ExposureFitsReader::ArchiveReader::COADD_INPUTS
@ COADD_INPUTS
Definition: ExposureFitsReader.cc:130
lsst::afw::image::ExposureFitsReader::ArchiveReader::PSF
@ PSF
Definition: ExposureFitsReader.cc:128
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::afw::image::ExposureFitsReader::MetadataReader::metadata
std::shared_ptr< daf::base::PropertyList > metadata
Definition: ExposureFitsReader.cc:118
lsst::afw::geom::makeSkyWcs
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition: SkyWcs.cc:526
lsst::afw::image::ExposureFitsReader::readValidPolygon
std::shared_ptr< afw::geom::polygon::Polygon > readValidPolygon()
Read the polygon describing the region of validity for the Exposure.
Definition: ExposureFitsReader.cc:318
ApCorrMap.h
lsst::afw::image::MaskedImageFitsReader::readMask
Mask< MaskPixelT > readMask(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool allowUnsafe=false)
Read the mask plane.
Definition: MaskedImageFitsReader.cc:144
lsst::daf::base::PropertyList::remove
virtual void remove(std::string const &name)
Remove all values for a property name (possibly hierarchical).
Definition: PropertyList.cc:216
lsst::afw::image::ExposureFitsReader::MetadataReader
Definition: ExposureFitsReader.cc:53
lsst::afw::image::ImageOrigin
ImageOrigin
Definition: ImageBase.h:94
lsst::afw::detection::Psf
A polymorphic base class for representing an image's Point Spread Function.
Definition: Psf.h:76
element
double element[2]
Definition: BaseTable.cc:91
lsst::pex::exceptions::TypeError
Reports errors from accepting an object of an unexpected or inappropriate type.
Definition: Runtime.h:167
lsst::afw::image::ExposureFitsReader::MetadataReader::MetadataReader
MetadataReader(std::shared_ptr< daf::base::PropertyList > primaryMetadata, std::shared_ptr< daf::base::PropertyList > imageMetadata, lsst::geom::Point2I const &xy0)
Definition: ExposureFitsReader.cc:55
lsst::afw::image::ExposureFitsReader::ArchiveReader::AP_CORR_MAP
@ AP_CORR_MAP
Definition: ExposureFitsReader.cc:131
lsst::afw::image::ExposureFitsReader::readPsf
std::shared_ptr< detection::Psf > readPsf()
Read the Exposure's point-spread function.
Definition: ExposureFitsReader.cc:313
lsst::afw::image::ExposureFitsReader::readPhotoCalib
std::shared_ptr< PhotoCalib > readPhotoCalib()
Read the Exposure's photometric calibration.
Definition: ExposureFitsReader.cc:304
lsst::afw::image::ExposureFitsReader::read
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.
Definition: ExposureFitsReader.cc:473
lsst::afw::image::ApCorrMap
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
Definition: ApCorrMap.h:45
lsst::afw::image::Image< ImagePixelT >
lsst::afw::image::ExposureFitsReader::ArchiveReader::Component
Component
Definition: ExposureFitsReader.cc:127
INSTANTIATE
#define INSTANTIATE(ImagePixelT)
Definition: ExposureFitsReader.cc:493
lsst::afw::image::ExposureFitsReader::readVarianceArray
ndarray::Array< VariancePixelT, 2, 2 > readVarianceArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the variance plane.
Definition: ExposureFitsReader.cc:458
lsst::afw::image::detail::stripVisitInfoKeywords
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
Definition: VisitInfo.cc:265
lsst::geom::Extent< double, 2 >
lsst::pex::exceptions::Exception::what
virtual char const * what(void) const noexcept
Return a character string summarizing this exception.
Definition: Exception.cc:99
lsst::afw::image::ExposureFitsReader::readImageArray
ndarray::Array< ImagePixelT, 2, 2 > readImageArray(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image plane.
Definition: ExposureFitsReader.cc:434
Log.h
LSST DM logging module built on log4cxx.
Detector.h
lsst::afw::image::ExposureFitsReader::~ExposureFitsReader
~ExposureFitsReader() noexcept
lsst::afw::cameraGeom::Detector
A representation of a detector in a mosaic camera.
Definition: Detector.h:185
lsst::afw::image::ExposureFitsReader::ArchiveReader::DETECTOR
@ DETECTOR
Definition: ExposureFitsReader.cc:134
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
lsst::afw::image::ExposureFitsReader::ArchiveReader::VALID_POLYGON
@ VALID_POLYGON
Definition: ExposureFitsReader.cc:132
lsst::afw::table::io::InputArchive::get
std::shared_ptr< Persistable > get(int id) const
Load the Persistable with the given ID and return it.
Definition: InputArchive.cc:182
lsst::afw::image::ExposureFitsReader::ArchiveReader::TRANSMISSION_CURVE
@ TRANSMISSION_CURVE
Definition: ExposureFitsReader.cc:133