From cea4f2ebb556538ab3140586a28da9bcbad10471 Mon Sep 17 00:00:00 2001 From: knodlseder <> Date: Sun, 14 Nov 2010 01:49:54 +0000 Subject: [PATCH] initial FITS file copy code --- pyext/ctselect.i | 8 ++++++-- src/ctselect/ctselect.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ src/ctselect/ctselect.hpp | 1 + 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/pyext/ctselect.i b/pyext/ctselect.i index 72c9202..32013bb 100644 --- a/pyext/ctselect.i +++ b/pyext/ctselect.i @@ -30,10 +30,14 @@ class ctselect : public GApplication { public: // Constructors and destructors - ctselect(void) : GApplication(CTSELECT_NAME, CTSELECT_VERSION) { return; } + ctselect(void); + ctselect(int argc, char *argv[]); + ~ctselect(void); // Methods - int run(void); + void run(void); + void get_parameters(void); + void select(void); }; diff --git a/src/ctselect/ctselect.cpp b/src/ctselect/ctselect.cpp index 4bc24e2..2cccdc1 100644 --- a/src/ctselect/ctselect.cpp +++ b/src/ctselect/ctselect.cpp @@ -105,6 +105,9 @@ void ctselect::run(void) log << std::endl; } + // Select events + select(); + // Return return; } @@ -134,6 +137,45 @@ void ctselect::get_parameters(void) } +/***********************************************************************//** + * @brief Select events + * + * @todo An interesting alternative is the fits_select_rows routine which copies + * the selected rows from one FITS table to another. That's in fact the thing + * we want to achieve here. The only way to use this routine would be to + * open 2 FITS files, one for the input data and a fresh one for the output + * data. The events table would then be copied over using the select routine, + * any other tables would be copied over directly. The code would look like: + * + * GFits infile(m_infile); + * GFits outfile(m_outfile); + * for (int extno = 0; extno < infile.size(); ++extno) { + * GFitsHDU* inhdu = infile.hdu(i); + * if (inhdu->extname() == "EVENTS") { + * GFitsHDU* outhdu = inhdu->select("expression"); + * outfile.append_hdu(*outhdu); + * } + * else + * outfile.append_hdu(*inhdu); + * } + * outfile.save(); + * outfile.close(); + * + ***************************************************************************/ +void ctselect::select(void) +{ + // Open FITS file + GFits file(m_infile); + //std::cout << file << std::endl; + + // Save file + file.saveto(m_outfile, true); + + // Return + return; +} + + /*========================================================================== = = = Private methods = diff --git a/src/ctselect/ctselect.hpp b/src/ctselect/ctselect.hpp index bf0b1d7..1e35123 100644 --- a/src/ctselect/ctselect.hpp +++ b/src/ctselect/ctselect.hpp @@ -42,6 +42,7 @@ public: // Methods void run(void); void get_parameters(void); + void select(void); protected: // Protected methods -- libgit2 0.21.4