Commit 320e8a1f978a9f30f2ee709c44e628dd46651904
1 parent
7beb30a2
Remove extname argument from GEbounds load constructor and load and save methods.
Showing
3 changed files
with
24 additions
and
28 deletions
include/GEbounds.hpp
| ... | ... | @@ -60,8 +60,7 @@ public: |
| 60 | 60 | GEbounds(const GEnergy& emin, const GEnergy& emax); |
| 61 | 61 | GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax, |
| 62 | 62 | const bool& log = true); |
| 63 | - GEbounds(const std::string& filename, | |
| 64 | - const std::string& extname = "EBOUNDS"); | |
| 63 | + GEbounds(const std::string& filename); | |
| 65 | 64 | virtual ~GEbounds(void); |
| 66 | 65 | |
| 67 | 66 | // Operators |
| ... | ... | @@ -82,11 +81,9 @@ public: |
| 82 | 81 | void extend(const GEbounds& ebds); |
| 83 | 82 | void set_lin(const int& num, const GEnergy& emin, const GEnergy& emax); |
| 84 | 83 | void set_log(const int& num, const GEnergy& emin, const GEnergy& emax); |
| 85 | - void load(const std::string& filename, | |
| 86 | - const std::string& extname = "EBOUNDS"); | |
| 84 | + void load(const std::string& filename); | |
| 87 | 85 | void save(const std::string& filename, |
| 88 | 86 | const bool& clobber = false, |
| 89 | - const std::string& extname = "EBOUNDS", | |
| 90 | 87 | const std::string& unit = "keV") const; |
| 91 | 88 | void read(const GFitsTable& table); |
| 92 | 89 | void write(GFits& file, | ... | ... |
pyext/GEbounds.i
| ... | ... | @@ -44,8 +44,7 @@ public: |
| 44 | 44 | GEbounds(const GEnergy& emin, const GEnergy& emax); |
| 45 | 45 | GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax, |
| 46 | 46 | const bool& log = true); |
| 47 | - GEbounds(const std::string& filename, | |
| 48 | - const std::string& extname = "EBOUNDS"); | |
| 47 | + GEbounds(const std::string& filename); | |
| 49 | 48 | virtual ~GEbounds(void); |
| 50 | 49 | |
| 51 | 50 | // Methods |
| ... | ... | @@ -63,11 +62,9 @@ public: |
| 63 | 62 | void extend(const GEbounds& ebds); |
| 64 | 63 | void set_lin(const int& num, const GEnergy& emin, const GEnergy& emax); |
| 65 | 64 | void set_log(const int& num, const GEnergy& emin, const GEnergy& emax); |
| 66 | - void load(const std::string& filename, | |
| 67 | - const std::string& extname = "EBOUNDS"); | |
| 65 | + void load(const std::string& filename); | |
| 68 | 66 | void save(const std::string& filename, |
| 69 | 67 | const bool& clobber = false, |
| 70 | - const std::string& extname = "EBOUNDS", | |
| 71 | 68 | const std::string& unit = "keV") const; |
| 72 | 69 | void read(const GFitsTable& table); |
| 73 | 70 | void write(GFits& file, | ... | ... |
src/obs/GEbounds.cpp
| ... | ... | @@ -29,9 +29,9 @@ |
| 29 | 29 | #include <config.h> |
| 30 | 30 | #endif |
| 31 | 31 | #include <cmath> |
| 32 | -//#include <iostream> | |
| 33 | 32 | #include "GException.hpp" |
| 34 | 33 | #include "GTools.hpp" |
| 34 | +#include "GFilename.hpp" | |
| 35 | 35 | #include "GEbounds.hpp" |
| 36 | 36 | #include "GFits.hpp" |
| 37 | 37 | #include "GFitsTable.hpp" |
| ... | ... | @@ -170,15 +170,14 @@ GEbounds::GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax, |
| 170 | 170 | * @brief Load constructor |
| 171 | 171 | * |
| 172 | 172 | * @param[in] filename FITS filename. |
| 173 | - * @param[in] extname FITS extension name (defaults to "EBOUNDS"). | |
| 174 | 173 | ***************************************************************************/ |
| 175 | -GEbounds::GEbounds(const std::string& filename, const std::string& extname) | |
| 174 | +GEbounds::GEbounds(const std::string& filename) | |
| 176 | 175 | { |
| 177 | 176 | // Initialise members |
| 178 | 177 | init_members(); |
| 179 | 178 | |
| 180 | 179 | // Load FITS file |
| 181 | - load(filename, extname); | |
| 180 | + load(filename); | |
| 182 | 181 | |
| 183 | 182 | // Return |
| 184 | 183 | return; |
| ... | ... | @@ -568,21 +567,23 @@ void GEbounds::set_log(const int& num, const GEnergy& emin, const GEnergy& emax) |
| 568 | 567 | /***********************************************************************//** |
| 569 | 568 | * @brief Load energy boundaries from FITS file |
| 570 | 569 | * |
| 571 | - * @param[in] filename FITS filename. | |
| 572 | - * @param[in] extname FITS extension name (defaults to "EBOUNDS"). | |
| 570 | + * @param[in] filename FITS file name. | |
| 573 | 571 | * |
| 574 | - * Loads the energy boundaries from FITS file. | |
| 572 | + * Loads the energy boundaries from a FITS file. | |
| 575 | 573 | ***************************************************************************/ |
| 576 | -void GEbounds::load(const std::string& filename, const std::string& extname) | |
| 574 | +void GEbounds::load(const std::string& filename) | |
| 577 | 575 | { |
| 576 | + // Create file name | |
| 577 | + GFilename fname(filename); | |
| 578 | + | |
| 578 | 579 | // Allocate FITS file |
| 579 | 580 | GFits file; |
| 580 | 581 | |
| 581 | 582 | // Open FITS file |
| 582 | - file.open(filename); | |
| 583 | + file.open(fname.filename()); | |
| 583 | 584 | |
| 584 | 585 | // Get energy boundary table |
| 585 | - const GFitsTable& table = *file.table(extname); | |
| 586 | + const GFitsTable& table = *file.table(fname.extname("EBOUNDS")); | |
| 586 | 587 | |
| 587 | 588 | // Read energy boundaries from table |
| 588 | 589 | read(table); |
| ... | ... | @@ -598,26 +599,27 @@ void GEbounds::load(const std::string& filename, const std::string& extname) |
| 598 | 599 | /***********************************************************************//** |
| 599 | 600 | * @brief Save energy boundaries into FITS file |
| 600 | 601 | * |
| 601 | - * @param[in] filename FITS filename. | |
| 602 | - * @param[in] clobber Overwrite any existing file (defaults to false)? | |
| 603 | - * @param[in] extname Energy boundary extension name (defaults to "EBOUNDS"). | |
| 604 | - * @param[in] unit Energy units (defaults to "keV") | |
| 602 | + * @param[in] filename FITS file name. | |
| 603 | + * @param[in] clobber Overwrite any existing file (default: false)? | |
| 604 | + * @param[in] unit Energy units (default: "keV") | |
| 605 | 605 | * |
| 606 | - * Saves the energy boundaries into extension @p extname of a FITS file. | |
| 606 | + * Saves the energy boundaries into a FITS file. | |
| 607 | 607 | ***************************************************************************/ |
| 608 | 608 | void GEbounds::save(const std::string& filename, |
| 609 | 609 | const bool& clobber, |
| 610 | - const std::string& extname, | |
| 611 | 610 | const std::string& unit) const |
| 612 | 611 | { |
| 612 | + // Create file name | |
| 613 | + GFilename fname(filename); | |
| 614 | + | |
| 613 | 615 | // Allocate FITS file |
| 614 | 616 | GFits file; |
| 615 | 617 | |
| 616 | 618 | // Write energy boundaries to FITS file |
| 617 | - write(file, extname, unit); | |
| 619 | + write(file, fname.extname("EBOUNDS"), unit); | |
| 618 | 620 | |
| 619 | 621 | // Save to file |
| 620 | - file.saveto(filename, clobber); | |
| 622 | + file.saveto(fname.filename(), clobber); | |
| 621 | 623 | |
| 622 | 624 | // Return |
| 623 | 625 | return; | ... | ... |