Commit f5e23511 authored by Robert Butora's avatar Robert Butora
Browse files

vlkb: moves header_modif_coordsys into common

parent 0df2f338
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -56,5 +56,8 @@ std::vector<Bounds> calc_bounds(std::string header, std::string skysys_str, std:

std::vector<uint_bounds> calc_overlap(const std::string header, const coordinates coord, int& ov_code);

int header_modif_coordsys(const std::string& skysys_str, const std::string& specsys_str,
      const std::string& pathname);

#endif
+41 −0
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@
#include "math.h" // round() needed
#include "cutout_ostream.hpp" // coordinates needed

#include "fitsfiles.hpp" // header_modif_coordsys needs this

#include <ostream>
//#include <vector>

@@ -170,3 +172,42 @@ std::vector<uint_bounds> calc_overlap(const std::string header, const coordinate
}






void write_previous2(string header, string filename)
{
   std::ofstream out(filename);
   out << header;
}

int header_modif_coordsys(const string& skysys_str, const string& specsys_str, const string& pathname)
{
   LOG_trace(__func__);

   int maxHdu = 1;//FIXME INT_MAX; // read all HDU's

   std::vector<fitsfiles::Hdu> allHdus =
      fitsfiles::fname2hdrstr(pathname, maxHdu);

   for(unsigned int i=0; i<allHdus.size(); i++)
   {
      cerr << "HDU#" << i << endl;

      fitsfiles::Hdu hd = allHdus.at(i);

      write_previous2(hd.m_header, "backup.fitshdu"+ to_string(i) +"header.orig");
      ast::frameset frm_set(hd.m_header);
      frm_set.set_skysystem(skysys_str);
      if(frm_set.has_specframe())
         frm_set.set_specsystem(specsys_str);

      //frm_set.write(cout, hd.m_header);
      frm_set.write2(pathname, i+1);
   }

   return 0;
}

+0 −32
Original line number Diff line number Diff line
@@ -11,9 +11,6 @@
#include "io.hpp"
#include "my_assert.hpp"

#include "ast_frameset.hpp" // FIXME temporarily was moved common/src -> common/include


#include <iostream>
#include <climits> // INT_MAX needed
#include <sstream>
@@ -130,35 +127,6 @@ int header_backup(const string& pathname, bool backup)
}


int header_modif_coordsys(const string& skysys_str, const string& specsys_str, const string& pathname)
{
   LOG_trace(__func__);

   int maxHdu = 1;//FIXME INT_MAX; // read all HDU's

   std::vector<fitsfiles::Hdu> allHdus =
      fitsfiles::fname2hdrstr(pathname, maxHdu);

   for(unsigned int i=0; i<allHdus.size(); i++)
   {
      cerr << "HDU#" << i << endl;

      fitsfiles::Hdu hd = allHdus.at(i);

      write_previous(hd.m_header, "backup.fitshdu"+ to_string(i) +"header.orig");
      ast::frameset frm_set(hd.m_header);
      frm_set.set_skysystem(skysys_str); 
      if(frm_set.has_specframe())
         frm_set.set_specsystem(specsys_str);

      //frm_set.write(cout, hd.m_header);
      frm_set.write2(pathname, i+1);
   }

   return 0;
}




//---------------------------------------------------------------------
Loading