39 # define __attribute__(x)
46 #include <boost/archive/binary_iarchive.hpp>
47 #include <boost/archive/binary_oarchive.hpp>
48 #include <boost/archive/text_iarchive.hpp>
49 #include <boost/archive/text_oarchive.hpp>
52 #include "wcslib/wcs.h"
68 namespace afwForm = lsst::afw::formatters;
70 namespace dafBase = lsst::daf::base;
71 namespace dafPersist = lsst::daf::persistence;
72 namespace pexPolicy = lsst::pex::policy;
73 namespace pexExcept = lsst::pex::exceptions;
81 dafPersist::Formatter(typeid(this)) {
95 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Persisting non-Wcs");
98 LOGL_DEBUG(_log,
"WcsFormatter write BoostStorage");
104 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Unrecognized Storage for Wcs");
113 LOGL_DEBUG(_log,
"WcsFormatter read BoostStorage");
120 LOGL_DEBUG(_log,
"WcsFormatter read FitsStorage");
122 int hdu = additionalData->get<
int>(
"hdu", 0);
129 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Unrecognized Storage for Wcs");
136 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Unexpected call to update for Wcs");
146 wcsProps->add(
"NAXIS", wcs.
_wcsInfo[0].naxis,
"number of data axes");
149 if (strncmp(wcs.
_wcsInfo[0].radesys,
"ICRS", 4) != 0) {
150 wcsProps->add(
"EQUINOX", wcs.
_wcsInfo[0].equinox,
"Equinox of coordinates");
152 wcsProps->add(
"RADESYS", std::string(wcs.
_wcsInfo[0].radesys),
"Coordinate system for equinox");
153 wcsProps->add(
"CRPIX1", wcs.
_wcsInfo[0].crpix[0],
"WCS Coordinate reference pixel");
154 wcsProps->add(
"CRPIX2", wcs.
_wcsInfo[0].crpix[1],
"WCS Coordinate reference pixel");
155 wcsProps->add(
"CD1_1", wcs.
_wcsInfo[0].cd[0],
"WCS Coordinate scale matrix");
156 wcsProps->add(
"CD1_2", wcs.
_wcsInfo[0].cd[1],
"WCS Coordinate scale matrix");
157 wcsProps->add(
"CD2_1", wcs.
_wcsInfo[0].cd[2],
"WCS Coordinate scale matrix");
158 wcsProps->add(
"CD2_2", wcs.
_wcsInfo[0].cd[3],
"WCS Coordinate scale matrix");
159 wcsProps->add(
"CRVAL1", wcs.
_wcsInfo[0].crval[0],
"WCS Ref value (RA in decimal degrees)");
160 wcsProps->add(
"CRVAL2", wcs.
_wcsInfo[0].crval[1],
"WCS Ref value (DEC in decimal degrees)");
161 wcsProps->add(
"CUNIT1", std::string(wcs.
_wcsInfo[0].cunit[0]));
162 wcsProps->add(
"CUNIT2", std::string(wcs.
_wcsInfo[0].cunit[1]));
166 for (
int i = 0; i != wcs.
_wcsInfo[0].npv; ++i) {
167 auto const pv = wcs.
_wcsInfo[0].pv[i];
168 int const ii = pv.i > 0 ? pv.i : (wcs.
_wcsInfo[0].lat + 1);
170 sprintf(key,
"PV%d_%d", ii, pv.m);
171 wcsProps->add(key, pv.value);
176 wcsProps->add(
"CTYPE1", ctype1,
"WCS Coordinate type");
177 wcsProps->add(
"CTYPE2", ctype2,
"WCS Coordinate type");
182 template <
class Archive>
185 LOGL_DEBUG(_log,
"WcsFormatter delegateSerialize start");
188 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Serializing non-Wcs");
198 if (Archive::is_loading::value) {
200 reinterpret_cast<wcsprm*
>(malloc(ip->
_nWcsInfo *
sizeof(wcsprm)));
204 for (
int i = 0; i < ip->
_nWcsInfo; ++i) {
206 if (Archive::is_loading::value) {
232 if (Archive::is_loading::value) {
237 LOGL_DEBUG(_log,
"WcsFormatter delegateSerialize end");
std::shared_ptr< Storage > Ptr
std::shared_ptr< PropertySet > Ptr
#define LOGL_DEBUG(logger, message...)
Class for storing ordered metadata with comments.
daf_persistence package header file
virtual boost::archive::text_iarchive & getIArchive(void)
virtual std::string const & getPath(void)
std::shared_ptr< Policy > Ptr
Implementation of the WCS standard for a any projection.
Class for FITS file storage.
table::Key< std::string > ctype2
table::Key< table::Array< Kernel::Pixel > > image
std::shared_ptr< PropertyList > Ptr
lsst::afw::image::Wcs Wcs
#define LSST_EXCEPT(type,...)
virtual boost::archive::text_oarchive & getOArchive(void)
boost::shared_ptr< daf::base::PropertySet > readMetadata(std::string const &fileName, int hdu=0, bool strip=false)
Return the metadata (header entries) from a FITS file.
int _wcshdrCtrl
Controls messages to stderr from wcshdr (0 for none); see wcshdr.h for details.
int _relax
Degree of permissiveness for wcspih (0 for strict); see wcshdr.h for details.
int _wcsfixCtrl
Do potentially unsafe translations of non-standard unit strings? 0/1 = no/yes.
Class for boost::serialization storage.
Base class for all persistable classes.
Include files required for standard LSST Exception handling.
table::Key< std::string > ctype1
coord::CoordSystem _coordSystem