Commit f0b00e8c83b053cf9a52f37a1f0347e1e1217dba
1 parent
974973c0
put GFits file as class member (and save only once)
Showing
2 changed files
with
11 additions
and
17 deletions
src/ctselect/ctselect.cpp
| ... | ... | @@ -124,6 +124,12 @@ void ctselect::run(void) |
| 124 | 124 | // Append GTI to FITS file |
| 125 | 125 | append_gti(); |
| 126 | 126 | |
| 127 | + // Save output FITS file | |
| 128 | + m_file.saveto(m_outfile, clobber()); | |
| 129 | + | |
| 130 | + // Close FITS file | |
| 131 | + m_file.close(); | |
| 132 | + | |
| 127 | 133 | // Write separator into logger |
| 128 | 134 | if (logTerse()) |
| 129 | 135 | log << std::endl; |
| ... | ... | @@ -212,21 +218,15 @@ void ctselect::select(void) |
| 212 | 218 | log << " FITS filename .............: " << expression << std::endl; |
| 213 | 219 | |
| 214 | 220 | // Open FITS file |
| 215 | - GFits file(expression); | |
| 221 | + m_file.open(expression); | |
| 216 | 222 | |
| 217 | 223 | // Log selected FITS file |
| 218 | 224 | if (logExplicit()) { |
| 219 | 225 | log << std::endl; |
| 220 | 226 | log.header1("FITS file content after selection"); |
| 221 | - log << file << std::endl; | |
| 227 | + log << m_file << std::endl; | |
| 222 | 228 | } |
| 223 | 229 | |
| 224 | - // Save output FITS file | |
| 225 | - file.saveto(m_outfile, clobber()); | |
| 226 | - | |
| 227 | - // Close FITS file | |
| 228 | - file.close(); | |
| 229 | - | |
| 230 | 230 | // Return |
| 231 | 231 | return; |
| 232 | 232 | } |
| ... | ... | @@ -247,23 +247,16 @@ void ctselect::append_gti(void) |
| 247 | 247 | tstop.met(m_tmax); |
| 248 | 248 | gti.add(tstart, tstop); |
| 249 | 249 | |
| 250 | - // Re-open FITS file | |
| 251 | - GFits file(m_outfile); | |
| 252 | - | |
| 253 | 250 | // Write GTI |
| 254 | - gti.write(&file); | |
| 251 | + gti.write(&m_file); | |
| 255 | 252 | |
| 256 | 253 | // Log final FITS file |
| 257 | 254 | if (logExplicit()) { |
| 258 | 255 | log << std::endl; |
| 259 | 256 | log.header1("Final FITS file content"); |
| 260 | - log << file << std::endl; | |
| 257 | + log << m_file << std::endl; | |
| 261 | 258 | } |
| 262 | 259 | |
| 263 | - // Save and close file | |
| 264 | - file.save(); | |
| 265 | - file.close(); | |
| 266 | - | |
| 267 | 260 | // Return |
| 268 | 261 | return; |
| 269 | 262 | } | ... | ... |