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 auto newVisitInfo = std::make_shared<VisitInfo>(
147 *_exposureId, oldVisitInfo->getExposureTime(), oldVisitInfo->getDarkTime(),
148 oldVisitInfo->getDate(), oldVisitInfo->getUt1(), oldVisitInfo->getEra(),
149 oldVisitInfo->getBoresightRaDec(), oldVisitInfo->getBoresightAzAlt(),
150 oldVisitInfo->getBoresightAirmass(), oldVisitInfo->getBoresightRotAngle(),
151 oldVisitInfo->getRotType(), oldVisitInfo->getObservatory(), oldVisitInfo->getWeather(),
152 oldVisitInfo->getInstrumentLabel(), oldVisitInfo->getId());
154 _visitInfo = newVisitInfo;
162 typehandling::makeKey<std::shared_ptr<FilterLabel const>>(
"FILTER"s);
192 return std::make_shared<ApCorrMap>(*
apCorrMap);
208 _metadata(metadata ? metadata
209 :
std::shared_ptr<daf::base::PropertySet>(new daf::base::PropertyList())),
211 _components(
std::make_unique<MapClass>()) {
228 : _exposureId(other._exposureId),
229 _metadata(other._metadata),
230 _visitInfo(other._visitInfo),
232 _components(
std::make_unique<MapClass>(*(other._components))) {
233 if (copyMetadata) _metadata = _metadata->deepCopy();
237 if (&other !=
this) {
238 _exposureId = other._exposureId;
239 _metadata = other._metadata;
240 _visitInfo = other._visitInfo;
242 _components = std::make_unique<MapClass>(*(other._components));
255 int componentId =
data.archive.put(
object);
256 data.metadata->set(key, componentId, comment);
260int ExposureInfo::_addToArchive(FitsWriteData&
data,
265 int componentId =
data.archive.put(
object);
266 data.metadata->set(key, componentId, comment);
276 return "archive ID for generic component '" + mapKey +
"'";
280ExposureInfo::FitsWriteData ExposureInfo::_startWriteFits(
lsst::geom::Point2I const& xy0)
const {
283 data.metadata.reset(
new daf::base::PropertyList());
284 data.imageMetadata.reset(
new daf::base::PropertyList());
285 data.maskMetadata =
data.imageMetadata;
286 data.varianceMetadata =
data.imageMetadata;
298 data.metadata->set(
"AR_HDU", 5,
"HDU (1-indexed) containing the archive used to store ancillary objects");
299 for (
auto const& keyValue : *_components) {
303 if (
object && object->isPersistable()) {
308 int id = _addToArchive(
data,
object, _getOldHeaderKey(key), comment);
309 data.metadata->set(_getNewHeaderKey(key),
id, comment);
322 auto newWcs =
getWcs()->copyAtShiftedPixelOrigin(shift);
325 wcsMetadata = newWcs->getFitsMetadata(
true);
326 }
catch (pex::exceptions::RuntimeError
const&) {
330 data.imageMetadata->combine(*newWcs->getFitsMetadata(
true));
340 data.imageMetadata->set(
"LTV1",
static_cast<double>(-xy0.getX()));
341 data.imageMetadata->set(
"LTV2",
static_cast<double>(-xy0.getY()));
361void ExposureInfo::_finishWriteFits(fits::Fits& fitsfile, FitsWriteData
const&
data)
const {
362 data.archive.writeFits(fitsfile);
table::Key< int > detector
#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.
table::Key< table::Array< std::uint8_t > > wcs
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?
void setFilterLabel(std::shared_ptr< FilterLabel const > filterLabel)
Set the exposure's filter information.
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())
std::shared_ptr< FilterLabel const > getFilterLabel() const
Return the exposure's filter information.
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.
bool hasFilterLabel() const
Does this exposure have filter 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.
void initApCorrMap()
Set the exposure's aperture correction map to a new, empty map.
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.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Extent< double, 2 > Extent2D
A base class for image defects.
Key< int > transmissionCurve