Commit 452c7462fbd4ca7128461ca18a7c9a8c9df6151a
1 parent
0383e8da
Use GFilename for filename arguments in GEbounds and GGti.
Showing
7 changed files
with
45 additions
and
43 deletions
NEWS
| @@ -24,6 +24,14 @@ The following methods have been renamed: | @@ -24,6 +24,14 @@ The following methods have been renamed: | ||
| 24 | - GCTAResponseTable::tables(), was formerly GCTAResponseTable::size() | 24 | - GCTAResponseTable::tables(), was formerly GCTAResponseTable::size() |
| 25 | - GCTAResponseTable::axis_bins(), was formerly GCTAResponseTable::axis() | 25 | - GCTAResponseTable::axis_bins(), was formerly GCTAResponseTable::axis() |
| 26 | 26 | ||
| 27 | +The following methods now take a GFilename argument instead of std::string: | ||
| 28 | +- GEbounds(const GFilename&) | ||
| 29 | +- GEbounds::load() | ||
| 30 | +- GEbounds::save() | ||
| 31 | +- GGti(const GFilename&) | ||
| 32 | +- GGti::load() | ||
| 33 | +- GGti::save() | ||
| 34 | + | ||
| 27 | The return value has been changed for the following methods: | 35 | The return value has been changed for the following methods: |
| 28 | - GFits::filename() returns now GFilename instead of std::string | 36 | - GFits::filename() returns now GFilename instead of std::string |
| 29 | - GCTAObservation::eventtype() returns now std::string instead of const std::string& | 37 | - GCTAObservation::eventtype() returns now std::string instead of const std::string& |
include/GEbounds.hpp
| 1 | /*************************************************************************** | 1 | /*************************************************************************** |
| 2 | * GEbounds.hpp - Energy boundaries class * | 2 | * GEbounds.hpp - Energy boundaries class * |
| 3 | * ----------------------------------------------------------------------- * | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2015 by Juergen Knoedlseder * | 4 | + * copyright (C) 2009-2016 by Juergen Knoedlseder * |
| 5 | * ----------------------------------------------------------------------- * | 5 | * ----------------------------------------------------------------------- * |
| 6 | * * | 6 | * * |
| 7 | * This program is free software: you can redistribute it and/or modify * | 7 | * This program is free software: you can redistribute it and/or modify * |
| @@ -36,6 +36,7 @@ | @@ -36,6 +36,7 @@ | ||
| 36 | class GXmlElement; | 36 | class GXmlElement; |
| 37 | class GFits; | 37 | class GFits; |
| 38 | class GFitsTable; | 38 | class GFitsTable; |
| 39 | +class GFilename; | ||
| 39 | 40 | ||
| 40 | 41 | ||
| 41 | /***********************************************************************//** | 42 | /***********************************************************************//** |
| @@ -55,7 +56,7 @@ class GEbounds : public GContainer { | @@ -55,7 +56,7 @@ class GEbounds : public GContainer { | ||
| 55 | public: | 56 | public: |
| 56 | // Constructors and destructors | 57 | // Constructors and destructors |
| 57 | GEbounds(void); | 58 | GEbounds(void); |
| 58 | - explicit GEbounds(const std::string& filename); | 59 | + explicit GEbounds(const GFilename& filename); |
| 59 | explicit GEbounds(const GXmlElement& xml); | 60 | explicit GEbounds(const GXmlElement& xml); |
| 60 | GEbounds(const GEbounds& ebds); | 61 | GEbounds(const GEbounds& ebds); |
| 61 | GEbounds(const GEnergy& emin, const GEnergy& emax); | 62 | GEbounds(const GEnergy& emin, const GEnergy& emax); |
| @@ -81,8 +82,8 @@ public: | @@ -81,8 +82,8 @@ public: | ||
| 81 | void extend(const GEbounds& ebds); | 82 | void extend(const GEbounds& ebds); |
| 82 | void set_lin(const int& num, const GEnergy& emin, const GEnergy& emax); | 83 | void set_lin(const int& num, const GEnergy& emin, const GEnergy& emax); |
| 83 | void set_log(const int& num, const GEnergy& emin, const GEnergy& emax); | 84 | void set_log(const int& num, const GEnergy& emin, const GEnergy& emax); |
| 84 | - void load(const std::string& filename); | ||
| 85 | - void save(const std::string& filename, | 85 | + void load(const GFilename& filename); |
| 86 | + void save(const GFilename& filename, | ||
| 86 | const bool& clobber = false, | 87 | const bool& clobber = false, |
| 87 | const std::string& unit = "keV") const; | 88 | const std::string& unit = "keV") const; |
| 88 | void read(const GFitsTable& table); | 89 | void read(const GFitsTable& table); |
include/GGti.hpp
| @@ -32,6 +32,7 @@ | @@ -32,6 +32,7 @@ | ||
| 32 | #include "GContainer.hpp" | 32 | #include "GContainer.hpp" |
| 33 | #include "GTime.hpp" | 33 | #include "GTime.hpp" |
| 34 | #include "GTimeReference.hpp" | 34 | #include "GTimeReference.hpp" |
| 35 | +#include "GFilename.hpp" | ||
| 35 | 36 | ||
| 36 | /* __ Forward declarations _______________________________________________ */ | 37 | /* __ Forward declarations _______________________________________________ */ |
| 37 | class GXmlElement; | 38 | class GXmlElement; |
| @@ -58,7 +59,7 @@ class GGti : public GContainer { | @@ -58,7 +59,7 @@ class GGti : public GContainer { | ||
| 58 | public: | 59 | public: |
| 59 | // Constructors and destructors | 60 | // Constructors and destructors |
| 60 | GGti(void); | 61 | GGti(void); |
| 61 | - explicit GGti(const std::string& filename); | 62 | + explicit GGti(const GFilename& filename); |
| 62 | GGti(const GGti& gti); | 63 | GGti(const GGti& gti); |
| 63 | GGti(const GTime& tstart, const GTime& tstop); | 64 | GGti(const GTime& tstart, const GTime& tstop); |
| 64 | explicit GGti(const GXmlElement& xml); | 65 | explicit GGti(const GXmlElement& xml); |
| @@ -82,8 +83,8 @@ public: | @@ -82,8 +83,8 @@ public: | ||
| 82 | void remove(const int& index); | 83 | void remove(const int& index); |
| 83 | void reserve(const int& num); | 84 | void reserve(const int& num); |
| 84 | void extend(const GGti& gti); | 85 | void extend(const GGti& gti); |
| 85 | - void load(const std::string& filename); | ||
| 86 | - void save(const std::string& filename, | 86 | + void load(const GFilename& filename); |
| 87 | + void save(const GFilename& filename, | ||
| 87 | const bool& clobber = false) const; | 88 | const bool& clobber = false) const; |
| 88 | void read(const GFitsTable& table); | 89 | void read(const GFitsTable& table); |
| 89 | void write(GFits& fits, | 90 | void write(GFits& fits, |
| @@ -118,7 +119,7 @@ protected: | @@ -118,7 +119,7 @@ protected: | ||
| 118 | GTime *m_start; //!< Array of start times | 119 | GTime *m_start; //!< Array of start times |
| 119 | GTime *m_stop; //!< Array of stop times | 120 | GTime *m_stop; //!< Array of stop times |
| 120 | GTimeReference m_reference; //!< Time reference | 121 | GTimeReference m_reference; //!< Time reference |
| 121 | - std::string m_xml_filename; //!< XML filename | 122 | + GFilename m_xml_filename; //!< XML filename |
| 122 | }; | 123 | }; |
| 123 | 124 | ||
| 124 | 125 |
pyext/GEbounds.i
| 1 | /*************************************************************************** | 1 | /*************************************************************************** |
| 2 | * GEbounds.i - Energy boundaries class * | 2 | * GEbounds.i - Energy boundaries class * |
| 3 | * ----------------------------------------------------------------------- * | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * |
| 5 | * ----------------------------------------------------------------------- * | 5 | * ----------------------------------------------------------------------- * |
| 6 | * * | 6 | * * |
| 7 | * This program is free software: you can redistribute it and/or modify * | 7 | * This program is free software: you can redistribute it and/or modify * |
| @@ -39,7 +39,7 @@ class GEbounds : public GContainer { | @@ -39,7 +39,7 @@ class GEbounds : public GContainer { | ||
| 39 | public: | 39 | public: |
| 40 | // Constructors and destructors | 40 | // Constructors and destructors |
| 41 | GEbounds(void); | 41 | GEbounds(void); |
| 42 | - explicit GEbounds(const std::string& filename); | 42 | + explicit GEbounds(const GFilename& filename); |
| 43 | explicit GEbounds(const GXmlElement& xml); | 43 | explicit GEbounds(const GXmlElement& xml); |
| 44 | GEbounds(const GEbounds& ebds); | 44 | GEbounds(const GEbounds& ebds); |
| 45 | GEbounds(const GEnergy& emin, const GEnergy& emax); | 45 | GEbounds(const GEnergy& emin, const GEnergy& emax); |
| @@ -62,8 +62,8 @@ public: | @@ -62,8 +62,8 @@ public: | ||
| 62 | void extend(const GEbounds& ebds); | 62 | void extend(const GEbounds& ebds); |
| 63 | void set_lin(const int& num, const GEnergy& emin, const GEnergy& emax); | 63 | void set_lin(const int& num, const GEnergy& emin, const GEnergy& emax); |
| 64 | void set_log(const int& num, const GEnergy& emin, const GEnergy& emax); | 64 | void set_log(const int& num, const GEnergy& emin, const GEnergy& emax); |
| 65 | - void load(const std::string& filename); | ||
| 66 | - void save(const std::string& filename, | 65 | + void load(const GFilename& filename); |
| 66 | + void save(const GFilename& filename, | ||
| 67 | const bool& clobber = false, | 67 | const bool& clobber = false, |
| 68 | const std::string& unit = "keV") const; | 68 | const std::string& unit = "keV") const; |
| 69 | void read(const GFitsTable& table); | 69 | void read(const GFitsTable& table); |
pyext/GGti.i
| @@ -40,7 +40,7 @@ class GGti : public GBase { | @@ -40,7 +40,7 @@ class GGti : public GBase { | ||
| 40 | public: | 40 | public: |
| 41 | // Constructors and destructors | 41 | // Constructors and destructors |
| 42 | GGti(void); | 42 | GGti(void); |
| 43 | - explicit GGti(const std::string& filename); | 43 | + explicit GGti(const GFilename& filename); |
| 44 | GGti(const GGti& gti); | 44 | GGti(const GGti& gti); |
| 45 | GGti(const GTime& tstart, const GTime& tstop); | 45 | GGti(const GTime& tstart, const GTime& tstop); |
| 46 | explicit GGti(const GXmlElement& xml); | 46 | explicit GGti(const GXmlElement& xml); |
| @@ -61,8 +61,8 @@ public: | @@ -61,8 +61,8 @@ public: | ||
| 61 | void remove(const int& index); | 61 | void remove(const int& index); |
| 62 | void reserve(const int& num); | 62 | void reserve(const int& num); |
| 63 | void extend(const GGti& gti); | 63 | void extend(const GGti& gti); |
| 64 | - void load(const std::string& filename); | ||
| 65 | - void save(const std::string& filename, | 64 | + void load(const GFilename& filename); |
| 65 | + void save(const GFilename& filename, | ||
| 66 | const bool& clobber = false) const; | 66 | const bool& clobber = false) const; |
| 67 | void read(const GFitsTable& table); | 67 | void read(const GFitsTable& table); |
| 68 | void write(GFits& fits, | 68 | void write(GFits& fits, |
src/obs/GEbounds.cpp
| @@ -83,7 +83,7 @@ GEbounds::GEbounds(void) | @@ -83,7 +83,7 @@ GEbounds::GEbounds(void) | ||
| 83 | * | 83 | * |
| 84 | * Constructs energy boundaries from a FITS file. | 84 | * Constructs energy boundaries from a FITS file. |
| 85 | ***************************************************************************/ | 85 | ***************************************************************************/ |
| 86 | -GEbounds::GEbounds(const std::string& filename) | 86 | +GEbounds::GEbounds(const GFilename& filename) |
| 87 | { | 87 | { |
| 88 | // Initialise members | 88 | // Initialise members |
| 89 | init_members(); | 89 | init_members(); |
| @@ -576,19 +576,16 @@ void GEbounds::set_log(const int& num, const GEnergy& emin, const GEnergy& emax) | @@ -576,19 +576,16 @@ void GEbounds::set_log(const int& num, const GEnergy& emin, const GEnergy& emax) | ||
| 576 | * If no extension name is provided, the energy boundaries are loaded from | 576 | * If no extension name is provided, the energy boundaries are loaded from |
| 577 | * the "EBOUNDS" extension. | 577 | * the "EBOUNDS" extension. |
| 578 | ***************************************************************************/ | 578 | ***************************************************************************/ |
| 579 | -void GEbounds::load(const std::string& filename) | 579 | +void GEbounds::load(const GFilename& filename) |
| 580 | { | 580 | { |
| 581 | - // Create file name | ||
| 582 | - GFilename fname(filename); | ||
| 583 | - | ||
| 584 | // Allocate FITS file | 581 | // Allocate FITS file |
| 585 | GFits file; | 582 | GFits file; |
| 586 | 583 | ||
| 587 | // Open FITS file | 584 | // Open FITS file |
| 588 | - file.open(fname.filename()); | 585 | + file.open(filename.filename()); |
| 589 | 586 | ||
| 590 | // Get energy boundary table | 587 | // Get energy boundary table |
| 591 | - const GFitsTable& table = *file.table(fname.extname("EBOUNDS")); | 588 | + const GFitsTable& table = *file.table(filename.extname("EBOUNDS")); |
| 592 | 589 | ||
| 593 | // Read energy boundaries from table | 590 | // Read energy boundaries from table |
| 594 | read(table); | 591 | read(table); |
| @@ -613,21 +610,18 @@ void GEbounds::load(const std::string& filename) | @@ -613,21 +610,18 @@ void GEbounds::load(const std::string& filename) | ||
| 613 | * If no extension name is provided, the energy boundaries are saved into | 610 | * If no extension name is provided, the energy boundaries are saved into |
| 614 | * an "EBOUNDS" extension. | 611 | * an "EBOUNDS" extension. |
| 615 | ***************************************************************************/ | 612 | ***************************************************************************/ |
| 616 | -void GEbounds::save(const std::string& filename, | 613 | +void GEbounds::save(const GFilename& filename, |
| 617 | const bool& clobber, | 614 | const bool& clobber, |
| 618 | const std::string& unit) const | 615 | const std::string& unit) const |
| 619 | { | 616 | { |
| 620 | - // Create file name | ||
| 621 | - GFilename fname(filename); | ||
| 622 | - | ||
| 623 | // Allocate FITS file | 617 | // Allocate FITS file |
| 624 | GFits file; | 618 | GFits file; |
| 625 | 619 | ||
| 626 | // Write energy boundaries to FITS file | 620 | // Write energy boundaries to FITS file |
| 627 | - write(file, fname.extname("EBOUNDS"), unit); | 621 | + write(file, filename.extname("EBOUNDS"), unit); |
| 628 | 622 | ||
| 629 | // Save to file | 623 | // Save to file |
| 630 | - file.saveto(fname.filename(), clobber); | 624 | + file.saveto(filename.filename(), clobber); |
| 631 | 625 | ||
| 632 | // Return | 626 | // Return |
| 633 | return; | 627 | return; |
src/obs/GGti.cpp
| @@ -62,6 +62,8 @@ | @@ -62,6 +62,8 @@ | ||
| 62 | 62 | ||
| 63 | /***********************************************************************//** | 63 | /***********************************************************************//** |
| 64 | * @brief Void constructor | 64 | * @brief Void constructor |
| 65 | + * | ||
| 66 | + * Constructs empty Good Time Intervals. | ||
| 65 | ***************************************************************************/ | 67 | ***************************************************************************/ |
| 66 | GGti::GGti(void) | 68 | GGti::GGti(void) |
| 67 | { | 69 | { |
| @@ -80,7 +82,7 @@ GGti::GGti(void) | @@ -80,7 +82,7 @@ GGti::GGti(void) | ||
| 80 | * | 82 | * |
| 81 | * Constructs Good Time Intervals from a FITS file. | 83 | * Constructs Good Time Intervals from a FITS file. |
| 82 | ***************************************************************************/ | 84 | ***************************************************************************/ |
| 83 | -GGti::GGti(const std::string& filename) | 85 | +GGti::GGti(const GFilename& filename) |
| 84 | { | 86 | { |
| 85 | // Initialise members | 87 | // Initialise members |
| 86 | init_members(); | 88 | init_members(); |
| @@ -97,6 +99,8 @@ GGti::GGti(const std::string& filename) | @@ -97,6 +99,8 @@ GGti::GGti(const std::string& filename) | ||
| 97 | * @brief Copy constructor | 99 | * @brief Copy constructor |
| 98 | * | 100 | * |
| 99 | * @param[in] gti Good Time Intervals. | 101 | * @param[in] gti Good Time Intervals. |
| 102 | + * | ||
| 103 | + * Constructs Good Time Intervals by coping other Good Time Intervals. | ||
| 100 | ***************************************************************************/ | 104 | ***************************************************************************/ |
| 101 | GGti::GGti(const GGti& gti) | 105 | GGti::GGti(const GGti& gti) |
| 102 | { | 106 | { |
| @@ -578,19 +582,16 @@ void GGti::extend(const GGti& gti) | @@ -578,19 +582,16 @@ void GGti::extend(const GGti& gti) | ||
| 578 | * If no extension name is provided in the @p filename, the Good Time | 582 | * If no extension name is provided in the @p filename, the Good Time |
| 579 | * Intervals are loaded from the "GTI" extension. | 583 | * Intervals are loaded from the "GTI" extension. |
| 580 | ***************************************************************************/ | 584 | ***************************************************************************/ |
| 581 | -void GGti::load(const std::string& filename) | 585 | +void GGti::load(const GFilename& filename) |
| 582 | { | 586 | { |
| 583 | - // Create file name | ||
| 584 | - GFilename fname(filename); | ||
| 585 | - | ||
| 586 | // Allocate FITS file | 587 | // Allocate FITS file |
| 587 | GFits file; | 588 | GFits file; |
| 588 | 589 | ||
| 589 | // Open FITS file | 590 | // Open FITS file |
| 590 | - file.open(fname.filename()); | 591 | + file.open(filename.filename()); |
| 591 | 592 | ||
| 592 | // Get GTI table | 593 | // Get GTI table |
| 593 | - const GFitsTable& table = *file.table(fname.extname("GTI")); | 594 | + const GFitsTable& table = *file.table(filename.extname("GTI")); |
| 594 | 595 | ||
| 595 | // Read GTI from table | 596 | // Read GTI from table |
| 596 | read(table); | 597 | read(table); |
| @@ -619,16 +620,13 @@ void GGti::load(const std::string& filename) | @@ -619,16 +620,13 @@ void GGti::load(const std::string& filename) | ||
| 619 | * An existing file will only be modified if the @p clobber flag is set to | 620 | * An existing file will only be modified if the @p clobber flag is set to |
| 620 | * true. | 621 | * true. |
| 621 | ***************************************************************************/ | 622 | ***************************************************************************/ |
| 622 | -void GGti::save(const std::string& filename, const bool& clobber) const | 623 | +void GGti::save(const GFilename& filename, const bool& clobber) const |
| 623 | { | 624 | { |
| 624 | - // Create file name | ||
| 625 | - GFilename fname(filename); | ||
| 626 | - | ||
| 627 | // Open or create FITS file | 625 | // Open or create FITS file |
| 628 | - GFits fits(fname.filename(), true); | 626 | + GFits fits(filename.filename(), true); |
| 629 | 627 | ||
| 630 | // Write GTI to FITS object | 628 | // Write GTI to FITS object |
| 631 | - write(fits, fname.extname("GTI")); | 629 | + write(fits, filename.extname("GTI")); |
| 632 | 630 | ||
| 633 | // Save to file | 631 | // Save to file |
| 634 | fits.save(clobber); | 632 | fits.save(clobber); |
| @@ -835,7 +833,7 @@ void GGti::write(GXmlElement& xml) const | @@ -835,7 +833,7 @@ void GGti::write(GXmlElement& xml) const | ||
| 835 | if (!m_xml_filename.empty()) { | 833 | if (!m_xml_filename.empty()) { |
| 836 | 834 | ||
| 837 | // Write "file" attribute | 835 | // Write "file" attribute |
| 838 | - par->attribute("file", m_xml_filename); | 836 | + par->attribute("file", m_xml_filename.fullname()); |
| 839 | 837 | ||
| 840 | // Write GTI file | 838 | // Write GTI file |
| 841 | save(m_xml_filename, true); | 839 | save(m_xml_filename, true); |
| @@ -1064,7 +1062,7 @@ std::string GGti::print(const GChatter& chatter) const | @@ -1064,7 +1062,7 @@ std::string GGti::print(const GChatter& chatter) const | ||
| 1064 | // Optionally append XML filename | 1062 | // Optionally append XML filename |
| 1065 | if (!m_xml_filename.empty()) { | 1063 | if (!m_xml_filename.empty()) { |
| 1066 | result.append("\n"+gammalib::parformat("File name")); | 1064 | result.append("\n"+gammalib::parformat("File name")); |
| 1067 | - result.append(m_xml_filename); | 1065 | + result.append(m_xml_filename.fullname()); |
| 1068 | } | 1066 | } |
| 1069 | 1067 | ||
| 1070 | } // endif: chatter was not silent | 1068 | } // endif: chatter was not silent |