diff --git a/inst/cta/include/GCTAAeff2D.hpp b/inst/cta/include/GCTAAeff2D.hpp index 2fc2b89..dab9aff 100644 --- a/inst/cta/include/GCTAAeff2D.hpp +++ b/inst/cta/include/GCTAAeff2D.hpp @@ -75,7 +75,7 @@ public: // Methods const GCTAResponseTable& table(void) const; void table(const GCTAResponseTable& table); - void read(const GFits& file); + void read(const GFitsTable& table); void write(GFitsBinTable& hdu) const; void save(const std::string& filename, const bool& clobber = false) const; diff --git a/inst/cta/include/GCTABackground3D.hpp b/inst/cta/include/GCTABackground3D.hpp index 4e0df6d..c156b30 100644 --- a/inst/cta/include/GCTABackground3D.hpp +++ b/inst/cta/include/GCTABackground3D.hpp @@ -75,7 +75,7 @@ public: bool is_valid(void) const; const GCTAResponseTable& table(void) const; void table(const GCTAResponseTable& table); - void read(const GFits& file); + void read(const GFitsTable& table); void write(GFitsBinTable& hdu) const; void save(const std::string& filename, const bool& clobber = false) const; diff --git a/inst/cta/include/GCTAEdisp2D.hpp b/inst/cta/include/GCTAEdisp2D.hpp index bb7d5a9..3fd3d42 100644 --- a/inst/cta/include/GCTAEdisp2D.hpp +++ b/inst/cta/include/GCTAEdisp2D.hpp @@ -91,7 +91,7 @@ public: // Methods const GCTAResponseTable& table(void) const; void table(const GCTAResponseTable& table); - void read(const GFits& file); + void read(const GFitsTable& table); void write(GFitsBinTable& hdu) const; void save(const std::string& filename, const bool& clobber = false) const; diff --git a/inst/cta/include/GCTAPsf2D.hpp b/inst/cta/include/GCTAPsf2D.hpp index e9d446e..0afd56d 100644 --- a/inst/cta/include/GCTAPsf2D.hpp +++ b/inst/cta/include/GCTAPsf2D.hpp @@ -96,7 +96,7 @@ public: // Methods const GCTAResponseTable& table(void) const; void table(const GCTAResponseTable& table); - void read(const GFits& file); + void read(const GFitsTable& table); void write(GFitsBinTable& hdu) const; void save(const std::string& filename, const bool& clobber = false) const; diff --git a/inst/cta/include/GCTAPsfKing.hpp b/inst/cta/include/GCTAPsfKing.hpp index 7480614..3ee44b5 100644 --- a/inst/cta/include/GCTAPsfKing.hpp +++ b/inst/cta/include/GCTAPsfKing.hpp @@ -94,7 +94,7 @@ public: // Methods const GCTAResponseTable& table(void) const; void table(const GCTAResponseTable& table); - void read(const GFits& file); + void read(const GFitsTable& table); void write(GFitsBinTable& hdu) const; void save(const std::string& filename, const bool& clobber = false) const; diff --git a/inst/cta/pyext/GCTAAeff2D.i b/inst/cta/pyext/GCTAAeff2D.i index 75e467e..d491b99 100644 --- a/inst/cta/pyext/GCTAAeff2D.i +++ b/inst/cta/pyext/GCTAAeff2D.i @@ -66,7 +66,7 @@ public: // Methods const GCTAResponseTable& table(void) const; void table(const GCTAResponseTable& table); - void read(const GFits& file); + void read(const GFitsTable& table); void write(GFitsBinTable& hdu) const; void save(const std::string& filename, const bool& clobber = false) const; diff --git a/inst/cta/pyext/GCTABackground3D.i b/inst/cta/pyext/GCTABackground3D.i index c9f4c12..6a22f60 100644 --- a/inst/cta/pyext/GCTABackground3D.i +++ b/inst/cta/pyext/GCTABackground3D.i @@ -63,7 +63,7 @@ public: bool is_valid(void) const; const GCTAResponseTable& table(void) const; void table(const GCTAResponseTable& table); - void read(const GFits& file); + void read(const GFitsTable& table); void write(GFitsBinTable& hdu) const; void save(const std::string& filename, const bool& clobber = false) const; diff --git a/inst/cta/pyext/GCTAEdisp2D.i b/inst/cta/pyext/GCTAEdisp2D.i index 5008aa1..9a16ed9 100644 --- a/inst/cta/pyext/GCTAEdisp2D.i +++ b/inst/cta/pyext/GCTAEdisp2D.i @@ -77,7 +77,7 @@ public: // Methods const GCTAResponseTable& table(void) const; void table(const GCTAResponseTable& table); - void read(const GFits& file); + void read(const GFitsTable& table); void write(GFitsBinTable& hdu) const; void save(const std::string& filename, const bool& clobber = false) const; diff --git a/inst/cta/pyext/GCTAPsf2D.i b/inst/cta/pyext/GCTAPsf2D.i index c6e152b..0c7acb8 100644 --- a/inst/cta/pyext/GCTAPsf2D.i +++ b/inst/cta/pyext/GCTAPsf2D.i @@ -82,7 +82,7 @@ public: // Methods const GCTAResponseTable& table(void) const; void table(const GCTAResponseTable& table); - void read(const GFits& file); + void read(const GFitsTable& table); void write(GFitsBinTable& hdu) const; void save(const std::string& filename, const bool& clobber = false) const; diff --git a/inst/cta/pyext/GCTAPsfKing.i b/inst/cta/pyext/GCTAPsfKing.i index 6402505..ec0ac06 100644 --- a/inst/cta/pyext/GCTAPsfKing.i +++ b/inst/cta/pyext/GCTAPsfKing.i @@ -81,6 +81,13 @@ public: const double& zenith = 0.0, const double& azimuth = 0.0, const bool& etrue = true) const; + // Methods + const GCTAResponseTable& table(void) const; + void table(const GCTAResponseTable& table); + void read(const GFitsTable& table); + void write(GFitsBinTable& hdu) const; + void save(const std::string& filename, + const bool& clobber = false) const; }; diff --git a/inst/cta/src/GCTAAeff2D.cpp b/inst/cta/src/GCTAAeff2D.cpp index 09cfddf..df5d02d 100644 --- a/inst/cta/src/GCTAAeff2D.cpp +++ b/inst/cta/src/GCTAAeff2D.cpp @@ -30,13 +30,14 @@ #endif #include "GTools.hpp" #include "GException.hpp" +#include "GFilename.hpp" #include "GFits.hpp" #include "GFitsBinTable.hpp" #include "GFitsTable.hpp" #include "GCTAAeff2D.hpp" /* __ Method name definitions ____________________________________________ */ -#define G_READ "GCTAAeff2D::read(GFits&)" +#define G_READ "GCTAAeff2D::read(GFitsTable&)" /* __ Macros _____________________________________________________________ */ @@ -235,25 +236,22 @@ GCTAAeff2D* GCTAAeff2D::clone(void) const /***********************************************************************//** - * @brief Read effective area from FITS file + * @brief Read effective area from FITS table * - * @param[in] fits FITS file pointer. + * @param[in] table FITS table pointer. * * @exception GException::invalid_value * FITS file format differs from expectation. * - * Reads the effective area form the FITS file extension "EFFECTIVE AREA". + * Reads the effective area form the FITS table. * The data are stored in m_aeff which is of type GCTAResponseTable. The * energy axis will be set to log10, the offset angle axis to radians. ***************************************************************************/ -void GCTAAeff2D::read(const GFits& fits) +void GCTAAeff2D::read(const GFitsTable& table) { // Clear response table m_aeff.clear(); - // Get effective area table - const GFitsTable& table = *fits.table("EFFECTIVE AREA"); - // Read effective area table m_aeff.read(table); @@ -321,17 +319,23 @@ void GCTAAeff2D::write(GFitsBinTable& hdu) const ***************************************************************************/ void GCTAAeff2D::load(const std::string& filename) { + // Create file name + GFilename fname(filename); + + // Allocate FITS file + GFits file; + // Open FITS file - GFits fits(filename); + file.open(fname.filename()); - // Read effective area from file - read(fits); + // Get effective area table + const GFitsTable& table = *file.table(fname.extname("EFFECTIVE AREA")); - // Close FITS file - fits.close(); + // Read effective area from table + read(table); - // Store filename - m_filename = filename; + // Close FITS file + file.close(); // Return return; @@ -348,9 +352,12 @@ void GCTAAeff2D::load(const std::string& filename) ***************************************************************************/ void GCTAAeff2D::save(const std::string& filename, const bool& clobber) const { + // Create file name + GFilename fname(filename); + // Create binary table GFitsBinTable table; - table.extname("EFFECTIVE AREA"); + table.extname(fname.extname("EFFECTIVE AREA")); // Write the Effective area table write(table); @@ -358,7 +365,7 @@ void GCTAAeff2D::save(const std::string& filename, const bool& clobber) const // Create FITS file, append table, and write into the file GFits fits; fits.append(table); - fits.saveto(filename, clobber); + fits.saveto(fname.filename(), clobber); // Return return; diff --git a/inst/cta/src/GCTAAeffArf.cpp b/inst/cta/src/GCTAAeffArf.cpp index 65e7840..8fcb21a 100644 --- a/inst/cta/src/GCTAAeffArf.cpp +++ b/inst/cta/src/GCTAAeffArf.cpp @@ -31,6 +31,7 @@ #include "GTools.hpp" #include "GMath.hpp" #include "GIntegral.hpp" +#include "GFilename.hpp" #include "GFitsTable.hpp" #include "GFitsTableCol.hpp" #include "GCTAAeffArf.hpp" @@ -247,21 +248,24 @@ GCTAAeffArf* GCTAAeffArf::clone(void) const ***************************************************************************/ void GCTAAeffArf::load(const std::string& filename) { - // Open ARF FITS file - GFits file(filename); + // Create file name + GFilename fname(filename); + + // Allocate FITS file + GFits file; + + // Open FITS file + file.open(fname.filename()); // Get ARF table - const GFitsTable& table = *file.table("SPECRESP"); + const GFitsTable& table = *file.table(fname.extname("SPECRESP")); - // Read ARF + // Read ARF from table read(table); - // Close ARF FITS file + // Close FITS file file.close(); - // Store filename - m_filename = filename; - // Return return; } diff --git a/inst/cta/src/GCTABackground3D.cpp b/inst/cta/src/GCTABackground3D.cpp index 90ddc12..b00b60c 100644 --- a/inst/cta/src/GCTABackground3D.cpp +++ b/inst/cta/src/GCTABackground3D.cpp @@ -30,13 +30,14 @@ #endif #include "GTools.hpp" #include "GException.hpp" +#include "GFilename.hpp" #include "GMath.hpp" #include "GFits.hpp" #include "GFitsBinTable.hpp" #include "GCTABackground3D.hpp" /* __ Method name definitions ____________________________________________ */ -#define G_READ "GCTABackground3D::read(GFits&)" +#define G_READ "GCTABackground3D::read(GFitsTable& table)" #define G_MC "GCTABackground3D::mc(GEnergy&, GTime&, GRan&)" #define G_INIT_MC_CACHE "GCTABackground3D::init_mc_cache()" @@ -305,24 +306,21 @@ GCTABackground3D* GCTABackground3D::clone(void) const /***********************************************************************//** * @brief Read background from FITS file * - * @param[in] fits FITS file pointer. + * @param[in] table FITS table. * * @exception GException::invalid_value * FITS file format differs from expectation. * - * Reads the background from the FITS file extension "BACKGROUND". The data + * Reads the background from the FITS table. The data * are stored in m_background which is of type GCTAResponseTable. The DETX * and DETY axes will be set to radians, the energy axis will be set to * log10. ***************************************************************************/ -void GCTABackground3D::read(const GFits& fits) +void GCTABackground3D::read(const GFitsTable& table) { // Clear response table m_background.clear(); - // Get background table - const GFitsTable& table = *fits.table("BACKGROUND"); - // Read background table m_background.read(table); @@ -386,17 +384,23 @@ void GCTABackground3D::write(GFitsBinTable& hdu) const ***************************************************************************/ void GCTABackground3D::load(const std::string& filename) { + // Create file name + GFilename fname(filename); + + // Allocate FITS file + GFits file; + // Open FITS file - GFits fits(filename); + file.open(fname.filename()); - // Read background from file - read(fits); + // Get background table + const GFitsTable& table = *file.table(fname.extname("BACKGROUND")); - // Close FITS file - fits.close(); + // Read effective area from table + read(table); - // Store filename - m_filename = filename; + // Close FITS file + file.close(); // Return return; @@ -413,9 +417,12 @@ void GCTABackground3D::load(const std::string& filename) ***************************************************************************/ void GCTABackground3D::save(const std::string& filename, const bool& clobber) const { + // Create file name + GFilename fname(filename); + // Create binary table GFitsBinTable table; - table.extname("BACKGROUND"); + table.extname(fname.extname("BACKGROUND")); // Write the background table write(table); @@ -423,7 +430,7 @@ void GCTABackground3D::save(const std::string& filename, const bool& clobber) co // Create FITS file, append table, and write into the file GFits fits; fits.append(table); - fits.saveto(filename, clobber); + fits.saveto(fname.filename(), clobber); // Return return; diff --git a/inst/cta/src/GCTAEdisp2D.cpp b/inst/cta/src/GCTAEdisp2D.cpp index 5251812..7598941 100644 --- a/inst/cta/src/GCTAEdisp2D.cpp +++ b/inst/cta/src/GCTAEdisp2D.cpp @@ -33,6 +33,7 @@ #include "GTools.hpp" #include "GMath.hpp" #include "GIntegral.hpp" +#include "GFilename.hpp" #include "GFits.hpp" #include "GFitsTable.hpp" #include "GFitsBinTable.hpp" @@ -238,17 +239,23 @@ GCTAEdisp2D* GCTAEdisp2D::clone(void) const ***************************************************************************/ void GCTAEdisp2D::load(const std::string& filename) { + // Create file name + GFilename fname(filename); + + // Allocate FITS file + GFits file; + // Open FITS file - GFits fits(filename); + file.open(fname.filename()); - // Read energy dispersion from file - read(fits); + // Get energy dispersion table + const GFitsTable& table = *file.table(fname.extname("ENERGY DISPERSION")); - // Close FITS file - fits.close(); + // Read energy dispersion from table + read(table); - // Store filename - m_filename = filename; + // Close FITS file + file.close(); // Return return; @@ -268,14 +275,11 @@ void GCTAEdisp2D::load(const std::string& filename) * The method assures that the energy dispersion information is properly * normalised. ***************************************************************************/ -void GCTAEdisp2D::read(const GFits& fits) +void GCTAEdisp2D::read(const GFitsTable& table) { // Clear response table m_edisp.clear(); - // Get energy dispersion table - const GFitsTable& table = *fits.table("ENERGY DISPERSION"); - // Read energy dispersion table m_edisp.read(table); @@ -399,17 +403,20 @@ void GCTAEdisp2D::write(GFitsBinTable& hdu) const ***************************************************************************/ void GCTAEdisp2D::save(const std::string& filename, const bool& clobber) const { + // Create file name + GFilename fname(filename); + // Create binary table GFitsBinTable table; - table.extname("ENERGY DISPERSION"); + table.extname(fname.extname("ENERGY DISPERSON")); - // Write the Energy dispersion table + // Write the energy dispersion table write(table); // Create FITS file, append table, and write into the file GFits fits; fits.append(table); - fits.saveto(filename, clobber); + fits.saveto(fname.filename(), clobber); // Return return; diff --git a/inst/cta/src/GCTAPsf2D.cpp b/inst/cta/src/GCTAPsf2D.cpp index 4bef47c..fec7bf5 100644 --- a/inst/cta/src/GCTAPsf2D.cpp +++ b/inst/cta/src/GCTAPsf2D.cpp @@ -32,13 +32,14 @@ #include "GTools.hpp" #include "GException.hpp" #include "GMath.hpp" +#include "GFilename.hpp" #include "GFits.hpp" #include "GFitsBinTable.hpp" #include "GCTAPsf2D.hpp" #include "GCTAException.hpp" /* __ Method name definitions ____________________________________________ */ -#define G_READ "GCTAPsf2D::read(GFits&)" +#define G_READ "GCTAPsf2D::read(GFitsTable& table)" #define G_LOAD "GCTAPsf2D::load(std::string&)" #define G_CONTAINMENT_RADIUS "GCTAPsf2D::containment_radius(double&,"\ " double&, double&, double&, double&, double&, bool&)" @@ -276,24 +277,21 @@ GCTAPsf2D* GCTAPsf2D::clone(void) const /***********************************************************************//** * @brief Read PSF from FITS file * - * @param[in] fits FITS file pointer. + * @param[in] table FITS table. * * @exception GException::invalid_value * FITS file format differs from expectation. * - * Reads the PSF from the FITS file extension "POINT SPREAD FUNCTION". The data + * Reads the PSF from the FITS table. The data * are stored in m_psf which is of type GCTAResponseTable. * The energy axis will be set to log10. The offset angle axis and * sigma parameter columns will be set to radians. ***************************************************************************/ -void GCTAPsf2D::read(const GFits& fits) +void GCTAPsf2D::read(const GFitsTable& table) { // Clear response table m_psf.clear(); - // Get PSF table - const GFitsTable& table = *fits.table("POINT SPREAD FUNCTION"); - // Read PSF table m_psf.read(table); @@ -367,17 +365,23 @@ void GCTAPsf2D::write(GFitsBinTable& hdu) const ***************************************************************************/ void GCTAPsf2D::load(const std::string& filename) { - // Open PSF FITS file - GFits fits(filename); + // Create file name + GFilename fname(filename); + + // Allocate FITS file + GFits file; - // Read fits file - read(fits); + // Open FITS file + file.open(fname.filename()); - // Close PSF FITS file - fits.close(); + // Get PSFa table + const GFitsTable& table = *file.table(fname.extname("POINT SPREAD FUNCTION")); - // Store filename - m_filename = filename; + // Read PSF from table + read(table); + + // Close FITS file + file.close(); // Return return; @@ -394,9 +398,12 @@ void GCTAPsf2D::load(const std::string& filename) ***************************************************************************/ void GCTAPsf2D::save(const std::string& filename, const bool& clobber) const { + // Create file name + GFilename fname(filename); + // Create binary table GFitsBinTable table; - table.extname("POINT SPREAD FUNCTION"); + table.extname(fname.extname("POINT SPREAD FUNCTION")); // Write the PSF table write(table); @@ -404,7 +411,7 @@ void GCTAPsf2D::save(const std::string& filename, const bool& clobber) const // Create FITS file, append table, and write into the file GFits fits; fits.append(table); - fits.saveto(filename, clobber); + fits.saveto(fname.filename(), clobber); // Return return; diff --git a/inst/cta/src/GCTAPsfKing.cpp b/inst/cta/src/GCTAPsfKing.cpp index 70dd660..0bffc1b 100644 --- a/inst/cta/src/GCTAPsfKing.cpp +++ b/inst/cta/src/GCTAPsfKing.cpp @@ -32,13 +32,14 @@ #include "GTools.hpp" #include "GException.hpp" #include "GMath.hpp" +#include "GFilename.hpp" #include "GFits.hpp" #include "GFitsBinTable.hpp" #include "GCTAPsfKing.hpp" #include "GCTAException.hpp" /* __ Method name definitions ____________________________________________ */ -#define G_READ "GCTAPsfKing::read(GFits&)" +#define G_READ "GCTAPsfKing::read(GFitsTable& table)" #define G_CONTAINMENT_RADIUS "GCTAPsfKing::containment_radius(double&,"\ " double&, double&, double&, double&, double&, bool&)" #define G_UPDATE "GCTAPsfKing::update(double&, double&)" @@ -277,24 +278,21 @@ GCTAPsfKing* GCTAPsfKing::clone(void) const /***********************************************************************//** * @brief Read PSF from FITS file * - * @param[in] fits FITS file pointer. + * @param[in] table FITS table. * * @exception GException::invalid_value * FITS file format differs from expectation. * - * Reads the PSF from the FITS file extension "POINT SPREAD FUNCTION". The + * Reads the PSF from the FITS table. The * data are stored in m_psf which is of type GCTAResponseTable. * The energy axis will be set to log10. The offset angle axis and * sigma parameter columns will be set to radians. ***************************************************************************/ -void GCTAPsfKing::read(const GFits& fits) +void GCTAPsfKing::read(const GFitsTable& table) { // Clear response table m_psf.clear(); - // Get PSF table - const GFitsTable& table = *fits.table("POINT SPREAD FUNCTION"); - // Read PSF table m_psf.read(table); @@ -358,17 +356,23 @@ void GCTAPsfKing::write(GFitsBinTable& hdu) const ***************************************************************************/ void GCTAPsfKing::load(const std::string& filename) { - // Open PSF FITS file - GFits file(filename); + // Create file name + GFilename fname(filename); - // Read fits file - read(file); + // Allocate FITS file + GFits file; - // Close PSF FITS file - file.close(); + // Open FITS file + file.open(fname.filename()); + + // Get PSFa table + const GFitsTable& table = *file.table(fname.extname("POINT SPREAD FUNCTION")); - // Store filename - m_filename = filename; + // Read PSF from table + read(table); + + // Close FITS file + file.close(); // Return return; @@ -384,9 +388,12 @@ void GCTAPsfKing::load(const std::string& filename) ***************************************************************************/ void GCTAPsfKing::save(const std::string& filename, const bool& clobber) const { + // Create file name + GFilename fname(filename); + // Create binary table GFitsBinTable table; - table.extname("POINT SPREAD FUNCTION"); + table.extname(fname.extname("POINT SPREAD FUNCTION")); // Write the PSF table write(table); @@ -394,7 +401,7 @@ void GCTAPsfKing::save(const std::string& filename, const bool& clobber) const // Create FITS file, append table, and write into the file GFits fits; fits.append(table); - fits.saveto(filename, clobber); + fits.saveto(fname.filename(), clobber); // Return return; diff --git a/inst/cta/src/GCTAPsfVector.cpp b/inst/cta/src/GCTAPsfVector.cpp index f241f50..8978d46 100644 --- a/inst/cta/src/GCTAPsfVector.cpp +++ b/inst/cta/src/GCTAPsfVector.cpp @@ -31,6 +31,7 @@ #include #include "GTools.hpp" #include "GMath.hpp" +#include "GFilename.hpp" #include "GFitsTable.hpp" #include "GFitsTableCol.hpp" #include "GCTAPsfVector.hpp" @@ -256,21 +257,24 @@ GCTAPsfVector* GCTAPsfVector::clone(void) const ***************************************************************************/ void GCTAPsfVector::load(const std::string& filename) { - // Open PSF FITS file - GFits file(filename); + // Create file name + GFilename fname(filename); - // Get PSF table - const GFitsTable& table = *file.table(1); + // Allocate FITS file + GFits file; - // Read PSF + // Open FITS file + file.open(fname.filename()); + + // Get PSFa table + const GFitsTable& table = *file.table(fname.extname("PSF")); + + // Read PSF from table read(table); - // Close PSF FITS file + // Close FITS file file.close(); - // Store filename - m_filename = filename; - // Return return; }