Commit fdd7ef48a643c60ec0ed1dfc96d52d3f29e7cc8f

Authored by Jürgen Knödlseder
1 parent c3bfe23e

Remove optional extname arguments from several classes.

Removed the optional extname argument from:
- GEbounds
- GEnergies
- GGti
- GNodeArray
- GCTAPointing
- GMWLObservation
- GMWLSpectrum
include/GEbounds.hpp
@@ -55,12 +55,12 @@ class GEbounds : public GContainer { @@ -55,12 +55,12 @@ class GEbounds : public GContainer {
55 public: 55 public:
56 // Constructors and destructors 56 // Constructors and destructors
57 GEbounds(void); 57 GEbounds(void);
58 - GEbounds(const GEbounds& ebds); 58 + explicit GEbounds(const std::string& filename);
59 explicit GEbounds(const GXmlElement& xml); 59 explicit GEbounds(const GXmlElement& xml);
  60 + GEbounds(const GEbounds& ebds);
60 GEbounds(const GEnergy& emin, const GEnergy& emax); 61 GEbounds(const GEnergy& emin, const GEnergy& emax);
61 GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax, 62 GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax,
62 const bool& log = true); 63 const bool& log = true);
63 - GEbounds(const std::string& filename);  
64 virtual ~GEbounds(void); 64 virtual ~GEbounds(void);
65 65
66 // Operators 66 // Operators
include/GEnergies.hpp
@@ -49,8 +49,7 @@ class GEnergies : public GContainer { @@ -49,8 +49,7 @@ class GEnergies : public GContainer {
49 public: 49 public:
50 // Constructors and destructors 50 // Constructors and destructors
51 GEnergies(void); 51 GEnergies(void);
52 - GEnergies(const std::string& filename,  
53 - const std::string& extname = "ENERGIES"); 52 + explicit GEnergies(const std::string& filename);
54 GEnergies(const GEnergies& energies); 53 GEnergies(const GEnergies& energies);
55 GEnergies(const int& num, const GEnergy& emin, const GEnergy& emax, 54 GEnergies(const int& num, const GEnergy& emin, const GEnergy& emax,
56 const bool& log = true); 55 const bool& log = true);
@@ -78,11 +77,9 @@ public: @@ -78,11 +77,9 @@ public:
78 const GEnergy& emax); 77 const GEnergy& emax);
79 void set_log(const int& num, const GEnergy& emin, 78 void set_log(const int& num, const GEnergy& emin,
80 const GEnergy& emax); 79 const GEnergy& emax);
81 - void load(const std::string& filename,  
82 - const std::string& extname = "ENERGIES"); 80 + void load(const std::string& filename);
83 void save(const std::string& filename, 81 void save(const std::string& filename,
84 - const bool& clobber = false,  
85 - const std::string& extname = "ENERGIES") const; 82 + const bool& clobber = false) const;
86 void read(const GFitsTable& table); 83 void read(const GFitsTable& table);
87 void write(GFits& file, 84 void write(GFits& file,
88 const std::string& extname = "ENERGIES") const; 85 const std::string& extname = "ENERGIES") const;
include/GGti.hpp
@@ -58,6 +58,7 @@ class GGti : public GContainer { @@ -58,6 +58,7 @@ class GGti : public GContainer {
58 public: 58 public:
59 // Constructors and destructors 59 // Constructors and destructors
60 GGti(void); 60 GGti(void);
  61 + explicit GGti(const std::string& filename);
61 GGti(const GGti& gti); 62 GGti(const GGti& gti);
62 GGti(const GTime& tstart, const GTime& tstop); 63 GGti(const GTime& tstart, const GTime& tstop);
63 explicit GGti(const GXmlElement& xml); 64 explicit GGti(const GXmlElement& xml);
@@ -81,11 +82,9 @@ public: @@ -81,11 +82,9 @@ public:
81 void remove(const int& index); 82 void remove(const int& index);
82 void reserve(const int& num); 83 void reserve(const int& num);
83 void extend(const GGti& gti); 84 void extend(const GGti& gti);
84 - void load(const std::string& filename,  
85 - const std::string& extname = "GTI"); 85 + void load(const std::string& filename);
86 void save(const std::string& filename, 86 void save(const std::string& filename,
87 - const bool& clobber = false,  
88 - const std::string& extname = "GTI") const; 87 + const bool& clobber = false) const;
89 void read(const GFitsTable& table); 88 void read(const GFitsTable& table);
90 void write(GFits& file, 89 void write(GFits& file,
91 const std::string& extname = "GTI") const; 90 const std::string& extname = "GTI") const;
include/GNodeArray.hpp
@@ -59,9 +59,10 @@ class GNodeArray : public GContainer { @@ -59,9 +59,10 @@ class GNodeArray : public GContainer {
59 public: 59 public:
60 // Constructors and destructors 60 // Constructors and destructors
61 GNodeArray(void); 61 GNodeArray(void);
62 - GNodeArray(const int& num, const double* array); 62 + explicit GNodeArray(const std::string& filename);
63 explicit GNodeArray(const GVector& vector); 63 explicit GNodeArray(const GVector& vector);
64 explicit GNodeArray(const std::vector<double>& vector); 64 explicit GNodeArray(const std::vector<double>& vector);
  65 + GNodeArray(const int& num, const double* array);
65 GNodeArray(const GNodeArray& array); 66 GNodeArray(const GNodeArray& array);
66 virtual ~GNodeArray(void); 67 virtual ~GNodeArray(void);
67 68
@@ -93,10 +94,9 @@ public: @@ -93,10 +94,9 @@ public:
93 const int& inx_right(void) const; 94 const int& inx_right(void) const;
94 const double& wgt_left(void) const; 95 const double& wgt_left(void) const;
95 const double& wgt_right(void) const; 96 const double& wgt_right(void) const;
96 - void load(const std::string& filename,  
97 - const std::string& extname = "NODES");  
98 - void save(const std::string& filename, const bool& clobber = false,  
99 - const std::string& extname = "NODES") const; 97 + void load(const std::string& filename);
  98 + void save(const std::string& filename,
  99 + const bool& clobber = false) const;
100 void read(const GFitsTable& table); 100 void read(const GFitsTable& table);
101 void write(GFits& file, 101 void write(GFits& file,
102 const std::string& extname = "NODES") const; 102 const std::string& extname = "NODES") const;
inst/cta/include/GCTAPointing.hpp
@@ -61,8 +61,7 @@ public: @@ -61,8 +61,7 @@ public:
61 GCTAPointing(void); 61 GCTAPointing(void);
62 explicit GCTAPointing(const GSkyDir& dir); 62 explicit GCTAPointing(const GSkyDir& dir);
63 explicit GCTAPointing(const GXmlElement& xml); 63 explicit GCTAPointing(const GXmlElement& xml);
64 - GCTAPointing(const std::string& filename,  
65 - const std::string& extname = "POINTING"); 64 + explicit GCTAPointing(const std::string& filename);
66 GCTAPointing(const GCTAPointing& pnt); 65 GCTAPointing(const GCTAPointing& pnt);
67 virtual ~GCTAPointing(void); 66 virtual ~GCTAPointing(void);
68 67
@@ -83,8 +82,7 @@ public: @@ -83,8 +82,7 @@ public:
83 void zenith(const double& zenith); 82 void zenith(const double& zenith);
84 void azimuth(const double& azimuth); 83 void azimuth(const double& azimuth);
85 GHorizDir dir_horiz(const GTime& time) const; 84 GHorizDir dir_horiz(const GTime& time) const;
86 - void load(const std::string& filename,  
87 - const std::string& extname = "POINTING"); 85 + void load(const std::string& filename);
88 void read(const GFitsTable& table); 86 void read(const GFitsTable& table);
89 void read(const GXmlElement& xml); 87 void read(const GXmlElement& xml);
90 void write(GXmlElement& xml) const; 88 void write(GXmlElement& xml) const;
inst/cta/pyext/GCTAPointing.i
@@ -40,8 +40,7 @@ public: @@ -40,8 +40,7 @@ public:
40 GCTAPointing(void); 40 GCTAPointing(void);
41 explicit GCTAPointing(const GSkyDir& dir); 41 explicit GCTAPointing(const GSkyDir& dir);
42 explicit GCTAPointing(const GXmlElement& xml); 42 explicit GCTAPointing(const GXmlElement& xml);
43 - GCTAPointing(const std::string& filename,  
44 - const std::string& extname = "POINTING"); 43 + explicit GCTAPointing(const std::string& filename);
45 GCTAPointing(const GCTAPointing& pnt); 44 GCTAPointing(const GCTAPointing& pnt);
46 virtual ~GCTAPointing(void); 45 virtual ~GCTAPointing(void);
47 46
@@ -59,8 +58,7 @@ public: @@ -59,8 +58,7 @@ public:
59 void zenith(const double& zenith); 58 void zenith(const double& zenith);
60 void azimuth(const double& azimuth); 59 void azimuth(const double& azimuth);
61 GHorizDir dir_horiz(const GTime& time) const; 60 GHorizDir dir_horiz(const GTime& time) const;
62 - void load(const std::string& filename,  
63 - const std::string& extname = "POINTING"); 61 + void load(const std::string& filename);
64 void read(const GFitsTable& table); 62 void read(const GFitsTable& table);
65 void read(const GXmlElement& xml); 63 void read(const GXmlElement& xml);
66 void write(GXmlElement& xml) const; 64 void write(GXmlElement& xml) const;
inst/cta/src/GCTAPointing.cpp
@@ -28,8 +28,9 @@ @@ -28,8 +28,9 @@
28 #ifdef HAVE_CONFIG_H 28 #ifdef HAVE_CONFIG_H
29 #include <config.h> 29 #include <config.h>
30 #endif 30 #endif
31 -#include "GCTAPointing.hpp"  
32 #include "GTools.hpp" 31 #include "GTools.hpp"
  32 +#include "GFilename.hpp"
  33 +#include "GCTAPointing.hpp"
33 #include "GFits.hpp" 34 #include "GFits.hpp"
34 #include "GHorizDir.hpp" 35 #include "GHorizDir.hpp"
35 36
@@ -107,21 +108,19 @@ GCTAPointing::GCTAPointing(const GXmlElement&amp; xml) @@ -107,21 +108,19 @@ GCTAPointing::GCTAPointing(const GXmlElement&amp; xml)
107 108
108 109
109 /***********************************************************************//** 110 /***********************************************************************//**
110 - * @brief Pointing table constructor 111 + * @brief FITS file constructor
111 * 112 *
112 - * @param[in] filename Pointing table file.  
113 - * @param[in] extname Pointing extension name (defaults to "POINTING") 113 + * @param[in] filename FITS file.
114 * 114 *
115 - * Construct CTA pointing from a pointing table file. 115 + * Construct CTA pointing from a pointing table FITS file.
116 ***************************************************************************/ 116 ***************************************************************************/
117 -GCTAPointing::GCTAPointing(const std::string& filename,  
118 - const std::string& extname) 117 +GCTAPointing::GCTAPointing(const std::string& filename)
119 { 118 {
120 // Initialise members 119 // Initialise members
121 init_members(); 120 init_members();
122 121
123 // Load pointing table 122 // Load pointing table
124 - load(filename, extname); 123 + load(filename);
125 124
126 // Return 125 // Return
127 return; 126 return;
@@ -400,24 +399,28 @@ GHorizDir GCTAPointing::dir_horiz(const GTime&amp; time) const @@ -400,24 +399,28 @@ GHorizDir GCTAPointing::dir_horiz(const GTime&amp; time) const
400 399
401 400
402 /************************************************************************ 401 /************************************************************************
403 - * @brief Load pointing table from a pointing file 402 + * @brief Load pointings from a FITS file
404 * 403 *
405 - * @param[in] filename Pointing table filename.  
406 - * @param[in] extname Pointing extension name (defaults to "POINTING") 404 + * @param[in] filename FITS file name.
  405 + *
  406 + * Loads pointings from a pointing table FITS file.
407 * 407 *
408 - * Loads a pointing table from a FITS file. See the read() method for  
409 - * more information about the structure of the FITS file. 408 + * If no extension name is provided, the pointing is are loaded from the
  409 + * "POINTING" extension.
410 ************************************************************************/ 410 ************************************************************************/
411 -void GCTAPointing::load(const std::string& filename, const std::string& extname) 411 +void GCTAPointing::load(const std::string& filename)
412 { 412 {
  413 + // Create file name
  414 + GFilename fname(filename);
  415 +
413 // Allocate FITS file 416 // Allocate FITS file
414 GFits file; 417 GFits file;
415 418
416 // Open FITS file 419 // Open FITS file
417 - file.open(filename); 420 + file.open(fname.filename());
418 421
419 // Get pointing table 422 // Get pointing table
420 - const GFitsTable& table = *file.table(extname); 423 + const GFitsTable& table = *file.table(fname.extname("POINTING"));
421 424
422 // Read pointing from table 425 // Read pointing from table
423 read(table); 426 read(table);
@@ -431,7 +434,7 @@ void GCTAPointing::load(const std::string&amp; filename, const std::string&amp; extname) @@ -431,7 +434,7 @@ void GCTAPointing::load(const std::string&amp; filename, const std::string&amp; extname)
431 434
432 435
433 /************************************************************************ 436 /************************************************************************
434 - * @brief Load pointing table from a pointing file 437 + * @brief Read pointings from a FITS table
435 * 438 *
436 * @param[in] filename Pointing table filename. 439 * @param[in] filename Pointing table filename.
437 * @param[in] extname Pointing extension name (defaults to "POINTING") 440 * @param[in] extname Pointing extension name (defaults to "POINTING")
inst/mwl/include/GMWLObservation.hpp
1 /*************************************************************************** 1 /***************************************************************************
2 * GMWLObservation.hpp - Multi-wavelength observation class * 2 * GMWLObservation.hpp - Multi-wavelength observation class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2014 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2015 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 *
@@ -49,8 +49,6 @@ public: @@ -49,8 +49,6 @@ public:
49 // Constructors and destructors 49 // Constructors and destructors
50 GMWLObservation(void); 50 GMWLObservation(void);
51 explicit GMWLObservation(const std::string& filename); 51 explicit GMWLObservation(const std::string& filename);
52 - explicit GMWLObservation(const std::string& filename, const int& extno);  
53 - explicit GMWLObservation(const std::string& filename, const std::string& extname);  
54 GMWLObservation(const GMWLObservation& obs); 52 GMWLObservation(const GMWLObservation& obs);
55 virtual ~GMWLObservation(void); 53 virtual ~GMWLObservation(void);
56 54
@@ -73,8 +71,6 @@ public: @@ -73,8 +71,6 @@ public:
73 71
74 // Other methods 72 // Other methods
75 void load(const std::string& filename); 73 void load(const std::string& filename);
76 - void load(const std::string& filename, const int& extno);  
77 - void load(const std::string& filename, const std::string& extname);  
78 const std::string& filename(void) const; 74 const std::string& filename(void) const;
79 const std::string& extno(void) const; 75 const std::string& extno(void) const;
80 const std::string& extname(void) const; 76 const std::string& extname(void) const;
inst/mwl/include/GMWLSpectrum.hpp
@@ -74,8 +74,6 @@ public: @@ -74,8 +74,6 @@ public:
74 virtual std::string print(const GChatter& chatter = NORMAL) const; 74 virtual std::string print(const GChatter& chatter = NORMAL) const;
75 75
76 // Other methods 76 // Other methods
77 - void load(const std::string& filename, const std::string& extname);  
78 - void load(const std::string& filename, const int& extno);  
79 void read(const GFits& file, const std::string& extname); 77 void read(const GFits& file, const std::string& extname);
80 void read(const GFits& file, const int& extno); 78 void read(const GFits& file, const int& extno);
81 const std::string& telescope(void) const; 79 const std::string& telescope(void) const;
inst/mwl/pyext/GMWLObservation.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GMWLObservation.i - Multi-wavelength observation class * 2 * GMWLObservation.i - Multi-wavelength observation class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2014 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2015 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,12 +39,11 @@ @@ -39,12 +39,11 @@
39 * instrument. The spectral points are given in physical units. 39 * instrument. The spectral points are given in physical units.
40 ***************************************************************************/ 40 ***************************************************************************/
41 class GMWLObservation : public GObservation { 41 class GMWLObservation : public GObservation {
  42 +
42 public: 43 public:
43 // Constructors and destructors 44 // Constructors and destructors
44 GMWLObservation(void); 45 GMWLObservation(void);
45 explicit GMWLObservation(const std::string& filename); 46 explicit GMWLObservation(const std::string& filename);
46 - explicit GMWLObservation(const std::string& filename, const int& extno);  
47 - explicit GMWLObservation(const std::string& filename, const std::string& extname);  
48 GMWLObservation(const GMWLObservation& obs); 47 GMWLObservation(const GMWLObservation& obs);
49 virtual ~GMWLObservation(void); 48 virtual ~GMWLObservation(void);
50 49
@@ -63,8 +62,6 @@ public: @@ -63,8 +62,6 @@ public:
63 62
64 // Other methods 63 // Other methods
65 void load(const std::string& filename); 64 void load(const std::string& filename);
66 - void load(const std::string& filename, const int& extno);  
67 - void load(const std::string& filename, const std::string& extname);  
68 const std::string& filename(void) const; 65 const std::string& filename(void) const;
69 const std::string& extno(void) const; 66 const std::string& extno(void) const;
70 const std::string& extname(void) const; 67 const std::string& extname(void) const;
inst/mwl/pyext/GMWLSpectrum.i
@@ -57,8 +57,6 @@ public: @@ -57,8 +57,6 @@ public:
57 virtual int number(void) const; 57 virtual int number(void) const;
58 58
59 // Other methods 59 // Other methods
60 - void load(const std::string& filename, const std::string& extname);  
61 - void load(const std::string& filename, const int& extno);  
62 void read(const GFits& file, const std::string& extname); 60 void read(const GFits& file, const std::string& extname);
63 void read(const GFits& file, const int& extno); 61 void read(const GFits& file, const int& extno);
64 const std::string& telescope(void) const; 62 const std::string& telescope(void) const;
inst/mwl/src/GMWLObservation.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * GMWLObservation.cpp - Multi-wavelength observation class * 2 * GMWLObservation.cpp - Multi-wavelength observation class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2013 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2015 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 *
@@ -28,8 +28,9 @@ @@ -28,8 +28,9 @@
28 #ifdef HAVE_CONFIG_H 28 #ifdef HAVE_CONFIG_H
29 #include <config.h> 29 #include <config.h>
30 #endif 30 #endif
31 -#include "GObservationRegistry.hpp"  
32 #include "GTools.hpp" 31 #include "GTools.hpp"
  32 +#include "GFilename.hpp"
  33 +#include "GObservationRegistry.hpp"
33 #include "GException.hpp" 34 #include "GException.hpp"
34 #include "GMWLObservation.hpp" 35 #include "GMWLObservation.hpp"
35 #include "GMWLSpectrum.hpp" 36 #include "GMWLSpectrum.hpp"
@@ -93,50 +94,6 @@ GMWLObservation::GMWLObservation(const std::string&amp; filename) : GObservation() @@ -93,50 +94,6 @@ GMWLObservation::GMWLObservation(const std::string&amp; filename) : GObservation()
93 94
94 95
95 /***********************************************************************//** 96 /***********************************************************************//**
96 - * @brief File constructor  
97 - *  
98 - * @param[in] filename File name.  
99 - * @param[in] extno FITS file extension number.  
100 - *  
101 - * Creates instance from file.  
102 - ***************************************************************************/  
103 -GMWLObservation::GMWLObservation(const std::string& filename,  
104 - const int& extno) : GObservation()  
105 -{  
106 - // Initialise members  
107 - init_members();  
108 -  
109 - // Load observation  
110 - load(filename, extno);  
111 -  
112 - // Return  
113 - return;  
114 -}  
115 -  
116 -  
117 -/***********************************************************************//**  
118 - * @brief File constructor  
119 - *  
120 - * @param[in] filename File name.  
121 - * @param[in] extname FITS file extension name.  
122 - *  
123 - * Creates instance from file.  
124 - ***************************************************************************/  
125 -GMWLObservation::GMWLObservation(const std::string& filename,  
126 - const std::string& extname) : GObservation()  
127 -{  
128 - // Initialise members  
129 - init_members();  
130 -  
131 - // Load observation  
132 - load(filename, extname);  
133 -  
134 - // Return  
135 - return;  
136 -}  
137 -  
138 -  
139 -/***********************************************************************//**  
140 * @brief Copy constructor 97 * @brief Copy constructor
141 * 98 *
142 * @param[in] obs Observation. 99 * @param[in] obs Observation.
@@ -336,11 +293,11 @@ void GMWLObservation::read(const GXmlElement&amp; xml) @@ -336,11 +293,11 @@ void GMWLObservation::read(const GXmlElement&amp; xml)
336 293
337 // Load file (this also stores the filename, extno and 294 // Load file (this also stores the filename, extno and
338 // extname) 295 // extname)
339 - if (gammalib::strip_whitespace(extno).length() > 0) {  
340 - load(filename, gammalib::toint(extno)); 296 + if (!gammalib::strip_whitespace(extno).empty()) {
  297 + load(filename+"["+extno+"]");
341 } 298 }
342 - else if (gammalib::strip_whitespace(extname).length() > 0) {  
343 - load(filename, extname); 299 + else if (!gammalib::strip_whitespace(extname).empty()) {
  300 + load(filename+"["+extname+"]");
344 } 301 }
345 else { 302 else {
346 load(filename); 303 load(filename);
@@ -442,79 +399,32 @@ void GMWLObservation::load(const std::string&amp; filename) @@ -442,79 +399,32 @@ void GMWLObservation::load(const std::string&amp; filename)
442 // Clear observation 399 // Clear observation
443 clear(); 400 clear();
444 401
445 - // Allocate spectrum  
446 - GMWLSpectrum* spec = new GMWLSpectrum;  
447 - m_events = spec;  
448 -  
449 - // Load spectrum  
450 - spec->load(filename);  
451 -  
452 - // Set attributes  
453 - name("Multi-wavelength observation");  
454 - id(filename);  
455 - m_filename = filename;  
456 - m_instrument = spec->instrument();  
457 -  
458 - // Return  
459 - return;  
460 -}  
461 -  
462 -  
463 -/***********************************************************************//**  
464 - * @brief Load observation  
465 - *  
466 - * @param[in] filename File name.  
467 - * @param[in] extno FITS extension number.  
468 - ***************************************************************************/  
469 -void GMWLObservation::load(const std::string& filename,  
470 - const int& extno)  
471 -{  
472 - // Clear observation  
473 - clear();  
474 -  
475 - // Allocate spectrum  
476 - GMWLSpectrum* spec = new GMWLSpectrum;  
477 - m_events = spec;  
478 -  
479 - // Load spectrum  
480 - spec->load(filename, extno);  
481 -  
482 - // Set attributes  
483 - name("Multi-wavelength observation");  
484 - id(filename+"["+gammalib::str(extno)+"]");  
485 - m_filename = filename;  
486 - m_extno = gammalib::str(extno);  
487 - m_instrument = spec->instrument();  
488 -  
489 - // Return  
490 - return;  
491 -}  
492 -  
493 -  
494 -/***********************************************************************//**  
495 - * @brief Load observation  
496 - *  
497 - * @param[in] filename File name.  
498 - * @param[in] extname FITS extension name.  
499 - ***************************************************************************/  
500 -void GMWLObservation::load(const std::string& filename,  
501 - const std::string& extname)  
502 -{  
503 - // Clear observation  
504 - clear(); 402 + // Create file name
  403 + GFilename fname(filename);
505 404
506 // Allocate spectrum 405 // Allocate spectrum
507 GMWLSpectrum* spec = new GMWLSpectrum; 406 GMWLSpectrum* spec = new GMWLSpectrum;
508 m_events = spec; 407 m_events = spec;
509 408
510 // Load spectrum 409 // Load spectrum
511 - spec->load(filename, extname); 410 + if (fname.has_extno()) {
  411 + spec->load(filename);
  412 + m_extno = gammalib::str(fname.extno());
  413 + id(filename+"["+m_extno+"]");
  414 + }
  415 + else if (fname.has_extname()) {
  416 + spec->load(filename);
  417 + m_extname = fname.extname();
  418 + id(filename+"["+m_extname+"]");
  419 + }
  420 + else {
  421 + spec->load(filename);
  422 + id(filename);
  423 + }
512 424
513 // Set attributes 425 // Set attributes
514 name("Multi-wavelength observation"); 426 name("Multi-wavelength observation");
515 - id(filename+"["+extname+"]");  
516 - m_filename = filename;  
517 - m_extname = extname; 427 + m_filename = fname.filename();
518 m_instrument = spec->instrument(); 428 m_instrument = spec->instrument();
519 429
520 // Return 430 // Return
inst/mwl/src/GMWLSpectrum.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * GMWLSpectrum.cpp - Multi-wavelength spectrum class * 2 * GMWLSpectrum.cpp - Multi-wavelength spectrum class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2013 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2015 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 *
@@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
29 #include <config.h> 29 #include <config.h>
30 #endif 30 #endif
31 #include "GTools.hpp" 31 #include "GTools.hpp"
  32 +#include "GFilename.hpp"
32 #include "GFits.hpp" 33 #include "GFits.hpp"
33 #include "GFitsTable.hpp" 34 #include "GFitsTable.hpp"
34 #include "GEnergy.hpp" 35 #include "GEnergy.hpp"
@@ -259,70 +260,25 @@ GMWLSpectrum* GMWLSpectrum::clone(void) const @@ -259,70 +260,25 @@ GMWLSpectrum* GMWLSpectrum::clone(void) const
259 ***************************************************************************/ 260 ***************************************************************************/
260 void GMWLSpectrum::load(const std::string& filename) 261 void GMWLSpectrum::load(const std::string& filename)
261 { 262 {
262 - // Clear object  
263 - clear();  
264 -  
265 - // Open FITS file  
266 - GFits file(filename);  
267 -  
268 - // Read spectrum  
269 - read(file);  
270 -  
271 - // Close FITS file  
272 - file.close();  
273 -  
274 - // Return  
275 - return;  
276 -}  
277 -  
278 -  
279 -/***********************************************************************//**  
280 - * @brief Load spectrum from FITS file  
281 - *  
282 - * @param[in] filename FITS file name.  
283 - * @param[in] extname FITS extension name.  
284 - *  
285 - * This method loads a spectrum from the specified extension from a FITS  
286 - * file.  
287 - ***************************************************************************/  
288 -void GMWLSpectrum::load(const std::string& filename, const std::string& extname)  
289 -{  
290 - // Clear object  
291 - clear();  
292 -  
293 - // Open FITS file  
294 - GFits file(filename);  
295 -  
296 - // Read spectrum from FITS file  
297 - read(file, extname);  
298 -  
299 - // Close FITS file  
300 - file.close();  
301 -  
302 - // Return  
303 - return;  
304 -} 263 + // Create file name
  264 + GFilename fname(filename);
305 265
306 -  
307 -/***********************************************************************//**  
308 - * @brief Load spectrum from FITS file  
309 - *  
310 - * @param[in] filename FITS file name.  
311 - * @param[in] extno FITS extension number.  
312 - *  
313 - * This method loads a spectrum from the specified extension number from a  
314 - * FITS file.  
315 - ***************************************************************************/  
316 -void GMWLSpectrum::load(const std::string& filename, const int& extno)  
317 -{  
318 // Clear object 266 // Clear object
319 clear(); 267 clear();
320 268
321 // Open FITS file 269 // Open FITS file
322 - GFits file(filename); 270 + GFits file(fname.filename());
323 271
324 - // Read spectrum from FITS file  
325 - read(file, extno); 272 + // Read spectrum
  273 + if (fname.has_extno()) {
  274 + read(file, fname.extno());
  275 + }
  276 + else if (fname.has_extname()) {
  277 + read(file, fname.extname());
  278 + }
  279 + else {
  280 + read(file);
  281 + }
326 282
327 // Close FITS file 283 // Close FITS file
328 file.close(); 284 file.close();
@@ -336,7 +292,7 @@ void GMWLSpectrum::load(const std::string&amp; filename, const int&amp; extno) @@ -336,7 +292,7 @@ void GMWLSpectrum::load(const std::string&amp; filename, const int&amp; extno)
336 * @brief Save spectrum 292 * @brief Save spectrum
337 * 293 *
338 * @param[in] filename File name. 294 * @param[in] filename File name.
339 - * @param[in] clobber Overwrite existing file (default=false). 295 + * @param[in] clobber Overwrite existing file (default: false).
340 * 296 *
341 * @todo To be implemented. 297 * @todo To be implemented.
342 ***************************************************************************/ 298 ***************************************************************************/
inst/mwl/test/test_MWL.cpp
@@ -191,9 +191,9 @@ void TestGMWL::test_optimizer(void) @@ -191,9 +191,9 @@ void TestGMWL::test_optimizer(void)
191 test_try("Load multi-wavelength observations"); 191 test_try("Load multi-wavelength observations");
192 try { 192 try {
193 obs.clear(); 193 obs.clear();
194 - GMWLObservation comptel(crab_fits, "COMPTEL");  
195 - GMWLObservation lat(crab_fits, "LAT");  
196 - GMWLObservation hess(crab_fits, "HESS"); 194 + GMWLObservation comptel(crab_fits+"[COMPTEL]");
  195 + GMWLObservation lat(crab_fits+"[LAT]");
  196 + GMWLObservation hess(crab_fits+"[HESS]");
197 obs.append(comptel); 197 obs.append(comptel);
198 obs.append(lat); 198 obs.append(lat);
199 obs.append(hess); 199 obs.append(hess);
pyext/GEbounds.i
@@ -39,12 +39,12 @@ class GEbounds : public GContainer { @@ -39,12 +39,12 @@ class GEbounds : public GContainer {
39 public: 39 public:
40 // Constructors and destructors 40 // Constructors and destructors
41 GEbounds(void); 41 GEbounds(void);
42 - GEbounds(const GEbounds& ebds); 42 + explicit GEbounds(const std::string& filename);
43 explicit GEbounds(const GXmlElement& xml); 43 explicit GEbounds(const GXmlElement& xml);
  44 + GEbounds(const GEbounds& ebds);
44 GEbounds(const GEnergy& emin, const GEnergy& emax); 45 GEbounds(const GEnergy& emin, const GEnergy& emax);
45 GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax, 46 GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax,
46 const bool& log = true); 47 const bool& log = true);
47 - GEbounds(const std::string& filename);  
48 virtual ~GEbounds(void); 48 virtual ~GEbounds(void);
49 49
50 // Methods 50 // Methods
pyext/GEnergies.i
@@ -41,8 +41,7 @@ class GEnergies : public GContainer { @@ -41,8 +41,7 @@ class GEnergies : public GContainer {
41 public: 41 public:
42 // Constructors and destructors 42 // Constructors and destructors
43 GEnergies(void); 43 GEnergies(void);
44 - GEnergies(const std::string& filename,  
45 - const std::string& extname = "ENERGIES"); 44 + explicit GEnergies(const std::string& filename);
46 GEnergies(const GEnergies& energies); 45 GEnergies(const GEnergies& energies);
47 GEnergies(const int& num, const GEnergy& emin, const GEnergy& emax, 46 GEnergies(const int& num, const GEnergy& emin, const GEnergy& emax,
48 const bool& log = true); 47 const bool& log = true);
@@ -64,13 +63,12 @@ public: @@ -64,13 +63,12 @@ public:
64 const GEnergy& emax); 63 const GEnergy& emax);
65 void set_log(const int& num, const GEnergy& emin, 64 void set_log(const int& num, const GEnergy& emin,
66 const GEnergy& emax); 65 const GEnergy& emax);
67 - void load(const std::string& filename,  
68 - const std::string& extname = "ENERGIES"); 66 + void load(const std::string& filename);
69 void save(const std::string& filename, 67 void save(const std::string& filename,
70 - const bool& clobber = false,  
71 - const std::string& extname = "ENERGIES") const; 68 + const bool& clobber = false) const;
72 void read(const GFitsTable& table); 69 void read(const GFitsTable& table);
73 - void write(GFits& file, const std::string& extname = "ENERGIES") const; 70 + void write(GFits& file,
  71 + const std::string& extname = "ENERGIES") const;
74 }; 72 };
75 73
76 74
pyext/GGti.i
@@ -36,9 +36,11 @@ @@ -36,9 +36,11 @@
36 * @brief Good Time Interval class 36 * @brief Good Time Interval class
37 ***************************************************************************/ 37 ***************************************************************************/
38 class GGti : public GBase { 38 class GGti : public GBase {
  39 +
39 public: 40 public:
40 // Constructors and destructors 41 // Constructors and destructors
41 GGti(void); 42 GGti(void);
  43 + explicit GGti(const std::string& filename);
42 GGti(const GGti& gti); 44 GGti(const GGti& gti);
43 GGti(const GTime& tstart, const GTime& tstop); 45 GGti(const GTime& tstart, const GTime& tstop);
44 explicit GGti(const GXmlElement& xml); 46 explicit GGti(const GXmlElement& xml);
@@ -59,11 +61,9 @@ public: @@ -59,11 +61,9 @@ public:
59 void remove(const int& index); 61 void remove(const int& index);
60 void reserve(const int& num); 62 void reserve(const int& num);
61 void extend(const GGti& gti); 63 void extend(const GGti& gti);
62 - void load(const std::string& filename,  
63 - const std::string& extname = "GTI"); 64 + void load(const std::string& filename);
64 void save(const std::string& filename, 65 void save(const std::string& filename,
65 - const bool& clobber = false,  
66 - const std::string& extname = "GTI") const; 66 + const bool& clobber = false) const;
67 void read(const GFitsTable& table); 67 void read(const GFitsTable& table);
68 void write(GFits& file, 68 void write(GFits& file,
69 const std::string& extname = "GTI") const; 69 const std::string& extname = "GTI") const;
pyext/GNodeArray.i
@@ -39,12 +39,14 @@ namespace std { @@ -39,12 +39,14 @@ namespace std {
39 * @brief Node array class 39 * @brief Node array class
40 ***************************************************************************/ 40 ***************************************************************************/
41 class GNodeArray : public GContainer { 41 class GNodeArray : public GContainer {
  42 +
42 public: 43 public:
43 // Constructors and destructors 44 // Constructors and destructors
44 GNodeArray(void); 45 GNodeArray(void);
45 - GNodeArray(const int& num, const double* array); 46 + explicit GNodeArray(const std::string& filename);
46 explicit GNodeArray(const GVector& vector); 47 explicit GNodeArray(const GVector& vector);
47 explicit GNodeArray(const std::vector<double>& vector); 48 explicit GNodeArray(const std::vector<double>& vector);
  49 + GNodeArray(const int& num, const double* array);
48 GNodeArray(const GNodeArray& array); 50 GNodeArray(const GNodeArray& array);
49 virtual ~GNodeArray(void); 51 virtual ~GNodeArray(void);
50 52
@@ -70,10 +72,9 @@ public: @@ -70,10 +72,9 @@ public:
70 const int& inx_right(void) const; 72 const int& inx_right(void) const;
71 const double& wgt_left(void) const; 73 const double& wgt_left(void) const;
72 const double& wgt_right(void) const; 74 const double& wgt_right(void) const;
73 - void load(const std::string& filename,  
74 - const std::string& extname = "NODES");  
75 - void save(const std::string& filename, const bool& clobber = false,  
76 - const std::string& extname = "NODES") const; 75 + void load(const std::string& filename);
  76 + void save(const std::string& filename,
  77 + const bool& clobber = false) const;
77 void read(const GFitsTable& table); 78 void read(const GFitsTable& table);
78 void write(GFits& file, 79 void write(GFits& file,
79 const std::string& extname = "NODES") const; 80 const std::string& extname = "NODES") const;
src/obs/GEbounds.cpp
@@ -77,17 +77,19 @@ GEbounds::GEbounds(void) @@ -77,17 +77,19 @@ GEbounds::GEbounds(void)
77 77
78 78
79 /***********************************************************************//** 79 /***********************************************************************//**
80 - * @brief Copy constructor 80 + * @brief FITS file constructor
81 * 81 *
82 - * @param[in] ebds Energy boundaries. 82 + * @param[in] filename FITS file name.
  83 + *
  84 + * Constructs energy boundaries from a FITS file.
83 ***************************************************************************/ 85 ***************************************************************************/
84 -GEbounds::GEbounds(const GEbounds& ebds) 86 +GEbounds::GEbounds(const std::string& filename)
85 { 87 {
86 - // Initialise class members for clean destruction 88 + // Initialise members
87 init_members(); 89 init_members();
88 90
89 - // Copy members  
90 - copy_members(ebds); 91 + // Load FITS file
  92 + load(filename);
91 93
92 // Return 94 // Return
93 return; 95 return;
@@ -99,7 +101,7 @@ GEbounds::GEbounds(const GEbounds&amp; ebds) @@ -99,7 +101,7 @@ GEbounds::GEbounds(const GEbounds&amp; ebds)
99 * 101 *
100 * @param[in] xml XML element. 102 * @param[in] xml XML element.
101 * 103 *
102 - * Constructs energy bounds from an XML element. 104 + * Constructs energy boundaries from an XML element.
103 ***************************************************************************/ 105 ***************************************************************************/
104 GEbounds::GEbounds(const GXmlElement& xml) 106 GEbounds::GEbounds(const GXmlElement& xml)
105 { 107 {
@@ -115,12 +117,30 @@ GEbounds::GEbounds(const GXmlElement&amp; xml) @@ -115,12 +117,30 @@ GEbounds::GEbounds(const GXmlElement&amp; xml)
115 117
116 118
117 /***********************************************************************//** 119 /***********************************************************************//**
  120 + * @brief Copy constructor
  121 + *
  122 + * @param[in] ebds Energy boundaries.
  123 + ***************************************************************************/
  124 +GEbounds::GEbounds(const GEbounds& ebds)
  125 +{
  126 + // Initialise class members for clean destruction
  127 + init_members();
  128 +
  129 + // Copy members
  130 + copy_members(ebds);
  131 +
  132 + // Return
  133 + return;
  134 +}
  135 +
  136 +
  137 +/***********************************************************************//**
118 * @brief Single energy band constructor 138 * @brief Single energy band constructor
119 * 139 *
120 * @param[in] emin Minimum energy of the interval. 140 * @param[in] emin Minimum energy of the interval.
121 * @param[in] emax Maximum energy of the interval. 141 * @param[in] emax Maximum energy of the interval.
122 * 142 *
123 - * Constructs energy bounds for one (emin, emax) energy band. 143 + * Constructs energy boundaries for one (emin, emax) energy band.
124 ***************************************************************************/ 144 ***************************************************************************/
125 GEbounds::GEbounds(const GEnergy& emin, const GEnergy& emax) 145 GEbounds::GEbounds(const GEnergy& emin, const GEnergy& emax)
126 { 146 {
@@ -167,24 +187,6 @@ GEbounds::GEbounds(const int&amp; num, const GEnergy&amp; emin, const GEnergy&amp; emax, @@ -167,24 +187,6 @@ GEbounds::GEbounds(const int&amp; num, const GEnergy&amp; emin, const GEnergy&amp; emax,
167 187
168 188
169 /***********************************************************************//** 189 /***********************************************************************//**
170 - * @brief Load constructor  
171 - *  
172 - * @param[in] filename FITS filename.  
173 - ***************************************************************************/  
174 -GEbounds::GEbounds(const std::string& filename)  
175 -{  
176 - // Initialise members  
177 - init_members();  
178 -  
179 - // Load FITS file  
180 - load(filename);  
181 -  
182 - // Return  
183 - return;  
184 -}  
185 -  
186 -  
187 -/***********************************************************************//**  
188 * @brief Destructor 190 * @brief Destructor
189 ***************************************************************************/ 191 ***************************************************************************/
190 GEbounds::~GEbounds(void) 192 GEbounds::~GEbounds(void)
@@ -570,6 +572,9 @@ void GEbounds::set_log(const int&amp; num, const GEnergy&amp; emin, const GEnergy&amp; emax) @@ -570,6 +572,9 @@ void GEbounds::set_log(const int&amp; num, const GEnergy&amp; emin, const GEnergy&amp; emax)
570 * @param[in] filename FITS file name. 572 * @param[in] filename FITS file name.
571 * 573 *
572 * Loads the energy boundaries from a FITS file. 574 * Loads the energy boundaries from a FITS file.
  575 + *
  576 + * If no extension name is provided, the energy boundaries are loaded from
  577 + * the "EBOUNDS" extension.
573 ***************************************************************************/ 578 ***************************************************************************/
574 void GEbounds::load(const std::string& filename) 579 void GEbounds::load(const std::string& filename)
575 { 580 {
@@ -603,7 +608,10 @@ void GEbounds::load(const std::string&amp; filename) @@ -603,7 +608,10 @@ void GEbounds::load(const std::string&amp; filename)
603 * @param[in] clobber Overwrite any existing file (default: false)? 608 * @param[in] clobber Overwrite any existing file (default: false)?
604 * @param[in] unit Energy units (default: "keV") 609 * @param[in] unit Energy units (default: "keV")
605 * 610 *
606 - * Saves the energy boundaries into a FITS file. 611 + * Saves energy boundaries into a FITS file.
  612 + *
  613 + * If no extension name is provided, the energy boundaries are saved into
  614 + * an "EBOUNDS" extension.
607 ***************************************************************************/ 615 ***************************************************************************/
608 void GEbounds::save(const std::string& filename, 616 void GEbounds::save(const std::string& filename,
609 const bool& clobber, 617 const bool& clobber,
src/obs/GEnergies.cpp
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
30 #endif 30 #endif
31 #include "GTools.hpp" 31 #include "GTools.hpp"
32 #include "GException.hpp" 32 #include "GException.hpp"
  33 +#include "GFilename.hpp"
33 #include "GEnergies.hpp" 34 #include "GEnergies.hpp"
34 #include "GFits.hpp" 35 #include "GFits.hpp"
35 #include "GFitsTable.hpp" 36 #include "GFitsTable.hpp"
@@ -71,20 +72,19 @@ GEnergies::GEnergies(void) @@ -71,20 +72,19 @@ GEnergies::GEnergies(void)
71 72
72 73
73 /***********************************************************************//** 74 /***********************************************************************//**
74 - * @brief Load constructor 75 + * @brief FITS file constructor
75 * 76 *
76 - * @param[in] filename FITS filename.  
77 - * @param[in] extname Energies extension name (defaults to "ENERGIES") 77 + * @param[in] filename FITS file name.
78 * 78 *
79 - * Constructs energy container by loading energies from FITS file. 79 + * Constructs energy container from a FITS file.
80 ***************************************************************************/ 80 ***************************************************************************/
81 -GEnergies::GEnergies(const std::string& filename, const std::string& extname) 81 +GEnergies::GEnergies(const std::string& filename)
82 { 82 {
83 // Initialise members 83 // Initialise members
84 init_members(); 84 init_members();
85 85
86 // Load energies 86 // Load energies
87 - load(filename, extname); 87 + load(filename);
88 88
89 // Return 89 // Return
90 return; 90 return;
@@ -534,21 +534,26 @@ void GEnergies::set_log(const int&amp; num, @@ -534,21 +534,26 @@ void GEnergies::set_log(const int&amp; num,
534 /***********************************************************************//** 534 /***********************************************************************//**
535 * @brief Load energies from FITS file 535 * @brief Load energies from FITS file
536 * 536 *
537 - * @param[in] filename FITS filename.  
538 - * @param[in] extname Energies extension name (defaults to "ENERGIES") 537 + * @param[in] filename FITS file name.
539 * 538 *
540 * Loads the energies from FITS file. 539 * Loads the energies from FITS file.
  540 + *
  541 + * If no extension name is provided, the energies are loaded from the
  542 + * "ENERGIES" extension.
541 ***************************************************************************/ 543 ***************************************************************************/
542 -void GEnergies::load(const std::string& filename, const std::string& extname) 544 +void GEnergies::load(const std::string& filename)
543 { 545 {
  546 + // Create file name
  547 + GFilename fname(filename);
  548 +
544 // Allocate FITS file 549 // Allocate FITS file
545 GFits file; 550 GFits file;
546 551
547 // Open FITS file 552 // Open FITS file
548 - file.open(filename); 553 + file.open(fname.filename());
549 554
550 // Get energies table 555 // Get energies table
551 - const GFitsTable& table = *file.table(extname); 556 + const GFitsTable& table = *file.table(fname.extname("ENERGIES"));
552 557
553 // Read energies from table 558 // Read energies from table
554 read(table); 559 read(table);
@@ -566,24 +571,25 @@ void GEnergies::load(const std::string&amp; filename, const std::string&amp; extname) @@ -566,24 +571,25 @@ void GEnergies::load(const std::string&amp; filename, const std::string&amp; extname)
566 * 571 *
567 * @param[in] filename FITS filename. 572 * @param[in] filename FITS filename.
568 * @param[in] clobber Overwrite any existing energies extension? 573 * @param[in] clobber Overwrite any existing energies extension?
569 - * @param[in] extname Energies extension name (defaults to "ENERGIES")  
570 * 574 *
571 - * Saves energies into extension @p extname of a FITS file. If the file does  
572 - * not exist it is created. If the file exists the energies are appended as  
573 - * extension. If another energies extension exists already it is overwritten  
574 - * if @p clobber=true. 575 + * Saves energies into a FITS file.
  576 + *
  577 + * If no extension name is provided, the energies are saved into an
  578 + * "ENERGIES" extension.
575 ***************************************************************************/ 579 ***************************************************************************/
576 -void GEnergies::save(const std::string& filename, const bool& clobber,  
577 - const std::string& extname) const 580 +void GEnergies::save(const std::string& filename, const bool& clobber) const
578 { 581 {
  582 + // Create file name
  583 + GFilename fname(filename);
  584 +
579 // Allocate FITS file 585 // Allocate FITS file
580 GFits file; 586 GFits file;
581 587
582 // Write energies to FITS file 588 // Write energies to FITS file
583 - write(file, extname); 589 + write(file, fname.extname("ENERGIES"));
584 590
585 // Save to file 591 // Save to file
586 - file.saveto(filename, clobber); 592 + file.saveto(fname.filename(), clobber);
587 593
588 // Return 594 // Return
589 return; 595 return;
@@ -637,7 +643,7 @@ void GEnergies::read(const GFitsTable&amp; table) @@ -637,7 +643,7 @@ void GEnergies::read(const GFitsTable&amp; table)
637 * @brief Write energies into FITS object 643 * @brief Write energies into FITS object
638 * 644 *
639 * @param[in] file FITS file. 645 * @param[in] file FITS file.
640 - * @param[in] extname Energy extension name (defaults to "ENERGIES") 646 + * @param[in] extname Energy extension name (default: "ENERGIES")
641 * 647 *
642 * Writes energies into FITS object. 648 * Writes energies into FITS object.
643 ***************************************************************************/ 649 ***************************************************************************/
src/obs/GGti.cpp
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
30 #endif 30 #endif
31 #include "GException.hpp" 31 #include "GException.hpp"
32 #include "GTools.hpp" 32 #include "GTools.hpp"
  33 +#include "GFilename.hpp"
33 #include "GGti.hpp" 34 #include "GGti.hpp"
34 #include "GFits.hpp" 35 #include "GFits.hpp"
35 #include "GFitsTable.hpp" 36 #include "GFitsTable.hpp"
@@ -73,6 +74,26 @@ GGti::GGti(void) @@ -73,6 +74,26 @@ GGti::GGti(void)
73 74
74 75
75 /***********************************************************************//** 76 /***********************************************************************//**
  77 + * @brief FITS file constructor
  78 + *
  79 + * @param[in] filename FITS file name.
  80 + *
  81 + * Constructs Good Time Intervals from a FITS file.
  82 + ***************************************************************************/
  83 +GGti::GGti(const std::string& filename)
  84 +{
  85 + // Initialise members
  86 + init_members();
  87 +
  88 + // Load FITS file
  89 + load(filename);
  90 +
  91 + // Return
  92 + return;
  93 +}
  94 +
  95 +
  96 +/***********************************************************************//**
76 * @brief Copy constructor 97 * @brief Copy constructor
77 * 98 *
78 * @param[in] gti Good Time Intervals. 99 * @param[in] gti Good Time Intervals.
@@ -551,20 +572,25 @@ void GGti::extend(const GGti&amp; gti) @@ -551,20 +572,25 @@ void GGti::extend(const GGti&amp; gti)
551 * @brief Load Good Time Intervals from FITS file 572 * @brief Load Good Time Intervals from FITS file
552 * 573 *
553 * @param[in] filename FITS filename. 574 * @param[in] filename FITS filename.
554 - * @param[in] extname GTI extension name (defaults to "GTI")  
555 * 575 *
556 * Loads the Good Time Intervals from FITS file. 576 * Loads the Good Time Intervals from FITS file.
  577 + *
  578 + * If no extension name is provided, the energy boundaries are loaded from
  579 + * the "GTI" extension.
557 ***************************************************************************/ 580 ***************************************************************************/
558 -void GGti::load(const std::string& filename, const std::string& extname) 581 +void GGti::load(const std::string& filename)
559 { 582 {
  583 + // Create file name
  584 + GFilename fname(filename);
  585 +
560 // Allocate FITS file 586 // Allocate FITS file
561 GFits file; 587 GFits file;
562 588
563 // Open FITS file 589 // Open FITS file
564 - file.open(filename); 590 + file.open(fname.filename());
565 591
566 // Get GTI table 592 // Get GTI table
567 - const GFitsTable& table = *file.table(extname); 593 + const GFitsTable& table = *file.table(fname.extname("GTI"));
568 594
569 // Read GTI from table 595 // Read GTI from table
570 read(table); 596 read(table);
@@ -582,24 +608,25 @@ void GGti::load(const std::string&amp; filename, const std::string&amp; extname) @@ -582,24 +608,25 @@ void GGti::load(const std::string&amp; filename, const std::string&amp; extname)
582 * 608 *
583 * @param[in] filename FITS filename. 609 * @param[in] filename FITS filename.
584 * @param[in] clobber Overwrite any existing GTI extension? 610 * @param[in] clobber Overwrite any existing GTI extension?
585 - * @param[in] extname GTI extension name (defaults to "GTI")  
586 * 611 *
587 - * Saves Good Time Intervals into extension @p extname of a FITS file. If the  
588 - * file does not exist it is created. If the file exists the GTI is appended  
589 - * as extension. If another GTI exists already it is overwritten if  
590 - * @p clobber=true. 612 + * Saves Good Time Intervals into a FITS file.
  613 + *
  614 + * If no extension name is provided, the Good Time Intervals are saved into
  615 + * an "GTI" extension.
591 ***************************************************************************/ 616 ***************************************************************************/
592 -void GGti::save(const std::string& filename, const bool& clobber,  
593 - const std::string& extname) const 617 +void GGti::save(const std::string& filename, const bool& clobber) const
594 { 618 {
  619 + // Create file name
  620 + GFilename fname(filename);
  621 +
595 // Allocate FITS file 622 // Allocate FITS file
596 GFits file; 623 GFits file;
597 624
598 // Write GTI to FITS file 625 // Write GTI to FITS file
599 - write(file, extname); 626 + write(file, fname.extname("GTI"));
600 627
601 // Save to file 628 // Save to file
602 - file.saveto(filename, clobber); 629 + file.saveto(fname.filename(), clobber);
603 630
604 // Return 631 // Return
605 return; 632 return;
src/support/GNodeArray.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * GNodeArray.cpp - Array of nodes class * 2 * GNodeArray.cpp - Array of nodes class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2014 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2015 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 *
@@ -29,9 +29,10 @@ @@ -29,9 +29,10 @@
29 #include <config.h> 29 #include <config.h>
30 #endif 30 #endif
31 #include <cmath> 31 #include <cmath>
  32 +#include "GTools.hpp"
32 #include "GException.hpp" 33 #include "GException.hpp"
  34 +#include "GFilename.hpp"
33 #include "GNodeArray.hpp" 35 #include "GNodeArray.hpp"
34 -#include "GTools.hpp"  
35 #include "GFits.hpp" 36 #include "GFits.hpp"
36 #include "GFitsTable.hpp" 37 #include "GFitsTable.hpp"
37 #include "GFitsBinTable.hpp" 38 #include "GFitsBinTable.hpp"
@@ -75,6 +76,26 @@ GNodeArray::GNodeArray(void) @@ -75,6 +76,26 @@ GNodeArray::GNodeArray(void)
75 76
76 77
77 /***********************************************************************//** 78 /***********************************************************************//**
  79 + * @brief FITS file constructor
  80 + *
  81 + * @param[in] filename FITS file name.
  82 + *
  83 + * Constructs node array from a FITS file.
  84 + ***************************************************************************/
  85 +GNodeArray::GNodeArray(const std::string& filename)
  86 +{
  87 + // Initialise members
  88 + init_members();
  89 +
  90 + // Load FITS file
  91 + load(filename);
  92 +
  93 + // Return
  94 + return;
  95 +}
  96 +
  97 +
  98 +/***********************************************************************//**
78 * @brief Element constructor 99 * @brief Element constructor
79 * 100 *
80 * @param[in] num Number of elements. 101 * @param[in] num Number of elements.
@@ -673,20 +694,25 @@ void GNodeArray::set_value(const double&amp; value) const @@ -673,20 +694,25 @@ void GNodeArray::set_value(const double&amp; value) const
673 * @brief Load nodes from FITS file 694 * @brief Load nodes from FITS file
674 * 695 *
675 * @param[in] filename FITS filename. 696 * @param[in] filename FITS filename.
676 - * @param[in] extname Energies extension name (defaults to "NODES")  
677 * 697 *
678 - * Loads the nodes from FITS file. 698 + * Loads the node array from a FITS file.
  699 + *
  700 + * If no extension name is provided, the node array is loaded from the
  701 + * "NODES" extension.
679 ***************************************************************************/ 702 ***************************************************************************/
680 -void GNodeArray::load(const std::string& filename, const std::string& extname) 703 +void GNodeArray::load(const std::string& filename)
681 { 704 {
  705 + // Create file name
  706 + GFilename fname(filename);
  707 +
682 // Allocate FITS file 708 // Allocate FITS file
683 GFits file; 709 GFits file;
684 710
685 // Open FITS file 711 // Open FITS file
686 - file.open(filename); 712 + file.open(fname.filename());
687 713
688 // Get nodes table 714 // Get nodes table
689 - const GFitsTable& table = *file.table(extname); 715 + const GFitsTable& table = *file.table(fname.extname("NODES"));
690 716
691 // Read nodes from table 717 // Read nodes from table
692 read(table); 718 read(table);
@@ -704,24 +730,25 @@ void GNodeArray::load(const std::string&amp; filename, const std::string&amp; extname) @@ -704,24 +730,25 @@ void GNodeArray::load(const std::string&amp; filename, const std::string&amp; extname)
704 * 730 *
705 * @param[in] filename FITS filename. 731 * @param[in] filename FITS filename.
706 * @param[in] clobber Overwrite any existing nodes extension? 732 * @param[in] clobber Overwrite any existing nodes extension?
707 - * @param[in] extname Nodes extension name (defaults to "NODES")  
708 * 733 *
709 - * Saves nodes into extension @p extname of a FITS file. If the file does  
710 - * not exist it is created. If the file exists the nodes are appended as  
711 - * extension. If another nodes extension exists already it is overwritten  
712 - * if @p clobber=true. 734 + * Saves node array into a FITS file.
  735 + *
  736 + * If no extension name is provided, the node array is saved into a
  737 + * "NODES" extension.
713 ***************************************************************************/ 738 ***************************************************************************/
714 -void GNodeArray::save(const std::string& filename, const bool& clobber,  
715 - const std::string& extname) const 739 +void GNodeArray::save(const std::string& filename, const bool& clobber) const
716 { 740 {
  741 + // Create file name
  742 + GFilename fname(filename);
  743 +
717 // Allocate FITS file 744 // Allocate FITS file
718 GFits file; 745 GFits file;
719 746
720 // Write nodes to FITS file 747 // Write nodes to FITS file
721 - write(file, extname); 748 + write(file, fname.extname("NODES"));
722 749
723 // Save to file 750 // Save to file
724 - file.saveto(filename, clobber); 751 + file.saveto(fname.filename(), clobber);
725 752
726 // Return 753 // Return
727 return; 754 return;
@@ -733,7 +760,7 @@ void GNodeArray::save(const std::string&amp; filename, const bool&amp; clobber, @@ -733,7 +760,7 @@ void GNodeArray::save(const std::string&amp; filename, const bool&amp; clobber,
733 * 760 *
734 * @param[in] table FITS table. 761 * @param[in] table FITS table.
735 * 762 *
736 - * Reads the nodes from a FITS table. 763 + * Reads the nodes from a FITS @p table.
737 ***************************************************************************/ 764 ***************************************************************************/
738 void GNodeArray::read(const GFitsTable& table) 765 void GNodeArray::read(const GFitsTable& table)
739 { 766 {