37 using namespace std::string_literals;
51 typehandling::Key<std::string, std::shared_ptr<geom::SkyWcs const>>
const ExposureInfo::KEY_WCS =
52 typehandling::makeKey<std::shared_ptr<geom::SkyWcs const>>(
"SKYWCS"s);
54 bool ExposureInfo::hasWcs()
const {
return hasComponent(KEY_WCS); }
59 typehandling::makeKey<std::shared_ptr<detection::Psf const>>(
"PSF"s);
61 bool ExposureInfo::hasPsf()
const {
return hasComponent(KEY_PSF); }
66 typehandling::makeKey<std::shared_ptr<PhotoCalib const>>(
"PHOTOCALIB"s);
68 bool ExposureInfo::hasPhotoCalib()
const {
return hasComponent(KEY_PHOTO_CALIB); }
70 return getComponent(KEY_PHOTO_CALIB);
77 typehandling::makeKey<std::shared_ptr<cameraGeom::Detector const>>(
"DETECTOR"s);
79 bool ExposureInfo::hasDetector()
const {
return hasComponent(KEY_DETECTOR); }
81 return getComponent(KEY_DETECTOR);
84 setComponent(KEY_DETECTOR,
detector);
88 ExposureInfo::KEY_VALID_POLYGON =
89 typehandling::makeKey<std::shared_ptr<geom::polygon::Polygon const>>(
"VALID_POLYGON"s);
91 bool ExposureInfo::hasValidPolygon()
const {
return hasComponent(KEY_VALID_POLYGON); }
93 return getComponent(KEY_VALID_POLYGON);
96 setComponent(KEY_VALID_POLYGON, polygon);
100 typehandling::makeKey<std::shared_ptr<CoaddInputs const>>(
"COADD_INPUTS"s);
102 bool ExposureInfo::hasCoaddInputs()
const {
return hasComponent(KEY_COADD_INPUTS); }
104 setComponent(KEY_COADD_INPUTS, coaddInputs);
107 return getComponent(KEY_COADD_INPUTS);
111 typehandling::makeKey<std::shared_ptr<ApCorrMap const>>(
"AP_CORR_MAP"s);
113 bool ExposureInfo::hasApCorrMap()
const {
return hasComponent(KEY_AP_CORR_MAP); }
116 setComponent(KEY_AP_CORR_MAP,
apCorrMap);
120 ExposureInfo::KEY_TRANSMISSION_CURVE =
121 typehandling::makeKey<std::shared_ptr<TransmissionCurve const>>(
"TRANSMISSION_CURVE"s);
123 bool ExposureInfo::hasTransmissionCurve()
const {
return hasComponent(KEY_TRANSMISSION_CURVE); }
125 return getComponent(KEY_TRANSMISSION_CURVE);
128 setComponent(KEY_TRANSMISSION_CURVE, tc);
148 typehandling::makeKey<std::shared_ptr<FilterLabel const>>(
"FILTER"s);
149 bool ExposureInfo::hasFilterLabel()
const {
return hasComponent(KEY_FILTER); }
152 setComponent(KEY_FILTER, label);
155 int ExposureInfo::getFitsSerializationVersion() {
164 std::string const& ExposureInfo::getFitsSerializationVersionName() {
173 return std::make_shared<ApCorrMap>(*
apCorrMap);
188 : _metadata(metadata ? metadata
189 :
std::shared_ptr<daf::base::PropertySet>(new daf::base::PropertyList())),
191 _components(
std::make_unique<MapClass>()) {
210 : _metadata(
other._metadata),
211 _visitInfo(
other._visitInfo),
213 _components(
std::make_unique<MapClass>(*(
other._components))) {
214 if (copyMetadata) _metadata = _metadata->deepCopy();
218 if (&
other !=
this) {
219 _metadata =
other._metadata;
220 _visitInfo =
other._visitInfo;
222 _components = std::make_unique<MapClass>(*(
other._components));
235 int componentId =
data.archive.put(
object);
236 data.metadata->set(
key, componentId, comment);
240 int ExposureInfo::_addToArchive(FitsWriteData&
data,
245 int componentId =
data.archive.put(
object);
246 data.metadata->set(
key, componentId, comment);
256 return "archive ID for generic component '" + mapKey +
"'";
260 ExposureInfo::FitsWriteData ExposureInfo::_startWriteFits(
lsst::geom::Point2I const& xy0)
const {
263 data.metadata.reset(
new daf::base::PropertyList());
264 data.imageMetadata.reset(
new daf::base::PropertyList());
265 data.maskMetadata =
data.imageMetadata;
266 data.varianceMetadata =
data.imageMetadata;
278 data.metadata->set(
"AR_HDU", 5,
"HDU (1-indexed) containing the archive used to store ancillary objects");
279 for (
auto const& keyValue : *_components) {
283 if (
object && object->isPersistable()) {
288 int id = _addToArchive(
data,
object, _getOldHeaderKey(
key), comment);
289 data.metadata->set(_getNewHeaderKey(
key),
id, comment);
302 auto newWcs =
getWcs()->copyAtShiftedPixelOrigin(shift);
305 wcsMetadata = newWcs->getFitsMetadata(
true);
306 }
catch (pex::exceptions::RuntimeError
const&) {
310 data.imageMetadata->combine(newWcs->getFitsMetadata(
true));
320 data.imageMetadata->set(
"LTV1",
static_cast<double>(-xy0.getX()));
321 data.imageMetadata->set(
"LTV2",
static_cast<double>(-xy0.getY()));
336 void ExposureInfo::_finishWriteFits(fits::Fits& fitsfile, FitsWriteData
const&
data)
const {
337 data.archive.writeFits(fitsfile);
LSST DM logging module built on log4cxx.
#define LOG_GET(logger)
Returns a Log object associated with logger.
Implementation of the Photometric Calibration class.
ItemVariant const * other
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.
std::shared_ptr< daf::base::PropertySet > getMetadata() const
Return flexible metadata.
ExposureInfo & operator=(ExposureInfo const &other)
Assignment; shares all components.
void setFilter(Filter const &filter)
Set the exposure's filter.
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 >(), 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.
void setValidPolygon(std::shared_ptr< geom::polygon::Polygon const > polygon)
Set the exposure's valid Polygon.
void setWcs(std::shared_ptr< geom::SkyWcs const > wcs)
Set the WCS of the exposure.
std::shared_ptr< image::VisitInfo const > getVisitInfo() const
Return the exposure's visit info.
void setApCorrMap(std::shared_ptr< ApCorrMap const > apCorrMap)
Set the exposure's aperture correction map (null pointer if !hasApCorrMap())
std::shared_ptr< cameraGeom::Detector const > getDetector() const
Return the exposure's Detector information.
void setPhotoCalib(std::shared_ptr< PhotoCalib const > photoCalib)
Set the Exposure's PhotoCalib object.
void setCoaddInputs(std::shared_ptr< CoaddInputs const > coaddInputs)
Set the exposure's coadd provenance catalogs.
void setDetector(std::shared_ptr< cameraGeom::Detector const > detector)
Set the exposure's Detector information.
void setPsf(std::shared_ptr< detection::Psf const > psf)
Set the exposure's point-spread function.
void initApCorrMap()
Set the exposure's aperture correction map to a new, empty map.
std::shared_ptr< geom::SkyWcs const > getWcs() const
Return the WCS of the exposure.
bool hasDetector() const
Does this exposure have Detector information?
static std::string const & getFitsSerializationVersionName()
Get the version of FITS serialization version info name.
void setTransmissionCurve(std::shared_ptr< TransmissionCurve const > tc)
Set the exposure's transmission curve.
A group of labels for a filter in an exposure or coadd.
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.
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.
Filter makeFilter(FilterLabel const &label)
Convert a FilterLabel back to an old-style Filter.
std::shared_ptr< FilterLabel > makeFilterLabel(Filter const &filter)
Convert an old-style Filter to a FilterLabel.
std::string const & getName() const noexcept
Return a filter's name.
Extent< double, 2 > Extent2D
A base class for image defects.
table::Key< int > detector
Key< int > transmissionCurve