37 LOG_LOGGER _log =
LOG_GET(
"afw.image.ExposureInfo");
49 if (metadata.exists(name)) {
50 r = metadata.get<
int>(
name);
51 metadata.remove(name);
66 if (wcs)
return wcs->clone();
72 return std::make_shared<ApCorrMap>(*apCorrMap);
87 : _wcs(_cloneWcs(wcs)),
88 _psf(
std::const_pointer_cast<detection::Psf>(psf)),
89 _calib(calib ? _cloneCalib(calib) :
std::shared_ptr<
Calib>(new
Calib())),
91 _validPolygon(polygon),
93 _metadata(metadata ? metadata
95 _coaddInputs(coaddInputs),
96 _apCorrMap(_cloneApCorrMap(apCorrMap)),
97 _visitInfo(visitInfo),
98 _transmissionCurve(transmissionCurve)
102 : _wcs(_cloneWcs(other._wcs)),
104 _calib(_cloneCalib(other._calib)),
105 _detector(other._detector),
106 _validPolygon(other._validPolygon),
107 _filter(other._filter),
108 _metadata(other._metadata),
109 _coaddInputs(other._coaddInputs),
110 _apCorrMap(_cloneApCorrMap(other._apCorrMap)),
111 _visitInfo(other._visitInfo),
112 _transmissionCurve(other._transmissionCurve) {}
118 : _wcs(_cloneWcs(other._wcs)),
120 _calib(_cloneCalib(other._calib)),
121 _detector(other._detector),
122 _validPolygon(other._validPolygon),
123 _filter(other._filter),
124 _metadata(other._metadata),
125 _coaddInputs(other._coaddInputs),
126 _apCorrMap(_cloneApCorrMap(other._apCorrMap)),
127 _visitInfo(other._visitInfo),
128 _transmissionCurve(other._transmissionCurve) {
129 if (copyMetadata) _metadata = _metadata->deepCopy();
133 if (&other !=
this) {
134 _wcs = _cloneWcs(other._wcs);
136 _calib = _cloneCalib(other._calib);
137 _detector = other._detector;
138 _validPolygon = other._validPolygon;
139 _filter = other._filter;
140 _metadata = other._metadata;
141 _coaddInputs = other._coaddInputs;
142 _apCorrMap = _cloneApCorrMap(other._apCorrMap);
143 _visitInfo = other._visitInfo;
144 _transmissionCurve = other._transmissionCurve;
155 ExposureInfo::FitsWriteData ExposureInfo::_startWriteFits(
afw::geom::Point2I const& xy0)
const {
160 data.maskMetadata = data.imageMetadata;
161 data.varianceMetadata = data.imageMetadata;
171 data.metadata->set(
"AR_HDU", 5,
"HDU (1-indexed) containing the archive used to store ancillary objects");
174 data.metadata->set(
"COADD_INPUTS_ID", coaddInputsId,
"archive ID for coadd inputs catalogs");
178 data.metadata->set(
"AP_CORR_MAP_ID", apCorrMapId,
"archive ID for aperture correction map");
181 int psfId = data.archive.put(
getPsf());
182 data.metadata->set(
"PSF_ID", psfId,
"archive ID for the Exposure's main Psf");
185 int wcsId = data.archive.put(
getWcs());
186 data.metadata->set(
"WCS_ID", wcsId,
"archive ID for the Exposure's main Wcs");
190 data.metadata->set(
"VALID_POLYGON_ID", polygonId,
"archive ID for the Exposure's valid polygon");
194 data.metadata->set(
"TRANSMISSION_CURVE_ID", transmissionCurveId,
195 "archive ID for the Exposure's transmission curve");
205 newWcs->shiftReferencePixel(-xy0.getX(), -xy0.getY());
208 data.imageMetadata->combine(newWcs->getFitsMetadata());
222 data.imageMetadata->set(
"LTV1", static_cast<double>(-xy0.getX()));
223 data.imageMetadata->set(
"LTV2", static_cast<double>(-xy0.getY()));
225 data.metadata->set(
"FILTER",
getFilter().getName());
227 data.metadata->set(
"DETNAME",
getDetector()->getName());
228 data.metadata->set(
"DETSER",
getDetector()->getSerial());
239 data.metadata->set(
"FLUXMAG0",
getCalib()->getFluxMag0().
first);
240 data.metadata->set(
"FLUXMAG0ERR",
getCalib()->getFluxMag0().
second);
245 void ExposureInfo::_finishWriteFits(
fits::Fits& fitsfile, FitsWriteData
const& data)
const {
246 data.archive.writeFits(fitsfile);
252 _wcs =
makeWcs(imageMetadata,
true);
254 if (!imageMetadata->exists(
"INHERIT")) {
260 metadata = imageMetadata;
263 _filter =
Filter(metadata,
true);
273 int archiveHdu = popInt(*metadata,
"AR_HDU");
278 fitsfile.
setHdu(archiveHdu);
284 int psfId = popInt(*metadata,
"PSF_ID");
288 LOGLS_WARN(_log,
"Could not read PSF; setting to null: " << err.
what());
290 int wcsId = popInt(*metadata,
"WCS_ID");
292 auto archiveWcs = archive.
get<
Wcs>(wcsId);
296 LOGLS_DEBUG(_log,
"Null WCS seen in binary table");
299 auto msg = str(boost::format(
"Could not read WCS extension; setting to null: %s") % err.
what());
301 msg +=
" ; using WCS from FITS header";
305 int coaddInputsId = popInt(*metadata,
"COADD_INPUTS_ID");
309 LOGLS_WARN(_log,
"Could not read CoaddInputs; setting to null: " << err.
what());
311 int apCorrMapId = popInt(*metadata,
"AP_CORR_MAP_ID");
315 LOGLS_WARN(_log,
"Could not read ApCorrMap; setting to null: " << err.
what());
317 int validPolygonId = popInt(*metadata,
"VALID_POLYGON_ID");
321 LOGLS_WARN(_log,
"Could not read ValidPolygon; setting to null: " << err.
what());
323 int transmissionCurveId = popInt(*metadata,
"TRANSMISSION_CURVE_ID");
327 LOGLS_WARN(_log,
"Could not read TransmissionCurve; setting to null: " << err.
what());
331 _metadata = metadata;
#define LOGLS_WARN(logger, message)
std::shared_ptr< Wcs > getWcs()
Return the coordinate system of the exposure.
bool hasTransmissionCurve() const
Does this exposure have a transmission curve?
A spatially-varying transmission curve as a function of wavelength.
table::Key< std::string > name
void setCalib(std::shared_ptr< Calib const > calib)
Set the Exposure's Calib object.
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
Information about a single exposure of an imaging camera.
std::shared_ptr< Wcs > makeWcs(std::shared_ptr< lsst::daf::base::PropertySet > const &fitsMetadata, bool stripMetadata=false)
Create a Wcs object from a fits header.
std::shared_ptr< image::VisitInfo const > getVisitInfo() const
Return the exposure's visit info.
bool hasPsf() const
Does this exposure have a Psf?
std::shared_ptr< ApCorrMap > getApCorrMap()
Return the exposure's aperture correction map (null pointer if !hasApCorrMap())
int stripFilterKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Filter-related keywords from the metadata.
bool hasDetector() const
Does this exposure have Detector information?
Implementation of the WCS standard for a any projection.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
bool hasWcs() const
Does this exposure have a Wcs?
Describe an exposure's calibration.
lsst::daf::base::PropertySet PropertySet
ExposureInfo & operator=(ExposureInfo const &other)
Assignment; deep-copies all components except the metadata.
void setVisitInfoMetadata(daf::base::PropertyList &metadata, VisitInfo const &visitInfo)
Set FITS metadata from a VisitInfo.
bool hasApCorrMap() const
Return true if the exposure has an aperture correction map.
#define LOGLS_DEBUG(logger, message)
A base class for image defects.
std::shared_ptr< detection::Psf > getPsf() const
Return the exposure's point-spread function.
void initApCorrMap()
Set the exposure's aperture correction map to a new, empty map.
bool hasValidPolygon() const
Does this exposure have a valid Polygon.
int stripCalibKeywords(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Remove Calib-related keywords from the metadata.
std::shared_ptr< geom::polygon::Polygon const > getValidPolygon() const
Return the valid Polygon.
Holds an integer identifier for an LSST filter.
void setHdu(int hdu, bool relative=false)
Set the current HDU.
std::shared_ptr< daf::base::PropertySet > getMetadata() const
Return flexible metadata.
virtual char const * what(void) const
ExposureInfo(std::shared_ptr< Wcs const > const &wcs=std::shared_ptr< Wcs const >(), std::shared_ptr< detection::Psf const > const &psf=std::shared_ptr< detection::Psf const >(), std::shared_ptr< Calib const > const &calib=std::shared_ptr< Calib 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 >(), Filter const &filter=Filter(), 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.
std::shared_ptr< cameraGeom::Detector const > getDetector() const
Return the exposure's Detector information.
std::shared_ptr< Calib > getCalib()
Return the exposure's photometric calibration.
int stripVisitInfoKeywords(daf::base::PropertySet &metadata)
Remove VisitInfo-related keywords from the metadata.
A collection of all the things that make an Exposure different from a MaskedImage.
A polymorphic base class for representing an image's Point Spread Function.
std::shared_ptr< CoaddInputs > getCoaddInputs() const
Return a pair of catalogs that record the inputs, if this Exposure is a coadd (otherwise null)...
Filter getFilter() const
Return the exposure's filter.
bool hasCoaddInputs() const
Does this exposure have coadd provenance catalogs?
std::shared_ptr< TransmissionCurve const > getTransmissionCurve() const
Return the exposure's transmission curve.