LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
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
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
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.
ExposureInfo(std::shared_ptr< geom::SkyWcs const > const &wcs=std::shared_ptr< geom::SkyWcs const >(), std::shared_ptr< detection::Psf const > const &psf=std::shared_ptr< detection::Psf const >(), std::shared_ptr< PhotoCalib const > const &photoCalib=std::shared_ptr< PhotoCalib const >(), std::shared_ptr< cameraGeom::Detector const > const &detector=std::shared_ptr< cameraGeom::Detector const >(), std::shared_ptr< geom::polygon::Polygon const > const &polygon=std::shared_ptr< geom::polygon::Polygon const >(), std::shared_ptr< daf::base::PropertySet > const &metadata=std::shared_ptr< daf::base::PropertySet >(), std::shared_ptr< CoaddInputs > const &coaddInputs=std::shared_ptr< CoaddInputs >(), std::shared_ptr< ApCorrMap > const &apCorrMap=std::shared_ptr< ApCorrMap >(), std::shared_ptr< image::VisitInfo const > const &visitInfo=std::shared_ptr< image::VisitInfo const >(), std::shared_ptr< TransmissionCurve const > const &transmissionCurve=std::shared_ptr< TransmissionCurve >())
Construct an ExposureInfo from its various components.
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 > visitInfo
Definition Exposure.cc:70
Key< int > transmissionCurve
Definition Exposure.cc:71
Key< int > apCorrMap
Definition Exposure.cc:68
T throw_with_nested(T... args)