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);
131 int ExposureInfo::getFitsSerializationVersion() {
139 std::string const& ExposureInfo::getFitsSerializationVersionName() {
148 return std::make_shared<ApCorrMap>(*
apCorrMap);
164 _metadata(metadata ? metadata
165 :
std::shared_ptr<daf::base::PropertySet>(new daf::base::PropertyList())),
167 _components(
std::make_unique<MapClass>()) {
184 : _filter(
other._filter),
185 _metadata(
other._metadata),
186 _visitInfo(
other._visitInfo),
188 _components(
std::make_unique<MapClass>(*(
other._components))) {
189 if (copyMetadata) _metadata = _metadata->deepCopy();
193 if (&
other !=
this) {
194 _filter =
other._filter;
195 _metadata =
other._metadata;
196 _visitInfo =
other._visitInfo;
198 _components = std::make_unique<MapClass>(*(
other._components));
211 int componentId =
data.archive.put(
object);
212 data.metadata->set(
key, componentId, comment);
216 int ExposureInfo::_addToArchive(FitsWriteData&
data,
221 int componentId =
data.archive.put(
object);
222 data.metadata->set(
key, componentId, comment);
232 return "archive ID for generic component '" + mapKey +
"'";
236 ExposureInfo::FitsWriteData ExposureInfo::_startWriteFits(
lsst::geom::Point2I const& xy0)
const {
239 data.metadata.reset(
new daf::base::PropertyList());
240 data.imageMetadata.reset(
new daf::base::PropertyList());
241 data.maskMetadata =
data.imageMetadata;
242 data.varianceMetadata =
data.imageMetadata;
254 data.metadata->set(
"AR_HDU", 5,
"HDU (1-indexed) containing the archive used to store ancillary objects");
255 for (
auto const& keyValue : *_components) {
259 if (
object && object->isPersistable()) {
264 int id = _addToArchive(
data,
object, _getOldHeaderKey(
key), comment);
265 data.metadata->set(_getNewHeaderKey(
key),
id, comment);
278 auto newWcs =
getWcs()->copyAtShiftedPixelOrigin(shift);
281 wcsMetadata = newWcs->getFitsMetadata(
true);
282 }
catch (pex::exceptions::RuntimeError
const&) {
286 data.imageMetadata->combine(newWcs->getFitsMetadata(
true));
296 data.imageMetadata->set(
"LTV1",
static_cast<double>(-xy0.getX()));
297 data.imageMetadata->set(
"LTV2",
static_cast<double>(-xy0.getY()));
313 void ExposureInfo::_finishWriteFits(fits::Fits& fitsfile, FitsWriteData
const&
data)
const {
314 data.archive.writeFits(fitsfile);