37using namespace std::string_literals;
52 typehandling::makeKey<std::shared_ptr<geom::SkyWcs const>>(
"SKYWCS"s);
59 typehandling::makeKey<std::shared_ptr<detection::Psf const>>(
"PSF"s);
66 typehandling::makeKey<std::shared_ptr<PhotoCalib const>>(
"PHOTOCALIB"s);
77 typehandling::makeKey<std::shared_ptr<cameraGeom::Detector const>>(
"DETECTOR"s);
89 typehandling::makeKey<std::shared_ptr<geom::polygon::Polygon const>>(
"VALID_POLYGON"s);
100 typehandling::makeKey<std::shared_ptr<CoaddInputs const>>(
"COADD_INPUTS"s);
111 typehandling::makeKey<std::shared_ptr<ApCorrMap const>>(
"AP_CORR_MAP"s);
121 typehandling::makeKey<std::shared_ptr<TransmissionCurve const>>(
"TRANSMISSION_CURVE"s);
146 typehandling::makeKey<std::shared_ptr<FilterLabel const>>(
"FILTER"s);
169 return std::make_shared<ApCorrMap>(*
apCorrMap);
185 _metadata(metadata ? metadata
186 :
std::shared_ptr<daf::base::PropertySet>(new daf::base::PropertyList())),
188 _components(
std::make_unique<MapClass>()) {
205 : _exposureId(other._exposureId),
206 _metadata(other._metadata),
207 _visitInfo(other._visitInfo),
209 _components(
std::make_unique<MapClass>(*(other._components))) {
210 if (copyMetadata) _metadata = _metadata->deepCopy();
214 if (&other !=
this) {
215 _exposureId = other._exposureId;
216 _metadata = other._metadata;
217 _visitInfo = other._visitInfo;
219 _components = std::make_unique<MapClass>(*(other._components));
230 int componentId =
data.archive.put(
object);
231 data.metadata->set(key, componentId, comment);
235int ExposureInfo::_addToArchive(FitsWriteData&
data,
240 int componentId =
data.archive.put(
object);
241 data.metadata->set(key, componentId, comment);
251 return "archive ID for generic component '" + mapKey +
"'";
255ExposureInfo::FitsWriteData ExposureInfo::_startWriteFits(
lsst::geom::Point2I const& xy0)
const {
258 data.metadata.reset(
new daf::base::PropertyList());
259 data.imageMetadata.reset(
new daf::base::PropertyList());
260 data.maskMetadata =
data.imageMetadata;
261 data.varianceMetadata =
data.imageMetadata;
273 data.metadata->set(
"AR_HDU", 5,
"HDU (1-indexed) containing the archive used to store ancillary objects");
274 for (
auto const& keyValue : *_components) {
278 if (
object && object->isPersistable()) {
283 int id = _addToArchive(
data,
object, _getOldHeaderKey(key), comment);
284 data.metadata->set(_getNewHeaderKey(key),
id, comment);
297 auto newWcs =
getWcs()->copyAtShiftedPixelOrigin(shift);
300 wcsMetadata = newWcs->getFitsMetadata(
true);
301 }
catch (pex::exceptions::RuntimeError
const&) {
305 data.imageMetadata->combine(*newWcs->getFitsMetadata(
true));
315 data.imageMetadata->set(
"LTV1",
static_cast<double>(-xy0.getX()));
316 data.imageMetadata->set(
"LTV2",
static_cast<double>(-xy0.getY()));
335void ExposureInfo::_finishWriteFits(fits::Fits& fitsfile, FitsWriteData
const&
data)
const {
336 data.archive.writeFits(fitsfile);
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
LSST DM logging module built on log4cxx.
#define LOG_GET(logger)
Returns a Log object associated with logger.
Implementation of the Photometric Calibration class.
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 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 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.
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.
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 map of Storable supporting strongly-typed access.
A base class for objects that can be persisted via afw::table::io Archive classes.
Key for type-safe lookup in a GenericMap.
Reports attempts to access elements using an invalid key.
void setVisitInfoMetadata(daf::base::PropertyList &metadata, VisitInfo const &visitInfo)
Set FITS metadata from a VisitInfo.
Extent< double, 2 > Extent2D
Key< int > transmissionCurve