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(), oldVisitInfo->getFocusZ(),
153 oldVisitInfo->getObservationType(), oldVisitInfo->getScienceProgram(),
154 oldVisitInfo->getObservationReason(), oldVisitInfo->getObject(),
155 oldVisitInfo->getHasSimulatedContent());
157 _visitInfo = newVisitInfo;
164 typehandling::makeKey<std::shared_ptr<FilterLabel const>>(
"FILTER"s);
187 return std::make_shared<ApCorrMap>(*apCorrMap);
203 _metadata(metadata ? metadata
204 :
std::shared_ptr<daf::base::PropertySet>(new daf::base::PropertyList())),
206 _components(
std::make_unique<MapClass>()) {
223 : _exposureId(other._exposureId),
224 _metadata(other._metadata),
225 _visitInfo(other._visitInfo),
227 _components(
std::make_unique<MapClass>(*(other._components))) {
228 if (copyMetadata) _metadata = _metadata->deepCopy();
232 if (&other !=
this) {
233 _exposureId = other._exposureId;
234 _metadata = other._metadata;
235 _visitInfo = other._visitInfo;
237 _components = std::make_unique<MapClass>(*(other._components));
250 int componentId =
data.archive.put(
object);
251 data.metadata->set(key, componentId, comment);
255int ExposureInfo::_addToArchive(FitsWriteData&
data,
260 int componentId =
data.archive.put(
object);
261 data.metadata->set(key, componentId, comment);
271 return "archive ID for generic component '" + mapKey +
"'";
275ExposureInfo::FitsWriteData ExposureInfo::_startWriteFits(
lsst::geom::Point2I const& xy0)
const {
278 data.metadata.reset(
new daf::base::PropertyList());
279 data.imageMetadata.reset(
new daf::base::PropertyList());
280 data.maskMetadata =
data.imageMetadata;
281 data.varianceMetadata =
data.imageMetadata;
293 data.metadata->set(
"AR_HDU", 5,
"HDU (1-indexed) containing the archive used to store ancillary objects");
294 for (
auto const& keyValue : *_components) {
298 if (
object &&
object->isPersistable()) {
303 int id = _addToArchive(
data,
object, _getOldHeaderKey(key), comment);
304 data.metadata->set(_getNewHeaderKey(key),
id, comment);
317 auto newWcs =
getWcs()->copyAtShiftedPixelOrigin(shift);
320 wcsMetadata = newWcs->getFitsMetadata(
true);
321 }
catch (pex::exceptions::RuntimeError
const&) {
325 data.imageMetadata->combine(*newWcs->getFitsMetadata(
true));
335 data.imageMetadata->set(
"LTV1",
static_cast<double>(-xy0.getX()));
336 data.imageMetadata->set(
"LTV2",
static_cast<double>(-xy0.getY()));
356void ExposureInfo::_finishWriteFits(fits::Fits& fitsfile, FitsWriteData
const&
data)
const {
357 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
table::Key< std::string > object
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.
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.
Extent< double, 2 > Extent2D
Key< int > transmissionCurve