LSST Applications 26.0.0,g0265f82a02+6660c170cc,g07994bdeae+30b05a742e,g0a0026dc87+17526d298f,g0a60f58ba1+17526d298f,g0e4bf8285c+96dd2c2ea9,g0ecae5effc+c266a536c8,g1e7d6db67d+6f7cb1f4bb,g26482f50c6+6346c0633c,g2bbee38e9b+6660c170cc,g2cc88a2952+0a4e78cd49,g3273194fdb+f6908454ef,g337abbeb29+6660c170cc,g337c41fc51+9a8f8f0815,g37c6e7c3d5+7bbafe9d37,g44018dc512+6660c170cc,g4a941329ef+4f7594a38e,g4c90b7bd52+5145c320d2,g58be5f913a+bea990ba40,g635b316a6c+8d6b3a3e56,g67924a670a+bfead8c487,g6ae5381d9b+81bc2a20b4,g93c4d6e787+26b17396bd,g98cecbdb62+ed2cb6d659,g98ffbb4407+81bc2a20b4,g9ddcbc5298+7f7571301f,ga1e77700b3+99e9273977,gae46bcf261+6660c170cc,gb2715bf1a1+17526d298f,gc86a011abf+17526d298f,gcf0d15dbbd+96dd2c2ea9,gdaeeff99f8+0d8dbea60f,gdb4ec4c597+6660c170cc,ge23793e450+96dd2c2ea9,gf041782ebf+171108ac67
LSST Data Management Base Package
Loading...
Searching...
No Matches
ExposureInfo.h
Go to the documentation of this file.
1// -*- LSST-C++ -*- // fixed format comment for emacs
2/*
3 * This file is part of afw.
4 *
5 * Developed for the LSST Data Management System.
6 * This product includes software developed by the LSST Project
7 * (https://www.lsst.org).
8 * See the COPYRIGHT file at the top-level directory of this distribution
9 * for details of code ownership.
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
25#ifndef LSST_AFW_IMAGE_ExposureInfo_h_INCLUDED
26#define LSST_AFW_IMAGE_ExposureInfo_h_INCLUDED
27
28#include <optional>
29
30#include "lsst/base.h"
31#include "lsst/daf/base.h"
32#include "lsst/geom/Point.h"
38#include "lsst/afw/table/misc.h" // For table::RecordId
39
40namespace lsst {
41namespace afw {
42
43namespace cameraGeom {
44class Detector;
45}
46
47namespace detection {
48class Psf;
49}
50
51namespace geom {
52namespace polygon {
53class Polygon;
54class SkyWcs;
55} // namespace polygon
56} // namespace geom
57
58namespace fits {
59class Fits;
60}
61
62namespace image {
63
64class PhotoCalib;
65class ApCorrMap;
66class VisitInfo;
67class TransmissionCurve;
68
88class ExposureInfo final {
89public:
110
119 bool hasId() const noexcept;
120
131 table::RecordId getId() const;
132
141 void setId(table::RecordId id);
142
144 void clearId() noexcept;
145
147 bool hasWcs() const;
148
150 std::shared_ptr<geom::SkyWcs const> getWcs() const;
151
153 void setWcs(std::shared_ptr<geom::SkyWcs const> wcs);
154
156 bool hasDetector() const;
157
159 std::shared_ptr<cameraGeom::Detector const> getDetector() const;
160
162 void setDetector(std::shared_ptr<cameraGeom::Detector const> detector);
163
165 bool hasFilter() const;
166
168 std::shared_ptr<FilterLabel const> getFilter() const;
169
171 void setFilter(std::shared_ptr<FilterLabel const> filter);
172
174 bool hasPhotoCalib() const;
175
177 std::shared_ptr<PhotoCalib const> getPhotoCalib() const;
178
180 void setPhotoCalib(std::shared_ptr<PhotoCalib const> photoCalib);
181
183 std::shared_ptr<daf::base::PropertySet> getMetadata() const { return _metadata; }
184
186 void setMetadata(std::shared_ptr<daf::base::PropertySet> metadata) { _metadata = metadata; }
187
189 bool hasPsf() const;
190
193
196
198 bool hasValidPolygon() const;
199
202
205
207 bool hasApCorrMap() const;
208
211
214
216 bool hasCoaddInputs() const;
217
220
223
226
228 bool hasVisitInfo() const { return static_cast<bool>(_visitInfo); }
229
232
234 bool hasTransmissionCurve() const;
235
238
241
266 template <class T>
268 std::shared_ptr<T> const& object) {
269 static_assert(std::is_base_of<typehandling::Storable, T>::value, "T must be a Storable");
270 // "No data" always represented internally by absent key-value pair, not by mapping to null
271 if (object != nullptr) {
272 _setComponent(key, object);
273 } else {
274 removeComponent(key);
275 }
276 }
277
286 template <class T>
288 return _components->contains(key);
289 }
290
300 template <class T>
302 try {
303 return _components->at(key);
304 } catch (pex::exceptions::OutOfRangeError const& e) {
305 return nullptr;
306 }
307 }
308
318 template <class T>
320 return _components->erase(key);
321 }
322
324 static int getFitsSerializationVersion();
325
328
336 explicit ExposureInfo(
352
354 ExposureInfo(ExposureInfo const& other);
355 ExposureInfo(ExposureInfo&& other);
356
358 ExposureInfo(ExposureInfo const& other, bool copyMetadata);
359
361 ExposureInfo& operator=(ExposureInfo const& other);
363
364 // Destructor defined in source file because we need access to destructors of forward-declared components
366
367private:
368 template <typename ImageT, typename MaskT, typename VarianceT>
369 friend class Exposure;
370
384 struct FitsWriteData {
390 };
391
408 static int _addToArchive(FitsWriteData& data, table::io::Persistable const& object, std::string key,
409 std::string comment);
410
411 static int _addToArchive(FitsWriteData& data, std::shared_ptr<table::io::Persistable const> const& object,
412 std::string key, std::string comment);
413
424 FitsWriteData _startWriteFits(lsst::geom::Point2I const& xy0 = lsst::geom::Point2I()) const;
425
439 void _finishWriteFits(fits::Fits& fitsfile, FitsWriteData const& data) const;
440
442
443 // Implementation of setComponent
444 template <class T>
445 void _setComponent(typehandling::Key<std::string, std::shared_ptr<T>> const& key,
446 std::shared_ptr<T> const& object) {
447 if (_components->contains(key)) {
448 _components->erase(key);
449 } else if (_components->contains(key.getId())) {
450 std::stringstream buffer;
451 buffer << "Map has a key that conflicts with " << key;
453 }
454 try {
455 bool success = _components->insert(key, object);
456 if (!success) {
457 throw LSST_EXCEPT(
459 "Insertion failed for unknown reasons. There may be something in the logs.");
460 }
461 } catch (std::exception const& e) {
463 LSST_EXCEPT(pex::exceptions::RuntimeError, "Insertion raised an exception."));
464 }
465 }
466
467 std::optional<table::RecordId> _exposureId;
470
471 // Class invariant: all pointers in _components are not null
473};
474} // namespace image
475} // namespace afw
476} // namespace lsst
477
478#endif // !LSST_AFW_IMAGE_ExposureInfo_h_INCLUDED
char * data
Definition BaseRecord.cc:61
table::Key< int > detector
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
table::Key< table::Array< std::uint8_t > > wcs
Definition SkyWcs.cc:66
Basic LSST definitions.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition fits.h:308
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition Exposure.h:72
A collection of all the things that make an Exposure different from a MaskedImage.
bool hasWcs() const
Does this exposure have a Wcs?
static int getFitsSerializationVersion()
Get the version of FITS serialization that this ExposureInfo understands.
bool hasCoaddInputs() const
Does this exposure have coadd provenance catalogs?
static typehandling::Key< std::string, std::shared_ptr< geom::SkyWcs const > > const KEY_WCS
Standard key for looking up the Wcs.
ExposureInfo & operator=(ExposureInfo const &other)
Assignment; shares all components.
static typehandling::Key< std::string, std::shared_ptr< cameraGeom::Detector const > > const KEY_DETECTOR
Standard key for looking up the detector information.
bool hasTransmissionCurve() const
Does this exposure have a transmission curve?
bool hasPsf() const
Does this exposure have a Psf?
void setVisitInfo(std::shared_ptr< image::VisitInfo const > const visitInfo)
Set the exposure's visit info.
void setValidPolygon(std::shared_ptr< geom::polygon::Polygon const > polygon)
Set the exposure's valid Polygon.
bool hasPhotoCalib() const
Does this exposure have a photometric calibration?
bool hasApCorrMap() const
Return true if the exposure has an aperture correction map.
void setWcs(std::shared_ptr< geom::SkyWcs const > wcs)
Set the WCS of the exposure.
std::shared_ptr< PhotoCalib const > getPhotoCalib() const
Return the exposure's photometric calibration.
bool hasComponent(typehandling::Key< std::string, T > const &key) const
Test whether a generic component is defined.
std::shared_ptr< ApCorrMap const > getApCorrMap() const
Return the exposure's aperture correction map (null pointer if !hasApCorrMap())
void setApCorrMap(std::shared_ptr< ApCorrMap const > apCorrMap)
Set the exposure's aperture correction map (null pointer if !hasApCorrMap())
void setPhotoCalib(std::shared_ptr< PhotoCalib const > photoCalib)
Set the Exposure's PhotoCalib object.
static typehandling::Key< std::string, std::shared_ptr< geom::polygon::Polygon const > > const KEY_VALID_POLYGON
Standard key for looking up the valid polygon.
void setComponent(typehandling::Key< std::string, std::shared_ptr< T > > const &key, std::shared_ptr< T > const &object)
Add a generic component to the ExposureInfo.
bool hasValidPolygon() const
Does this exposure have a valid Polygon.
std::shared_ptr< geom::SkyWcs const > getWcs() const
Return the WCS of the exposure.
std::shared_ptr< T > getComponent(typehandling::Key< std::string, std::shared_ptr< T > > const &key) const
Retrieve a generic component from the ExposureInfo.
std::shared_ptr< FilterLabel const > getFilter() const
Return the exposure's filter information.
static typehandling::Key< std::string, std::shared_ptr< PhotoCalib const > > const KEY_PHOTO_CALIB
Standard key for looking up the photometric calibration.
void setCoaddInputs(std::shared_ptr< CoaddInputs const > coaddInputs)
Set the exposure's coadd provenance catalogs.
std::shared_ptr< cameraGeom::Detector const > getDetector() const
Return the exposure's Detector information.
void clearId() noexcept
Unset the exposure ID, if any.
void setMetadata(std::shared_ptr< daf::base::PropertySet > metadata)
Set the flexible metadata.
void setDetector(std::shared_ptr< cameraGeom::Detector const > detector)
Set the exposure's Detector information.
void setFilter(std::shared_ptr< FilterLabel const > filter)
Set the exposure's filter information.
bool hasVisitInfo() const
Does this exposure have visit info?
void setPsf(std::shared_ptr< detection::Psf const > psf)
Set the exposure's point-spread function.
static typehandling::Key< std::string, std::shared_ptr< TransmissionCurve const > > const KEY_TRANSMISSION_CURVE
Standard key for looking up the transmission curve.
static typehandling::Key< std::string, std::shared_ptr< CoaddInputs const > > const KEY_COADD_INPUTS
Standard key for looking up coadd provenance catalogs.
static typehandling::Key< std::string, std::shared_ptr< detection::Psf const > > const KEY_PSF
Standard key for looking up the point-spread function.
std::shared_ptr< CoaddInputs const > getCoaddInputs() const
Return a pair of catalogs that record the inputs, if this Exposure is a coadd (otherwise null).
bool hasFilter() const
Does this exposure have filter information?
table::RecordId getId() const
Return the exposure ID.
std::shared_ptr< geom::polygon::Polygon const > getValidPolygon() const
Return the valid Polygon.
std::shared_ptr< daf::base::PropertySet > getMetadata() const
Return flexible metadata.
bool hasDetector() const
Does this exposure have Detector information?
static typehandling::Key< std::string, std::shared_ptr< ApCorrMap const > > const KEY_AP_CORR_MAP
Standard key for looking up the aperture correction map.
static std::string const & getFitsSerializationVersionName()
Get the version of FITS serialization version info name.
std::shared_ptr< image::VisitInfo const > getVisitInfo() const
Return the exposure's visit info.
static typehandling::Key< std::string, std::shared_ptr< FilterLabel const > > const KEY_FILTER
Standard key for looking up filter information.
void setId(table::RecordId id)
Set the exposure ID.
bool hasId() const noexcept
Does this Exposure have an exposure id?
void setTransmissionCurve(std::shared_ptr< TransmissionCurve const > tc)
Set the exposure's transmission curve.
bool removeComponent(typehandling::Key< std::string, T > const &key)
Clear a generic component from the ExposureInfo.
std::shared_ptr< detection::Psf const > getPsf() const
Return the exposure's point-spread function.
std::shared_ptr< TransmissionCurve const > getTransmissionCurve() const
Return the exposure's transmission curve.
A group of labels for a filter in an exposure or coadd.
Definition FilterLabel.h:58
The photometric calibration of an exposure.
Definition PhotoCalib.h:114
A multi-catalog archive object used to save table::io::Persistable objects.
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition Persistable.h:74
Key for type-safe lookup in a GenericMap.
Definition Key.h:52
Reports attempts to access elements outside a valid range of indices.
Definition Runtime.h:89
Reports errors that are due to events beyond the control of the program.
Definition Runtime.h:104
Reports errors from accepting an object of an unexpected or inappropriate type.
Definition Runtime.h:167
STL namespace.
T str(T... args)
Key< int > psf
Definition Exposure.cc:65
Key< int > visitInfo
Definition Exposure.cc:70
Key< int > photoCalib
Definition Exposure.cc:67
Key< int > transmissionCurve
Definition Exposure.cc:71
Key< int > apCorrMap
Definition Exposure.cc:68
T throw_with_nested(T... args)