39 # define __attribute__(x)
44 #include <boost/archive/binary_iarchive.hpp>
45 #include <boost/archive/binary_oarchive.hpp>
46 #include <boost/archive/text_iarchive.hpp>
47 #include <boost/archive/text_oarchive.hpp>
50 #include "wcslib/wcs.h"
63 static void execTrace(std::string s,
int level =
EXEC_TRACE) {
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)) {
91 execTrace(
"WcsFormatter write start");
95 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Persisting non-Wcs");
98 execTrace(
"WcsFormatter write BoostStorage");
101 execTrace(
"WcsFormatter write end");
104 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Unrecognized Storage for Wcs");
110 execTrace(
"WcsFormatter read start");
113 execTrace(
"WcsFormatter read BoostStorage");
116 execTrace(
"WcsFormatter read end");
120 execTrace(
"WcsFormatter read FitsStorage");
122 int hdu = additionalData->get<
int>(
"hdu", 0);
126 execTrace(
"WcsFormatter read end");
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");
147 wcsProps->add(
"EQUINOX", wcs.
_wcsInfo[0].equinox,
"Equinox of coordinates");
148 wcsProps->add(
"RADESYS", std::string(wcs.
_wcsInfo[0].radesys),
"Coordinate system for equinox");
149 wcsProps->add(
"CRPIX1", wcs.
_wcsInfo[0].crpix[0],
"WCS Coordinate reference pixel");
150 wcsProps->add(
"CRPIX2", wcs.
_wcsInfo[0].crpix[1],
"WCS Coordinate reference pixel");
151 wcsProps->add(
"CD1_1", wcs.
_wcsInfo[0].cd[0],
"WCS Coordinate scale matrix");
152 wcsProps->add(
"CD1_2", wcs.
_wcsInfo[0].cd[1],
"WCS Coordinate scale matrix");
153 wcsProps->add(
"CD2_1", wcs.
_wcsInfo[0].cd[2],
"WCS Coordinate scale matrix");
154 wcsProps->add(
"CD2_2", wcs.
_wcsInfo[0].cd[3],
"WCS Coordinate scale matrix");
155 wcsProps->add(
"CRVAL1", wcs.
_wcsInfo[0].crval[0],
"WCS Ref value (RA in decimal degrees)");
156 wcsProps->add(
"CRVAL2", wcs.
_wcsInfo[0].crval[1],
"WCS Ref value (DEC in decimal degrees)");
157 wcsProps->add(
"CUNIT1", std::string(wcs.
_wcsInfo[0].cunit[0]));
158 wcsProps->add(
"CUNIT2", std::string(wcs.
_wcsInfo[0].cunit[1]));
162 for (
int i = 0; i != wcs.
_wcsInfo[0].npv; ++i) {
163 auto const pv = wcs.
_wcsInfo[0].pv[i];
164 int const ii = pv.i > 0 ? pv.i : (wcs.
_wcsInfo[0].lat + 1);
166 sprintf(key,
"PV%d_%d", ii, pv.m);
167 wcsProps->add(key, pv.value);
172 wcsProps->add(
"CTYPE1", ctype1,
"WCS Coordinate type");
173 wcsProps->add(
"CTYPE2", ctype2,
"WCS Coordinate type");
178 template <
class Archive>
181 execTrace(
"WcsFormatter delegateSerialize start");
184 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Serializing non-Wcs");
194 if (Archive::is_loading::value) {
196 reinterpret_cast<wcsprm*
>(malloc(ip->
_nWcsInfo *
sizeof(wcsprm)));
200 for (
int i = 0; i < ip->
_nWcsInfo; ++i) {
202 if (Archive::is_loading::value) {
228 if (Archive::is_loading::value) {
233 execTrace(
"WcsFormatter delegateSerialize end");
Class for storing ordered metadata with comments.
Include files required for standard LSST Exception handling.
daf_persistence package header file
virtual boost::archive::text_iarchive & getIArchive(void)
boost::shared_ptr< PropertySet > Ptr
virtual std::string const & getPath(void)
boost::shared_ptr< Policy > Ptr
definition of the Trace messaging facilities
Implementation of the WCS standard for a any projection.
limited backward compatibility to the DC2 run-time trace facilities
Class for FITS file storage.
table::Key< std::string > ctype2
table::Key< table::Array< Kernel::Pixel > > image
boost::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.
boost::shared_ptr< Storage > Ptr
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.
table::Key< std::string > ctype1
coord::CoordSystem _coordSystem