Commit cea4f2ebb556538ab3140586a28da9bcbad10471

Authored by knodlseder
1 parent 9204bcf5

initial FITS file copy code

pyext/ctselect.i
@@ -30,10 +30,14 @@ @@ -30,10 +30,14 @@
30 class ctselect : public GApplication { 30 class ctselect : public GApplication {
31 public: 31 public:
32 // Constructors and destructors 32 // Constructors and destructors
33 - ctselect(void) : GApplication(CTSELECT_NAME, CTSELECT_VERSION) { return; } 33 + ctselect(void);
  34 + ctselect(int argc, char *argv[]);
  35 + ~ctselect(void);
34 36
35 // Methods 37 // Methods
36 - int run(void); 38 + void run(void);
  39 + void get_parameters(void);
  40 + void select(void);
37 }; 41 };
38 42
39 43
src/ctselect/ctselect.cpp
@@ -105,6 +105,9 @@ void ctselect::run(void) @@ -105,6 +105,9 @@ void ctselect::run(void)
105 log << std::endl; 105 log << std::endl;
106 } 106 }
107 107
  108 + // Select events
  109 + select();
  110 +
108 // Return 111 // Return
109 return; 112 return;
110 } 113 }
@@ -134,6 +137,45 @@ void ctselect::get_parameters(void) @@ -134,6 +137,45 @@ void ctselect::get_parameters(void)
134 } 137 }
135 138
136 139
  140 +/***********************************************************************//**
  141 + * @brief Select events
  142 + *
  143 + * @todo An interesting alternative is the fits_select_rows routine which copies
  144 + * the selected rows from one FITS table to another. That's in fact the thing
  145 + * we want to achieve here. The only way to use this routine would be to
  146 + * open 2 FITS files, one for the input data and a fresh one for the output
  147 + * data. The events table would then be copied over using the select routine,
  148 + * any other tables would be copied over directly. The code would look like:
  149 + *
  150 + * GFits infile(m_infile);
  151 + * GFits outfile(m_outfile);
  152 + * for (int extno = 0; extno < infile.size(); ++extno) {
  153 + * GFitsHDU* inhdu = infile.hdu(i);
  154 + * if (inhdu->extname() == "EVENTS") {
  155 + * GFitsHDU* outhdu = inhdu->select("expression");
  156 + * outfile.append_hdu(*outhdu);
  157 + * }
  158 + * else
  159 + * outfile.append_hdu(*inhdu);
  160 + * }
  161 + * outfile.save();
  162 + * outfile.close();
  163 + *
  164 + ***************************************************************************/
  165 +void ctselect::select(void)
  166 +{
  167 + // Open FITS file
  168 + GFits file(m_infile);
  169 + //std::cout << file << std::endl;
  170 +
  171 + // Save file
  172 + file.saveto(m_outfile, true);
  173 +
  174 + // Return
  175 + return;
  176 +}
  177 +
  178 +
137 /*========================================================================== 179 /*==========================================================================
138 = = 180 = =
139 = Private methods = 181 = Private methods =
src/ctselect/ctselect.hpp
@@ -42,6 +42,7 @@ public: @@ -42,6 +42,7 @@ public:
42 // Methods 42 // Methods
43 void run(void); 43 void run(void);
44 void get_parameters(void); 44 void get_parameters(void);
  45 + void select(void);
45 46
46 protected: 47 protected:
47 // Protected methods 48 // Protected methods