30 #define __attribute__(x) 37 #include <boost/archive/binary_iarchive.hpp> 38 #include <boost/archive/binary_oarchive.hpp> 39 #include <boost/archive/text_iarchive.hpp> 40 #include <boost/archive/text_oarchive.hpp> 42 #include "wcslib/wcs.h" 56 LOG_LOGGER _log =
LOG_GET(
"afw.TanWcsFormatter");
61 namespace formatters {
78 LOGL_DEBUG(_log,
"TamWcsFormatter write start");
86 LOGL_DEBUG(_log,
"TanWcsFormatter write BoostStorage");
87 boost->getOArchive() & *ip;
96 LOGL_DEBUG(_log,
"TanWcsFormatter read start");
101 LOGL_DEBUG(_log,
"TanWcsFormatter read BoostStorage");
102 boost->getIArchive() & *ip;
108 LOGL_DEBUG(_log,
"TanWcsFormatter read FitsStorage");
124 template <
class Archive>
129 if (Archive::is_loading::value) {
130 m = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>(rows, cols);
132 for (
int j = 0; j < m.cols(); ++j) {
133 for (
int i = 0; i < m.rows(); ++i) {
141 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>
const&
m) {
142 int order = m.rows();
143 if (m.cols() != order) {
148 wcsProps->add(which +
"_ORDER", static_cast<int>(order));
149 for (
int i = 0; i <= order; ++i) {
150 for (
int j = 0; j <= order; ++j) {
151 double val = m(i, j);
153 wcsProps->add((boost::format(
"%1%_%2%_%3%") % which % i % j).str(), val);
168 wcsProps->add(
"NAXIS", wcs.
_wcsInfo[0].naxis,
"number of data axes");
171 if (strncmp(wcs.
_wcsInfo[0].radesys,
"ICRS", 4) != 0) {
172 wcsProps->add(
"EQUINOX", wcs.
_wcsInfo[0].equinox,
"Equinox of coordinates");
174 wcsProps->add(
"RADESYS",
std::string(wcs.
_wcsInfo[0].radesys),
"Coordinate system for equinox");
175 wcsProps->add(
"CRPIX1", wcs.
_wcsInfo[0].crpix[0],
"WCS Coordinate reference pixel");
176 wcsProps->add(
"CRPIX2", wcs.
_wcsInfo[0].crpix[1],
"WCS Coordinate reference pixel");
177 wcsProps->add(
"CD1_1", wcs.
_wcsInfo[0].cd[0],
"WCS Coordinate scale matrix");
178 wcsProps->add(
"CD1_2", wcs.
_wcsInfo[0].cd[1],
"WCS Coordinate scale matrix");
179 wcsProps->add(
"CD2_1", wcs.
_wcsInfo[0].cd[2],
"WCS Coordinate scale matrix");
180 wcsProps->add(
"CD2_2", wcs.
_wcsInfo[0].cd[3],
"WCS Coordinate scale matrix");
181 wcsProps->add(
"CRVAL1", wcs.
_wcsInfo[0].crval[0],
"WCS Ref value (RA in decimal degrees)");
182 wcsProps->add(
"CRVAL2", wcs.
_wcsInfo[0].crval[1],
"WCS Ref value (DEC in decimal degrees)");
195 if (wcs._hasDistortion) {
196 if (ctype1.
rfind(
"-SIP") == std::string::npos) {
199 if (ctype2.
rfind(
"-SIP") == std::string::npos) {
202 encodeSipHeader(wcsProps,
"A", wcs._sipA);
203 encodeSipHeader(wcsProps,
"B", wcs._sipB);
204 encodeSipHeader(wcsProps,
"AP", wcs._sipAp);
205 encodeSipHeader(wcsProps,
"BP", wcs._sipBp);
207 wcsProps->add(
"CTYPE1", ctype1,
"WCS Coordinate type");
208 wcsProps->add(
"CTYPE2", ctype2,
"WCS Coordinate type");
213 template <
class Archive>
215 LOGL_DEBUG(_log,
"TanWcsFormatter delegateSerialize start");
226 ar & ip->_hasDistortion;
228 if (ip->_hasDistortion) {
236 if (Archive::is_loading::value) {
237 ip->
_wcsInfo =
reinterpret_cast<wcsprm*
>(malloc(ip->
_nWcsInfo *
sizeof(wcsprm)));
240 for (
int i = 0; i < ip->
_nWcsInfo; ++i) {
242 if (Archive::is_loading::value) {
266 if (Archive::is_loading::value) {
271 LOGL_DEBUG(_log,
"TanWcsFormatter delegateSerialize end");
table::Key< std::string > ctype2
#define LOGL_DEBUG(logger, message...)
std::shared_ptr< daf::base::PropertyList > readMetadata(std::string const &fileName, int hdu=DEFAULT_HDU, bool strip=false)
Read FITS header.
A base class for image defects.
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
T dynamic_pointer_cast(T... args)
#define LSST_EXCEPT(type,...)
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.
table::Key< std::string > ctype1
coord::CoordSystem _coordSystem
const int DEFAULT_HDU
Specify that the default HDU should be read.