From 320e8a1f978a9f30f2ee709c44e628dd46651904 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Sat, 12 Dec 2015 08:51:24 +0100 Subject: [PATCH] Remove extname argument from GEbounds load constructor and load and save methods. --- include/GEbounds.hpp | 7 ++----- pyext/GEbounds.i | 7 ++----- src/obs/GEbounds.cpp | 38 ++++++++++++++++++++------------------ 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/include/GEbounds.hpp b/include/GEbounds.hpp index 392e9b4..00d1e1d 100644 --- a/include/GEbounds.hpp +++ b/include/GEbounds.hpp @@ -60,8 +60,7 @@ public: GEbounds(const GEnergy& emin, const GEnergy& emax); GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax, const bool& log = true); - GEbounds(const std::string& filename, - const std::string& extname = "EBOUNDS"); + GEbounds(const std::string& filename); virtual ~GEbounds(void); // Operators @@ -82,11 +81,9 @@ public: void extend(const GEbounds& ebds); void set_lin(const int& num, const GEnergy& emin, const GEnergy& emax); void set_log(const int& num, const GEnergy& emin, const GEnergy& emax); - void load(const std::string& filename, - const std::string& extname = "EBOUNDS"); + void load(const std::string& filename); void save(const std::string& filename, const bool& clobber = false, - const std::string& extname = "EBOUNDS", const std::string& unit = "keV") const; void read(const GFitsTable& table); void write(GFits& file, diff --git a/pyext/GEbounds.i b/pyext/GEbounds.i index f1bc2ea..aeef309 100644 --- a/pyext/GEbounds.i +++ b/pyext/GEbounds.i @@ -44,8 +44,7 @@ public: GEbounds(const GEnergy& emin, const GEnergy& emax); GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax, const bool& log = true); - GEbounds(const std::string& filename, - const std::string& extname = "EBOUNDS"); + GEbounds(const std::string& filename); virtual ~GEbounds(void); // Methods @@ -63,11 +62,9 @@ public: void extend(const GEbounds& ebds); void set_lin(const int& num, const GEnergy& emin, const GEnergy& emax); void set_log(const int& num, const GEnergy& emin, const GEnergy& emax); - void load(const std::string& filename, - const std::string& extname = "EBOUNDS"); + void load(const std::string& filename); void save(const std::string& filename, const bool& clobber = false, - const std::string& extname = "EBOUNDS", const std::string& unit = "keV") const; void read(const GFitsTable& table); void write(GFits& file, diff --git a/src/obs/GEbounds.cpp b/src/obs/GEbounds.cpp index 913df86..71a6fda 100644 --- a/src/obs/GEbounds.cpp +++ b/src/obs/GEbounds.cpp @@ -29,9 +29,9 @@ #include #endif #include -//#include #include "GException.hpp" #include "GTools.hpp" +#include "GFilename.hpp" #include "GEbounds.hpp" #include "GFits.hpp" #include "GFitsTable.hpp" @@ -170,15 +170,14 @@ GEbounds::GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax, * @brief Load constructor * * @param[in] filename FITS filename. - * @param[in] extname FITS extension name (defaults to "EBOUNDS"). ***************************************************************************/ -GEbounds::GEbounds(const std::string& filename, const std::string& extname) +GEbounds::GEbounds(const std::string& filename) { // Initialise members init_members(); // Load FITS file - load(filename, extname); + load(filename); // Return return; @@ -568,21 +567,23 @@ void GEbounds::set_log(const int& num, const GEnergy& emin, const GEnergy& emax) /***********************************************************************//** * @brief Load energy boundaries from FITS file * - * @param[in] filename FITS filename. - * @param[in] extname FITS extension name (defaults to "EBOUNDS"). + * @param[in] filename FITS file name. * - * Loads the energy boundaries from FITS file. + * Loads the energy boundaries from a FITS file. ***************************************************************************/ -void GEbounds::load(const std::string& filename, const std::string& extname) +void GEbounds::load(const std::string& filename) { + // Create file name + GFilename fname(filename); + // Allocate FITS file GFits file; // Open FITS file - file.open(filename); + file.open(fname.filename()); // Get energy boundary table - const GFitsTable& table = *file.table(extname); + const GFitsTable& table = *file.table(fname.extname("EBOUNDS")); // Read energy boundaries from table read(table); @@ -598,26 +599,27 @@ void GEbounds::load(const std::string& filename, const std::string& extname) /***********************************************************************//** * @brief Save energy boundaries into FITS file * - * @param[in] filename FITS filename. - * @param[in] clobber Overwrite any existing file (defaults to false)? - * @param[in] extname Energy boundary extension name (defaults to "EBOUNDS"). - * @param[in] unit Energy units (defaults to "keV") + * @param[in] filename FITS file name. + * @param[in] clobber Overwrite any existing file (default: false)? + * @param[in] unit Energy units (default: "keV") * - * Saves the energy boundaries into extension @p extname of a FITS file. + * Saves the energy boundaries into a FITS file. ***************************************************************************/ void GEbounds::save(const std::string& filename, const bool& clobber, - const std::string& extname, const std::string& unit) const { + // Create file name + GFilename fname(filename); + // Allocate FITS file GFits file; // Write energy boundaries to FITS file - write(file, extname, unit); + write(file, fname.extname("EBOUNDS"), unit); // Save to file - file.saveto(filename, clobber); + file.saveto(fname.filename(), clobber); // Return return; -- libgit2 0.21.4