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"
69 namespace afwForm = lsst::afw::formatters;
71 namespace dafBase = lsst::daf::base;
72 namespace dafPersist = lsst::daf::persistence;
73 namespace pexPolicy = lsst::pex::policy;
74 namespace pexExcept = lsst::pex::exceptions;
82 dafPersist::Formatter(typeid(this)) {
96 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Persisting non-Wcs");
99 LOGL_DEBUG(_log,
"WcsFormatter write BoostStorage");
105 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Unrecognized Storage for Wcs");
114 LOGL_DEBUG(_log,
"WcsFormatter read BoostStorage");
121 LOGL_DEBUG(_log,
"WcsFormatter read FitsStorage");
123 int hdu = additionalData->get<
int>(
"hdu", 0);
130 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Unrecognized Storage for Wcs");
137 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Unexpected call to update for Wcs");
147 wcsProps->add(
"NAXIS", wcs.
_wcsInfo[0].naxis,
"number of data axes");
150 if (strncmp(wcs.
_wcsInfo[0].radesys,
"ICRS", 4) != 0) {
151 wcsProps->add(
"EQUINOX", wcs.
_wcsInfo[0].equinox,
"Equinox of coordinates");
153 wcsProps->add(
"RADESYS", std::string(wcs.
_wcsInfo[0].radesys),
"Coordinate system for equinox");
154 wcsProps->add(
"CRPIX1", wcs.
_wcsInfo[0].crpix[0],
"WCS Coordinate reference pixel");
155 wcsProps->add(
"CRPIX2", wcs.
_wcsInfo[0].crpix[1],
"WCS Coordinate reference pixel");
156 wcsProps->add(
"CD1_1", wcs.
_wcsInfo[0].cd[0],
"WCS Coordinate scale matrix");
157 wcsProps->add(
"CD1_2", wcs.
_wcsInfo[0].cd[1],
"WCS Coordinate scale matrix");
158 wcsProps->add(
"CD2_1", wcs.
_wcsInfo[0].cd[2],
"WCS Coordinate scale matrix");
159 wcsProps->add(
"CD2_2", wcs.
_wcsInfo[0].cd[3],
"WCS Coordinate scale matrix");
160 wcsProps->add(
"CRVAL1", wcs.
_wcsInfo[0].crval[0],
"WCS Ref value (RA in decimal degrees)");
161 wcsProps->add(
"CRVAL2", wcs.
_wcsInfo[0].crval[1],
"WCS Ref value (DEC in decimal degrees)");
162 wcsProps->add(
"CUNIT1", std::string(wcs.
_wcsInfo[0].cunit[0]));
163 wcsProps->add(
"CUNIT2", std::string(wcs.
_wcsInfo[0].cunit[1]));
167 for (
int i = 0; i != wcs.
_wcsInfo[0].npv; ++i) {
168 auto const pv = wcs.
_wcsInfo[0].pv[i];
169 int const ii = pv.i > 0 ? pv.i : (wcs.
_wcsInfo[0].lat + 1);
171 sprintf(key,
"PV%d_%d", ii, pv.m);
172 wcsProps->add(key, pv.value);
177 wcsProps->add(
"CTYPE1", ctype1,
"WCS Coordinate type");
178 wcsProps->add(
"CTYPE2", ctype2,
"WCS Coordinate type");
183 template <
class Archive>
186 LOGL_DEBUG(_log,
"WcsFormatter delegateSerialize start");
189 throw LSST_EXCEPT(pexExcept::RuntimeError,
"Serializing non-Wcs");
199 if (Archive::is_loading::value) {
201 reinterpret_cast<wcsprm*
>(malloc(ip->
_nWcsInfo *
sizeof(wcsprm)));
205 for (
int i = 0; i < ip->
_nWcsInfo; ++i) {
207 if (Archive::is_loading::value) {
233 if (Archive::is_loading::value) {
238 LOGL_DEBUG(_log,
"WcsFormatter delegateSerialize end");
std::shared_ptr< Policy > Ptr
Class for storing ordered metadata with comments.
daf_persistence package header file
Include files required for standard LSST Exception handling.
Implementation of the WCS standard for a any projection.
Class for FITS file storage.
table::Key< std::string > ctype2
virtual boost::archive::text_oarchive & getOArchive(void)
Get a boost::serialization archive suitable for output.
boost::shared_ptr< daf::base::PropertyList > readMetadata(std::string const &fileName, int hdu=0, bool strip=false)
Read FITS header.
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
table::Key< table::Array< Kernel::Pixel > > image
LSST DM logging module built on log4cxx.
std::shared_ptr< PropertyList > Ptr
std::shared_ptr< Storage > Ptr
Utilities for working with FITS files.
virtual boost::archive::text_iarchive & getIArchive(void)
Get a boost::serialization archive suitable for input.
lsst::afw::image::Wcs Wcs
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
int _wcshdrCtrl
Controls messages to stderr from wcshdr (0 for none); see wcshdr.h for details.
virtual std::string const & getPath(void)
Return the pathname for the FITS file.
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.
std::shared_ptr< PropertySet > Ptr
#define LOG_GET(logger)
Returns a Log object associated with logger.
table::Key< std::string > ctype1
coord::CoordSystem _coordSystem