39 namespace lsst {
namespace afw {
namespace image {
46 if (metadata.exists(name)) {
47 r = metadata.get<
int>(
name);
48 metadata.remove(name);
72 return std::make_shared<ApCorrMap>(*apCorrMap);
87 ) : _wcs(_cloneWcs(wcs)),
88 _psf(std::const_pointer_cast<detection::Psf>(psf)),
91 _validPolygon(polygon),
94 _coaddInputs(coaddInputs),
95 _apCorrMap(_cloneApCorrMap(apCorrMap))
99 _wcs(_cloneWcs(other._wcs)),
101 _calib(_cloneCalib(other._calib)),
102 _detector(other._detector),
103 _validPolygon(other._validPolygon),
104 _filter(other._filter),
106 _coaddInputs(other._coaddInputs),
107 _apCorrMap(_cloneApCorrMap(other._apCorrMap))
111 _wcs(_cloneWcs(other._wcs)),
113 _calib(_cloneCalib(other._calib)),
114 _detector(other._detector),
115 _validPolygon(other._validPolygon),
116 _filter(other._filter),
118 _coaddInputs(other._coaddInputs),
119 _apCorrMap(_cloneApCorrMap(other._apCorrMap))
125 if (&other !=
this) {
159 data.
metadata->set(
"AR_HDU", 5,
"HDU containing the archive used to store ancillary objects");
162 data.
metadata->set(
"COADD_INPUTS_ID", coaddInputsId,
"archive ID for coadd inputs catalogs");
166 data.
metadata->set(
"AP_CORR_MAP_ID", apCorrMapId,
"archive ID for aperture correction map");
170 data.
metadata->set(
"PSF_ID", psfId,
"archive ID for the Exposure's main Psf");
174 data.
metadata->set(
"WCS_ID", wcsId,
"archive ID for the Exposure's main Wcs");
178 data.
metadata->set(
"VALID_POLYGON_ID", polygonId,
"archive ID for the Exposure's valid polygon");
188 newWcs->shiftReferencePixel(-xy0.getX(), -xy0.getY() );
205 data.
imageMetadata->set(
"LTV1", static_cast<double>(-xy0.getX()));
206 data.
imageMetadata->set(
"LTV2", static_cast<double>(-xy0.getY()));
236 if (!imageMetadata->
exists(
"INHERIT")) {
242 metadata = imageMetadata;
252 int archiveHdu = popInt(*metadata,
"AR_HDU");
255 fitsfile.
setHdu(archiveHdu);
261 int psfId = popInt(*metadata,
"PSF_ID");
264 }
catch (pex::exceptions::NotFoundError & err) {
265 LOGLS_WARN(_log,
"Could not read PSF; setting to null: " << err.what());
267 int wcsId = popInt(*metadata,
"WCS_ID");
269 auto archiveWcs = archive.
get<
Wcs>(wcsId);
273 LOGLS_INFO(_log,
"Empty WCS extension, using FITS header");
275 }
catch (pex::exceptions::NotFoundError & err) {
276 auto msg = str(
boost::format(
"Could not read WCS extension; setting to null: %s") % err.what());
278 msg +=
" ; using WCS from FITS header";
282 int coaddInputsId = popInt(*metadata,
"COADD_INPUTS_ID");
285 }
catch (pex::exceptions::NotFoundError & err) {
286 LOGLS_WARN(_log,
"Could not read CoaddInputs; setting to null: " << err.what());
288 int apCorrMapId = popInt(*metadata,
"AP_CORR_MAP_ID");
291 }
catch (pex::exceptions::NotFoundError & err) {
292 LOGLS_WARN(_log,
"Could not read ApCorrMap; setting to null: " << err.what());
294 int validPolygonId = popInt(*metadata,
"VALID_POLYGON_ID");
297 }
catch (pex::exceptions::NotFoundError & err) {
298 LOGLS_WARN(_log,
"Could not read ValidPolygon; setting to null: " << err.what());
boost::shared_ptr< ApCorrMap > _apCorrMap
boost::shared_ptr< detection::Psf > getPsf() const
Return the exposure's point-spread function.
table::Key< std::string > name
void _finishWriteFits(fits::Fits &fitsfile, FitsWriteData const &data) const
Write any additional non-image HDUs to a FITS file.
boost::shared_ptr< daf::base::PropertyList > imageMetadata
Class for storing ordered metadata with comments.
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
static boost::shared_ptr< Wcs > _cloneWcs(boost::shared_ptr< Wcs const > wcs)
bool hasValidPolygon() const
Does this exposure have a valid Polygon.
Implementation of the WCS standard for a any projection.
bool hasCoaddInputs() const
Does this exposure have coadd provenance catalogs?
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
boost::shared_ptr< cameraGeom::Detector const > getDetector() const
Return the exposure's Detector information.
static boost::shared_ptr< Calib > _cloneCalib(boost::shared_ptr< Calib const > calib)
table::Key< table::Array< Kernel::Pixel > > image
lsst::daf::base::PropertySet PropertySet
boost::shared_ptr< daf::base::PropertySet > _metadata
ExposureInfo & operator=(ExposureInfo const &other)
Assignment; deep-copies all components except the metadata.
boost::shared_ptr< Wcs > makeWcs(boost::shared_ptr< lsst::daf::base::PropertySet > const &fitsMetadata, bool stripMetadata=false)
#define LOGLS_WARN(logger, message)
boost::shared_ptr< geom::polygon::Polygon const > getValidPolygon() const
Return the valid Polygon.
A struct passed back and forth between Exposure and ExposureInfo when writing FITS files...
ExposureInfo(boost::shared_ptr< Wcs const > const &wcs=boost::shared_ptr< Wcs const >(), boost::shared_ptr< detection::Psf const > const &psf=boost::shared_ptr< detection::Psf const >(), boost::shared_ptr< Calib const > const &calib=boost::shared_ptr< Calib const >(), boost::shared_ptr< cameraGeom::Detector const > const &detector=boost::shared_ptr< cameraGeom::Detector const >(), boost::shared_ptr< geom::polygon::Polygon const > const &polygon=boost::shared_ptr< geom::polygon::Polygon const >(), Filter const &filter=Filter(), boost::shared_ptr< daf::base::PropertySet > const &metadata=boost::shared_ptr< daf::base::PropertySet >(), boost::shared_ptr< CoaddInputs > const &coaddInputs=boost::shared_ptr< CoaddInputs >(), boost::shared_ptr< ApCorrMap > const &apCorrMap=boost::shared_ptr< ApCorrMap >())
Construct an ExposureInfo from its various components.
boost::shared_ptr< detection::Psf > _psf
boost::shared_ptr< Wcs > getWcs()
Return the coordinate system of the exposure.
void writeFits(fits::Fits &fitsfile) const
Write the archive to an already-open FITS object.
boost::shared_ptr< daf::base::PropertyList > maskMetadata
boost::shared_ptr< Wcs > _wcs
boost::shared_ptr< ApCorrMap > getApCorrMap()
Return the exposure's aperture correction map (null pointer if !hasApCorrMap())
Holds an integer identifier for an LSST filter.
void setHdu(int hdu, bool relative=false)
Set the current HDU.
int stripCalibKeywords(boost::shared_ptr< lsst::daf::base::PropertySet > metadata)
boost::shared_ptr< cameraGeom::Detector const > _detector
static boost::shared_ptr< ApCorrMap > _cloneApCorrMap(boost::shared_ptr< ApCorrMap const > apCorrMap)
Filter getFilter() const
Return the exposure's filter.
bool hasPsf() const
Does this exposure have a Psf?
void setCalib(boost::shared_ptr< Calib const > calib)
Set the Exposure's Calib object.
bool hasWcs() const
Does this exposure have a Wcs?
void _readFits(fits::Fits &fitsfile, boost::shared_ptr< daf::base::PropertySet > metadata, boost::shared_ptr< daf::base::PropertySet > imageMetadata)
Read from a FITS file and metadata.
Class for storing generic metadata.
table::io::OutputArchive archive
int put(Persistable const *obj, bool permissive=false)
Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArc...
boost::shared_ptr< daf::base::PropertySet > getMetadata() const
Return flexible metadata.
int stripFilterKeywords(boost::shared_ptr< lsst::daf::base::PropertySet > metadata)
bool hasApCorrMap() const
Return true if the exposure has an aperture correction map.
boost::shared_ptr< Calib > _calib
boost::shared_ptr< CoaddInputs > getCoaddInputs() const
Return a pair of catalogs that record the inputs, if this Exposure is a coadd (otherwise null)...
Include files required for standard LSST Exception handling.
boost::shared_ptr< daf::base::PropertyList > 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.
boost::shared_ptr< daf::base::PropertyList > varianceMetadata
boost::shared_ptr< Calib > getCalib()
Return the exposure's photometric calibration.
daf::base::PropertySet & _metadata
bool exists(std::string const &name) const
bool hasDetector() const
Does this exposure have Detector information?
#define LOGLS_INFO(logger, message)
FitsWriteData _startWriteFits(geom::Point2I const &xy0=geom::Point2I()) const
Start the process of writing an exposure to FITS.
boost::shared_ptr< geom::polygon::Polygon const > _validPolygon
boost::shared_ptr< CoaddInputs > _coaddInputs