Commit 82b798bed5ff24c39a5ed547b742252a67af4d12
1 parent
320e8a1f
Use GFilename in read/write/load/save methods
Showing
17 changed files
with
157 additions
and
107 deletions
inst/cta/include/GCTAAeff2D.hpp
| ... | ... | @@ -75,7 +75,7 @@ public: |
| 75 | 75 | // Methods |
| 76 | 76 | const GCTAResponseTable& table(void) const; |
| 77 | 77 | void table(const GCTAResponseTable& table); |
| 78 | - void read(const GFits& file); | |
| 78 | + void read(const GFitsTable& table); | |
| 79 | 79 | void write(GFitsBinTable& hdu) const; |
| 80 | 80 | void save(const std::string& filename, |
| 81 | 81 | const bool& clobber = false) const; | ... | ... |
inst/cta/include/GCTABackground3D.hpp
| ... | ... | @@ -75,7 +75,7 @@ public: |
| 75 | 75 | bool is_valid(void) const; |
| 76 | 76 | const GCTAResponseTable& table(void) const; |
| 77 | 77 | void table(const GCTAResponseTable& table); |
| 78 | - void read(const GFits& file); | |
| 78 | + void read(const GFitsTable& table); | |
| 79 | 79 | void write(GFitsBinTable& hdu) const; |
| 80 | 80 | void save(const std::string& filename, |
| 81 | 81 | const bool& clobber = false) const; | ... | ... |
inst/cta/include/GCTAEdisp2D.hpp
| ... | ... | @@ -91,7 +91,7 @@ public: |
| 91 | 91 | // Methods |
| 92 | 92 | const GCTAResponseTable& table(void) const; |
| 93 | 93 | void table(const GCTAResponseTable& table); |
| 94 | - void read(const GFits& file); | |
| 94 | + void read(const GFitsTable& table); | |
| 95 | 95 | void write(GFitsBinTable& hdu) const; |
| 96 | 96 | void save(const std::string& filename, |
| 97 | 97 | const bool& clobber = false) const; | ... | ... |
inst/cta/include/GCTAPsf2D.hpp
| ... | ... | @@ -96,7 +96,7 @@ public: |
| 96 | 96 | // Methods |
| 97 | 97 | const GCTAResponseTable& table(void) const; |
| 98 | 98 | void table(const GCTAResponseTable& table); |
| 99 | - void read(const GFits& file); | |
| 99 | + void read(const GFitsTable& table); | |
| 100 | 100 | void write(GFitsBinTable& hdu) const; |
| 101 | 101 | void save(const std::string& filename, |
| 102 | 102 | const bool& clobber = false) const; | ... | ... |
inst/cta/include/GCTAPsfKing.hpp
| ... | ... | @@ -94,7 +94,7 @@ public: |
| 94 | 94 | // Methods |
| 95 | 95 | const GCTAResponseTable& table(void) const; |
| 96 | 96 | void table(const GCTAResponseTable& table); |
| 97 | - void read(const GFits& file); | |
| 97 | + void read(const GFitsTable& table); | |
| 98 | 98 | void write(GFitsBinTable& hdu) const; |
| 99 | 99 | void save(const std::string& filename, |
| 100 | 100 | const bool& clobber = false) const; | ... | ... |
inst/cta/pyext/GCTAAeff2D.i
| ... | ... | @@ -66,7 +66,7 @@ public: |
| 66 | 66 | // Methods |
| 67 | 67 | const GCTAResponseTable& table(void) const; |
| 68 | 68 | void table(const GCTAResponseTable& table); |
| 69 | - void read(const GFits& file); | |
| 69 | + void read(const GFitsTable& table); | |
| 70 | 70 | void write(GFitsBinTable& hdu) const; |
| 71 | 71 | void save(const std::string& filename, |
| 72 | 72 | const bool& clobber = false) const; | ... | ... |
inst/cta/pyext/GCTABackground3D.i
| ... | ... | @@ -63,7 +63,7 @@ public: |
| 63 | 63 | bool is_valid(void) const; |
| 64 | 64 | const GCTAResponseTable& table(void) const; |
| 65 | 65 | void table(const GCTAResponseTable& table); |
| 66 | - void read(const GFits& file); | |
| 66 | + void read(const GFitsTable& table); | |
| 67 | 67 | void write(GFitsBinTable& hdu) const; |
| 68 | 68 | void save(const std::string& filename, |
| 69 | 69 | const bool& clobber = false) const; | ... | ... |
inst/cta/pyext/GCTAEdisp2D.i
| ... | ... | @@ -77,7 +77,7 @@ public: |
| 77 | 77 | // Methods |
| 78 | 78 | const GCTAResponseTable& table(void) const; |
| 79 | 79 | void table(const GCTAResponseTable& table); |
| 80 | - void read(const GFits& file); | |
| 80 | + void read(const GFitsTable& table); | |
| 81 | 81 | void write(GFitsBinTable& hdu) const; |
| 82 | 82 | void save(const std::string& filename, |
| 83 | 83 | const bool& clobber = false) const; | ... | ... |
inst/cta/pyext/GCTAPsf2D.i
| ... | ... | @@ -82,7 +82,7 @@ public: |
| 82 | 82 | // Methods |
| 83 | 83 | const GCTAResponseTable& table(void) const; |
| 84 | 84 | void table(const GCTAResponseTable& table); |
| 85 | - void read(const GFits& file); | |
| 85 | + void read(const GFitsTable& table); | |
| 86 | 86 | void write(GFitsBinTable& hdu) const; |
| 87 | 87 | void save(const std::string& filename, |
| 88 | 88 | const bool& clobber = false) const; | ... | ... |
inst/cta/pyext/GCTAPsfKing.i
| ... | ... | @@ -81,6 +81,13 @@ public: |
| 81 | 81 | const double& zenith = 0.0, |
| 82 | 82 | const double& azimuth = 0.0, |
| 83 | 83 | const bool& etrue = true) const; |
| 84 | + // Methods | |
| 85 | + const GCTAResponseTable& table(void) const; | |
| 86 | + void table(const GCTAResponseTable& table); | |
| 87 | + void read(const GFitsTable& table); | |
| 88 | + void write(GFitsBinTable& hdu) const; | |
| 89 | + void save(const std::string& filename, | |
| 90 | + const bool& clobber = false) const; | |
| 84 | 91 | }; |
| 85 | 92 | |
| 86 | 93 | ... | ... |
inst/cta/src/GCTAAeff2D.cpp
| ... | ... | @@ -30,13 +30,14 @@ |
| 30 | 30 | #endif |
| 31 | 31 | #include "GTools.hpp" |
| 32 | 32 | #include "GException.hpp" |
| 33 | +#include "GFilename.hpp" | |
| 33 | 34 | #include "GFits.hpp" |
| 34 | 35 | #include "GFitsBinTable.hpp" |
| 35 | 36 | #include "GFitsTable.hpp" |
| 36 | 37 | #include "GCTAAeff2D.hpp" |
| 37 | 38 | |
| 38 | 39 | /* __ Method name definitions ____________________________________________ */ |
| 39 | -#define G_READ "GCTAAeff2D::read(GFits&)" | |
| 40 | +#define G_READ "GCTAAeff2D::read(GFitsTable&)" | |
| 40 | 41 | |
| 41 | 42 | /* __ Macros _____________________________________________________________ */ |
| 42 | 43 | |
| ... | ... | @@ -235,25 +236,22 @@ GCTAAeff2D* GCTAAeff2D::clone(void) const |
| 235 | 236 | |
| 236 | 237 | |
| 237 | 238 | /***********************************************************************//** |
| 238 | - * @brief Read effective area from FITS file | |
| 239 | + * @brief Read effective area from FITS table | |
| 239 | 240 | * |
| 240 | - * @param[in] fits FITS file pointer. | |
| 241 | + * @param[in] table FITS table pointer. | |
| 241 | 242 | * |
| 242 | 243 | * @exception GException::invalid_value |
| 243 | 244 | * FITS file format differs from expectation. |
| 244 | 245 | * |
| 245 | - * Reads the effective area form the FITS file extension "EFFECTIVE AREA". | |
| 246 | + * Reads the effective area form the FITS table. | |
| 246 | 247 | * The data are stored in m_aeff which is of type GCTAResponseTable. The |
| 247 | 248 | * energy axis will be set to log10, the offset angle axis to radians. |
| 248 | 249 | ***************************************************************************/ |
| 249 | -void GCTAAeff2D::read(const GFits& fits) | |
| 250 | +void GCTAAeff2D::read(const GFitsTable& table) | |
| 250 | 251 | { |
| 251 | 252 | // Clear response table |
| 252 | 253 | m_aeff.clear(); |
| 253 | 254 | |
| 254 | - // Get effective area table | |
| 255 | - const GFitsTable& table = *fits.table("EFFECTIVE AREA"); | |
| 256 | - | |
| 257 | 255 | // Read effective area table |
| 258 | 256 | m_aeff.read(table); |
| 259 | 257 | |
| ... | ... | @@ -321,17 +319,23 @@ void GCTAAeff2D::write(GFitsBinTable& hdu) const |
| 321 | 319 | ***************************************************************************/ |
| 322 | 320 | void GCTAAeff2D::load(const std::string& filename) |
| 323 | 321 | { |
| 322 | + // Create file name | |
| 323 | + GFilename fname(filename); | |
| 324 | + | |
| 325 | + // Allocate FITS file | |
| 326 | + GFits file; | |
| 327 | + | |
| 324 | 328 | // Open FITS file |
| 325 | - GFits fits(filename); | |
| 329 | + file.open(fname.filename()); | |
| 326 | 330 | |
| 327 | - // Read effective area from file | |
| 328 | - read(fits); | |
| 331 | + // Get effective area table | |
| 332 | + const GFitsTable& table = *file.table(fname.extname("EFFECTIVE AREA")); | |
| 329 | 333 | |
| 330 | - // Close FITS file | |
| 331 | - fits.close(); | |
| 334 | + // Read effective area from table | |
| 335 | + read(table); | |
| 332 | 336 | |
| 333 | - // Store filename | |
| 334 | - m_filename = filename; | |
| 337 | + // Close FITS file | |
| 338 | + file.close(); | |
| 335 | 339 | |
| 336 | 340 | // Return |
| 337 | 341 | return; |
| ... | ... | @@ -348,9 +352,12 @@ void GCTAAeff2D::load(const std::string& filename) |
| 348 | 352 | ***************************************************************************/ |
| 349 | 353 | void GCTAAeff2D::save(const std::string& filename, const bool& clobber) const |
| 350 | 354 | { |
| 355 | + // Create file name | |
| 356 | + GFilename fname(filename); | |
| 357 | + | |
| 351 | 358 | // Create binary table |
| 352 | 359 | GFitsBinTable table; |
| 353 | - table.extname("EFFECTIVE AREA"); | |
| 360 | + table.extname(fname.extname("EFFECTIVE AREA")); | |
| 354 | 361 | |
| 355 | 362 | // Write the Effective area table |
| 356 | 363 | write(table); |
| ... | ... | @@ -358,7 +365,7 @@ void GCTAAeff2D::save(const std::string& filename, const bool& clobber) const |
| 358 | 365 | // Create FITS file, append table, and write into the file |
| 359 | 366 | GFits fits; |
| 360 | 367 | fits.append(table); |
| 361 | - fits.saveto(filename, clobber); | |
| 368 | + fits.saveto(fname.filename(), clobber); | |
| 362 | 369 | |
| 363 | 370 | // Return |
| 364 | 371 | return; | ... | ... |
inst/cta/src/GCTAAeffArf.cpp
| ... | ... | @@ -31,6 +31,7 @@ |
| 31 | 31 | #include "GTools.hpp" |
| 32 | 32 | #include "GMath.hpp" |
| 33 | 33 | #include "GIntegral.hpp" |
| 34 | +#include "GFilename.hpp" | |
| 34 | 35 | #include "GFitsTable.hpp" |
| 35 | 36 | #include "GFitsTableCol.hpp" |
| 36 | 37 | #include "GCTAAeffArf.hpp" |
| ... | ... | @@ -247,21 +248,24 @@ GCTAAeffArf* GCTAAeffArf::clone(void) const |
| 247 | 248 | ***************************************************************************/ |
| 248 | 249 | void GCTAAeffArf::load(const std::string& filename) |
| 249 | 250 | { |
| 250 | - // Open ARF FITS file | |
| 251 | - GFits file(filename); | |
| 251 | + // Create file name | |
| 252 | + GFilename fname(filename); | |
| 253 | + | |
| 254 | + // Allocate FITS file | |
| 255 | + GFits file; | |
| 256 | + | |
| 257 | + // Open FITS file | |
| 258 | + file.open(fname.filename()); | |
| 252 | 259 | |
| 253 | 260 | // Get ARF table |
| 254 | - const GFitsTable& table = *file.table("SPECRESP"); | |
| 261 | + const GFitsTable& table = *file.table(fname.extname("SPECRESP")); | |
| 255 | 262 | |
| 256 | - // Read ARF | |
| 263 | + // Read ARF from table | |
| 257 | 264 | read(table); |
| 258 | 265 | |
| 259 | - // Close ARF FITS file | |
| 266 | + // Close FITS file | |
| 260 | 267 | file.close(); |
| 261 | 268 | |
| 262 | - // Store filename | |
| 263 | - m_filename = filename; | |
| 264 | - | |
| 265 | 269 | // Return |
| 266 | 270 | return; |
| 267 | 271 | } | ... | ... |
inst/cta/src/GCTABackground3D.cpp
| ... | ... | @@ -30,13 +30,14 @@ |
| 30 | 30 | #endif |
| 31 | 31 | #include "GTools.hpp" |
| 32 | 32 | #include "GException.hpp" |
| 33 | +#include "GFilename.hpp" | |
| 33 | 34 | #include "GMath.hpp" |
| 34 | 35 | #include "GFits.hpp" |
| 35 | 36 | #include "GFitsBinTable.hpp" |
| 36 | 37 | #include "GCTABackground3D.hpp" |
| 37 | 38 | |
| 38 | 39 | /* __ Method name definitions ____________________________________________ */ |
| 39 | -#define G_READ "GCTABackground3D::read(GFits&)" | |
| 40 | +#define G_READ "GCTABackground3D::read(GFitsTable& table)" | |
| 40 | 41 | #define G_MC "GCTABackground3D::mc(GEnergy&, GTime&, GRan&)" |
| 41 | 42 | #define G_INIT_MC_CACHE "GCTABackground3D::init_mc_cache()" |
| 42 | 43 | |
| ... | ... | @@ -305,24 +306,21 @@ GCTABackground3D* GCTABackground3D::clone(void) const |
| 305 | 306 | /***********************************************************************//** |
| 306 | 307 | * @brief Read background from FITS file |
| 307 | 308 | * |
| 308 | - * @param[in] fits FITS file pointer. | |
| 309 | + * @param[in] table FITS table. | |
| 309 | 310 | * |
| 310 | 311 | * @exception GException::invalid_value |
| 311 | 312 | * FITS file format differs from expectation. |
| 312 | 313 | * |
| 313 | - * Reads the background from the FITS file extension "BACKGROUND". The data | |
| 314 | + * Reads the background from the FITS table. The data | |
| 314 | 315 | * are stored in m_background which is of type GCTAResponseTable. The DETX |
| 315 | 316 | * and DETY axes will be set to radians, the energy axis will be set to |
| 316 | 317 | * log10. |
| 317 | 318 | ***************************************************************************/ |
| 318 | -void GCTABackground3D::read(const GFits& fits) | |
| 319 | +void GCTABackground3D::read(const GFitsTable& table) | |
| 319 | 320 | { |
| 320 | 321 | // Clear response table |
| 321 | 322 | m_background.clear(); |
| 322 | 323 | |
| 323 | - // Get background table | |
| 324 | - const GFitsTable& table = *fits.table("BACKGROUND"); | |
| 325 | - | |
| 326 | 324 | // Read background table |
| 327 | 325 | m_background.read(table); |
| 328 | 326 | |
| ... | ... | @@ -386,17 +384,23 @@ void GCTABackground3D::write(GFitsBinTable& hdu) const |
| 386 | 384 | ***************************************************************************/ |
| 387 | 385 | void GCTABackground3D::load(const std::string& filename) |
| 388 | 386 | { |
| 387 | + // Create file name | |
| 388 | + GFilename fname(filename); | |
| 389 | + | |
| 390 | + // Allocate FITS file | |
| 391 | + GFits file; | |
| 392 | + | |
| 389 | 393 | // Open FITS file |
| 390 | - GFits fits(filename); | |
| 394 | + file.open(fname.filename()); | |
| 391 | 395 | |
| 392 | - // Read background from file | |
| 393 | - read(fits); | |
| 396 | + // Get background table | |
| 397 | + const GFitsTable& table = *file.table(fname.extname("BACKGROUND")); | |
| 394 | 398 | |
| 395 | - // Close FITS file | |
| 396 | - fits.close(); | |
| 399 | + // Read effective area from table | |
| 400 | + read(table); | |
| 397 | 401 | |
| 398 | - // Store filename | |
| 399 | - m_filename = filename; | |
| 402 | + // Close FITS file | |
| 403 | + file.close(); | |
| 400 | 404 | |
| 401 | 405 | // Return |
| 402 | 406 | return; |
| ... | ... | @@ -413,9 +417,12 @@ void GCTABackground3D::load(const std::string& filename) |
| 413 | 417 | ***************************************************************************/ |
| 414 | 418 | void GCTABackground3D::save(const std::string& filename, const bool& clobber) const |
| 415 | 419 | { |
| 420 | + // Create file name | |
| 421 | + GFilename fname(filename); | |
| 422 | + | |
| 416 | 423 | // Create binary table |
| 417 | 424 | GFitsBinTable table; |
| 418 | - table.extname("BACKGROUND"); | |
| 425 | + table.extname(fname.extname("BACKGROUND")); | |
| 419 | 426 | |
| 420 | 427 | // Write the background table |
| 421 | 428 | write(table); |
| ... | ... | @@ -423,7 +430,7 @@ void GCTABackground3D::save(const std::string& filename, const bool& clobber) co |
| 423 | 430 | // Create FITS file, append table, and write into the file |
| 424 | 431 | GFits fits; |
| 425 | 432 | fits.append(table); |
| 426 | - fits.saveto(filename, clobber); | |
| 433 | + fits.saveto(fname.filename(), clobber); | |
| 427 | 434 | |
| 428 | 435 | // Return |
| 429 | 436 | return; | ... | ... |
inst/cta/src/GCTAEdisp2D.cpp
| ... | ... | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include "GTools.hpp" |
| 34 | 34 | #include "GMath.hpp" |
| 35 | 35 | #include "GIntegral.hpp" |
| 36 | +#include "GFilename.hpp" | |
| 36 | 37 | #include "GFits.hpp" |
| 37 | 38 | #include "GFitsTable.hpp" |
| 38 | 39 | #include "GFitsBinTable.hpp" |
| ... | ... | @@ -238,17 +239,23 @@ GCTAEdisp2D* GCTAEdisp2D::clone(void) const |
| 238 | 239 | ***************************************************************************/ |
| 239 | 240 | void GCTAEdisp2D::load(const std::string& filename) |
| 240 | 241 | { |
| 242 | + // Create file name | |
| 243 | + GFilename fname(filename); | |
| 244 | + | |
| 245 | + // Allocate FITS file | |
| 246 | + GFits file; | |
| 247 | + | |
| 241 | 248 | // Open FITS file |
| 242 | - GFits fits(filename); | |
| 249 | + file.open(fname.filename()); | |
| 243 | 250 | |
| 244 | - // Read energy dispersion from file | |
| 245 | - read(fits); | |
| 251 | + // Get energy dispersion table | |
| 252 | + const GFitsTable& table = *file.table(fname.extname("ENERGY DISPERSION")); | |
| 246 | 253 | |
| 247 | - // Close FITS file | |
| 248 | - fits.close(); | |
| 254 | + // Read energy dispersion from table | |
| 255 | + read(table); | |
| 249 | 256 | |
| 250 | - // Store filename | |
| 251 | - m_filename = filename; | |
| 257 | + // Close FITS file | |
| 258 | + file.close(); | |
| 252 | 259 | |
| 253 | 260 | // Return |
| 254 | 261 | return; |
| ... | ... | @@ -268,14 +275,11 @@ void GCTAEdisp2D::load(const std::string& filename) |
| 268 | 275 | * The method assures that the energy dispersion information is properly |
| 269 | 276 | * normalised. |
| 270 | 277 | ***************************************************************************/ |
| 271 | -void GCTAEdisp2D::read(const GFits& fits) | |
| 278 | +void GCTAEdisp2D::read(const GFitsTable& table) | |
| 272 | 279 | { |
| 273 | 280 | // Clear response table |
| 274 | 281 | m_edisp.clear(); |
| 275 | 282 | |
| 276 | - // Get energy dispersion table | |
| 277 | - const GFitsTable& table = *fits.table("ENERGY DISPERSION"); | |
| 278 | - | |
| 279 | 283 | // Read energy dispersion table |
| 280 | 284 | m_edisp.read(table); |
| 281 | 285 | |
| ... | ... | @@ -399,17 +403,20 @@ void GCTAEdisp2D::write(GFitsBinTable& hdu) const |
| 399 | 403 | ***************************************************************************/ |
| 400 | 404 | void GCTAEdisp2D::save(const std::string& filename, const bool& clobber) const |
| 401 | 405 | { |
| 406 | + // Create file name | |
| 407 | + GFilename fname(filename); | |
| 408 | + | |
| 402 | 409 | // Create binary table |
| 403 | 410 | GFitsBinTable table; |
| 404 | - table.extname("ENERGY DISPERSION"); | |
| 411 | + table.extname(fname.extname("ENERGY DISPERSON")); | |
| 405 | 412 | |
| 406 | - // Write the Energy dispersion table | |
| 413 | + // Write the energy dispersion table | |
| 407 | 414 | write(table); |
| 408 | 415 | |
| 409 | 416 | // Create FITS file, append table, and write into the file |
| 410 | 417 | GFits fits; |
| 411 | 418 | fits.append(table); |
| 412 | - fits.saveto(filename, clobber); | |
| 419 | + fits.saveto(fname.filename(), clobber); | |
| 413 | 420 | |
| 414 | 421 | // Return |
| 415 | 422 | return; | ... | ... |
inst/cta/src/GCTAPsf2D.cpp
| ... | ... | @@ -32,13 +32,14 @@ |
| 32 | 32 | #include "GTools.hpp" |
| 33 | 33 | #include "GException.hpp" |
| 34 | 34 | #include "GMath.hpp" |
| 35 | +#include "GFilename.hpp" | |
| 35 | 36 | #include "GFits.hpp" |
| 36 | 37 | #include "GFitsBinTable.hpp" |
| 37 | 38 | #include "GCTAPsf2D.hpp" |
| 38 | 39 | #include "GCTAException.hpp" |
| 39 | 40 | |
| 40 | 41 | /* __ Method name definitions ____________________________________________ */ |
| 41 | -#define G_READ "GCTAPsf2D::read(GFits&)" | |
| 42 | +#define G_READ "GCTAPsf2D::read(GFitsTable& table)" | |
| 42 | 43 | #define G_LOAD "GCTAPsf2D::load(std::string&)" |
| 43 | 44 | #define G_CONTAINMENT_RADIUS "GCTAPsf2D::containment_radius(double&,"\ |
| 44 | 45 | " double&, double&, double&, double&, double&, bool&)" |
| ... | ... | @@ -276,24 +277,21 @@ GCTAPsf2D* GCTAPsf2D::clone(void) const |
| 276 | 277 | /***********************************************************************//** |
| 277 | 278 | * @brief Read PSF from FITS file |
| 278 | 279 | * |
| 279 | - * @param[in] fits FITS file pointer. | |
| 280 | + * @param[in] table FITS table. | |
| 280 | 281 | * |
| 281 | 282 | * @exception GException::invalid_value |
| 282 | 283 | * FITS file format differs from expectation. |
| 283 | 284 | * |
| 284 | - * Reads the PSF from the FITS file extension "POINT SPREAD FUNCTION". The data | |
| 285 | + * Reads the PSF from the FITS table. The data | |
| 285 | 286 | * are stored in m_psf which is of type GCTAResponseTable. |
| 286 | 287 | * The energy axis will be set to log10. The offset angle axis and |
| 287 | 288 | * sigma parameter columns will be set to radians. |
| 288 | 289 | ***************************************************************************/ |
| 289 | -void GCTAPsf2D::read(const GFits& fits) | |
| 290 | +void GCTAPsf2D::read(const GFitsTable& table) | |
| 290 | 291 | { |
| 291 | 292 | // Clear response table |
| 292 | 293 | m_psf.clear(); |
| 293 | 294 | |
| 294 | - // Get PSF table | |
| 295 | - const GFitsTable& table = *fits.table("POINT SPREAD FUNCTION"); | |
| 296 | - | |
| 297 | 295 | // Read PSF table |
| 298 | 296 | m_psf.read(table); |
| 299 | 297 | |
| ... | ... | @@ -367,17 +365,23 @@ void GCTAPsf2D::write(GFitsBinTable& hdu) const |
| 367 | 365 | ***************************************************************************/ |
| 368 | 366 | void GCTAPsf2D::load(const std::string& filename) |
| 369 | 367 | { |
| 370 | - // Open PSF FITS file | |
| 371 | - GFits fits(filename); | |
| 368 | + // Create file name | |
| 369 | + GFilename fname(filename); | |
| 370 | + | |
| 371 | + // Allocate FITS file | |
| 372 | + GFits file; | |
| 372 | 373 | |
| 373 | - // Read fits file | |
| 374 | - read(fits); | |
| 374 | + // Open FITS file | |
| 375 | + file.open(fname.filename()); | |
| 375 | 376 | |
| 376 | - // Close PSF FITS file | |
| 377 | - fits.close(); | |
| 377 | + // Get PSFa table | |
| 378 | + const GFitsTable& table = *file.table(fname.extname("POINT SPREAD FUNCTION")); | |
| 378 | 379 | |
| 379 | - // Store filename | |
| 380 | - m_filename = filename; | |
| 380 | + // Read PSF from table | |
| 381 | + read(table); | |
| 382 | + | |
| 383 | + // Close FITS file | |
| 384 | + file.close(); | |
| 381 | 385 | |
| 382 | 386 | // Return |
| 383 | 387 | return; |
| ... | ... | @@ -394,9 +398,12 @@ void GCTAPsf2D::load(const std::string& filename) |
| 394 | 398 | ***************************************************************************/ |
| 395 | 399 | void GCTAPsf2D::save(const std::string& filename, const bool& clobber) const |
| 396 | 400 | { |
| 401 | + // Create file name | |
| 402 | + GFilename fname(filename); | |
| 403 | + | |
| 397 | 404 | // Create binary table |
| 398 | 405 | GFitsBinTable table; |
| 399 | - table.extname("POINT SPREAD FUNCTION"); | |
| 406 | + table.extname(fname.extname("POINT SPREAD FUNCTION")); | |
| 400 | 407 | |
| 401 | 408 | // Write the PSF table |
| 402 | 409 | write(table); |
| ... | ... | @@ -404,7 +411,7 @@ void GCTAPsf2D::save(const std::string& filename, const bool& clobber) const |
| 404 | 411 | // Create FITS file, append table, and write into the file |
| 405 | 412 | GFits fits; |
| 406 | 413 | fits.append(table); |
| 407 | - fits.saveto(filename, clobber); | |
| 414 | + fits.saveto(fname.filename(), clobber); | |
| 408 | 415 | |
| 409 | 416 | // Return |
| 410 | 417 | return; | ... | ... |
inst/cta/src/GCTAPsfKing.cpp
| ... | ... | @@ -32,13 +32,14 @@ |
| 32 | 32 | #include "GTools.hpp" |
| 33 | 33 | #include "GException.hpp" |
| 34 | 34 | #include "GMath.hpp" |
| 35 | +#include "GFilename.hpp" | |
| 35 | 36 | #include "GFits.hpp" |
| 36 | 37 | #include "GFitsBinTable.hpp" |
| 37 | 38 | #include "GCTAPsfKing.hpp" |
| 38 | 39 | #include "GCTAException.hpp" |
| 39 | 40 | |
| 40 | 41 | /* __ Method name definitions ____________________________________________ */ |
| 41 | -#define G_READ "GCTAPsfKing::read(GFits&)" | |
| 42 | +#define G_READ "GCTAPsfKing::read(GFitsTable& table)" | |
| 42 | 43 | #define G_CONTAINMENT_RADIUS "GCTAPsfKing::containment_radius(double&,"\ |
| 43 | 44 | " double&, double&, double&, double&, double&, bool&)" |
| 44 | 45 | #define G_UPDATE "GCTAPsfKing::update(double&, double&)" |
| ... | ... | @@ -277,24 +278,21 @@ GCTAPsfKing* GCTAPsfKing::clone(void) const |
| 277 | 278 | /***********************************************************************//** |
| 278 | 279 | * @brief Read PSF from FITS file |
| 279 | 280 | * |
| 280 | - * @param[in] fits FITS file pointer. | |
| 281 | + * @param[in] table FITS table. | |
| 281 | 282 | * |
| 282 | 283 | * @exception GException::invalid_value |
| 283 | 284 | * FITS file format differs from expectation. |
| 284 | 285 | * |
| 285 | - * Reads the PSF from the FITS file extension "POINT SPREAD FUNCTION". The | |
| 286 | + * Reads the PSF from the FITS table. The | |
| 286 | 287 | * data are stored in m_psf which is of type GCTAResponseTable. |
| 287 | 288 | * The energy axis will be set to log10. The offset angle axis and |
| 288 | 289 | * sigma parameter columns will be set to radians. |
| 289 | 290 | ***************************************************************************/ |
| 290 | -void GCTAPsfKing::read(const GFits& fits) | |
| 291 | +void GCTAPsfKing::read(const GFitsTable& table) | |
| 291 | 292 | { |
| 292 | 293 | // Clear response table |
| 293 | 294 | m_psf.clear(); |
| 294 | 295 | |
| 295 | - // Get PSF table | |
| 296 | - const GFitsTable& table = *fits.table("POINT SPREAD FUNCTION"); | |
| 297 | - | |
| 298 | 296 | // Read PSF table |
| 299 | 297 | m_psf.read(table); |
| 300 | 298 | |
| ... | ... | @@ -358,17 +356,23 @@ void GCTAPsfKing::write(GFitsBinTable& hdu) const |
| 358 | 356 | ***************************************************************************/ |
| 359 | 357 | void GCTAPsfKing::load(const std::string& filename) |
| 360 | 358 | { |
| 361 | - // Open PSF FITS file | |
| 362 | - GFits file(filename); | |
| 359 | + // Create file name | |
| 360 | + GFilename fname(filename); | |
| 363 | 361 | |
| 364 | - // Read fits file | |
| 365 | - read(file); | |
| 362 | + // Allocate FITS file | |
| 363 | + GFits file; | |
| 366 | 364 | |
| 367 | - // Close PSF FITS file | |
| 368 | - file.close(); | |
| 365 | + // Open FITS file | |
| 366 | + file.open(fname.filename()); | |
| 367 | + | |
| 368 | + // Get PSFa table | |
| 369 | + const GFitsTable& table = *file.table(fname.extname("POINT SPREAD FUNCTION")); | |
| 369 | 370 | |
| 370 | - // Store filename | |
| 371 | - m_filename = filename; | |
| 371 | + // Read PSF from table | |
| 372 | + read(table); | |
| 373 | + | |
| 374 | + // Close FITS file | |
| 375 | + file.close(); | |
| 372 | 376 | |
| 373 | 377 | // Return |
| 374 | 378 | return; |
| ... | ... | @@ -384,9 +388,12 @@ void GCTAPsfKing::load(const std::string& filename) |
| 384 | 388 | ***************************************************************************/ |
| 385 | 389 | void GCTAPsfKing::save(const std::string& filename, const bool& clobber) const |
| 386 | 390 | { |
| 391 | + // Create file name | |
| 392 | + GFilename fname(filename); | |
| 393 | + | |
| 387 | 394 | // Create binary table |
| 388 | 395 | GFitsBinTable table; |
| 389 | - table.extname("POINT SPREAD FUNCTION"); | |
| 396 | + table.extname(fname.extname("POINT SPREAD FUNCTION")); | |
| 390 | 397 | |
| 391 | 398 | // Write the PSF table |
| 392 | 399 | write(table); |
| ... | ... | @@ -394,7 +401,7 @@ void GCTAPsfKing::save(const std::string& filename, const bool& clobber) const |
| 394 | 401 | // Create FITS file, append table, and write into the file |
| 395 | 402 | GFits fits; |
| 396 | 403 | fits.append(table); |
| 397 | - fits.saveto(filename, clobber); | |
| 404 | + fits.saveto(fname.filename(), clobber); | |
| 398 | 405 | |
| 399 | 406 | // Return |
| 400 | 407 | return; | ... | ... |
inst/cta/src/GCTAPsfVector.cpp
| ... | ... | @@ -31,6 +31,7 @@ |
| 31 | 31 | #include <cmath> |
| 32 | 32 | #include "GTools.hpp" |
| 33 | 33 | #include "GMath.hpp" |
| 34 | +#include "GFilename.hpp" | |
| 34 | 35 | #include "GFitsTable.hpp" |
| 35 | 36 | #include "GFitsTableCol.hpp" |
| 36 | 37 | #include "GCTAPsfVector.hpp" |
| ... | ... | @@ -256,21 +257,24 @@ GCTAPsfVector* GCTAPsfVector::clone(void) const |
| 256 | 257 | ***************************************************************************/ |
| 257 | 258 | void GCTAPsfVector::load(const std::string& filename) |
| 258 | 259 | { |
| 259 | - // Open PSF FITS file | |
| 260 | - GFits file(filename); | |
| 260 | + // Create file name | |
| 261 | + GFilename fname(filename); | |
| 261 | 262 | |
| 262 | - // Get PSF table | |
| 263 | - const GFitsTable& table = *file.table(1); | |
| 263 | + // Allocate FITS file | |
| 264 | + GFits file; | |
| 264 | 265 | |
| 265 | - // Read PSF | |
| 266 | + // Open FITS file | |
| 267 | + file.open(fname.filename()); | |
| 268 | + | |
| 269 | + // Get PSFa table | |
| 270 | + const GFitsTable& table = *file.table(fname.extname("PSF")); | |
| 271 | + | |
| 272 | + // Read PSF from table | |
| 266 | 273 | read(table); |
| 267 | 274 | |
| 268 | - // Close PSF FITS file | |
| 275 | + // Close FITS file | |
| 269 | 276 | file.close(); |
| 270 | 277 | |
| 271 | - // Store filename | |
| 272 | - m_filename = filename; | |
| 273 | - | |
| 274 | 278 | // Return |
| 275 | 279 | return; |
| 276 | 280 | } | ... | ... |