58 void add_hdu(std::string hdu_name, Eigen::DenseBase<Derived> &data) {
60 std::vector<long> naxes{data.cols(), data.rows(), 1, 1};
63 hdus.push_back((
pfits->addImage(hdu_name,DOUBLE_IMG,naxes)));
66 std::valarray<double> temp_data(data.size());
70 for (
int i=0; i<data.rows(); ++i){
71 for (
int j=0; j<data.cols(); ++j) {
74 temp_data[k] = data(i, data.cols() - j - 1);
77 temp_data[k] = data(i,j);
87 hdus.back()->write(first_pixel, temp_data.size(), temp_data);
93 CCfits::ExtHDU& hdu =
pfits->extension(hdu_name);
96 std::valarray<double> contents;
103 long ax1(hdu.axis(0));
104 long ax2(hdu.axis(1));
107 Eigen::MatrixXd data(ax2,ax1);
111 for (Eigen::Index i=0; i<ax2; ++i) {
112 for (Eigen::Index j=0; j<ax1; ++j) {
113 data(i,j) = contents[k];
120 data.rowwise().reverseInPlace();
125 }
catch (CCfits::FITS::NoSuchHDU) {
127 std::exit(EXIT_FAILURE);
132 void add_wcs(hdu_t *hdu, wcs_t &wcs,
const epoch_t epoch) {
134 hdu->addKey(
"EQUINOX", epoch,
"WCS: Equinox");
136 for (Eigen::Index i=0; i<wcs.ctype.size(); ++i) {
137 hdu->addKey(
"CTYPE"+std::to_string(i+1), wcs.ctype[i],
"WCS: Projection Type " +std::to_string(i+1));
138 hdu->addKey(
"CUNIT"+std::to_string(i+1), wcs.cunit[i],
"WCS: Axis Unit " +std::to_string(i+1));
139 hdu->addKey(
"CRVAL"+std::to_string(i+1), wcs.crval[i],
"WCS: Ref Pixel Value " +std::to_string(i+1));
140 hdu->addKey(
"CDELT"+std::to_string(i+1), wcs.cdelt[i],
"WCS: Pixel Scale " +std::to_string(i+1));
142 hdu->addKey(
"CRPIX"+std::to_string(i+1), wcs.crpix[i] + 1,
"WCS: Ref Pixel " +std::to_string(i+1));