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 55 public:
56 56 // Constructors and destructors
57 57 GEbounds(void);
58   - GEbounds(const GEbounds& ebds);
  58 + explicit GEbounds(const std::string& filename);
59 59 explicit GEbounds(const GXmlElement& xml);
  60 + GEbounds(const GEbounds& ebds);
60 61 GEbounds(const GEnergy& emin, const GEnergy& emax);
61 62 GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax,
62 63 const bool& log = true);
63   - GEbounds(const std::string& filename);
64 64 virtual ~GEbounds(void);
65 65  
66 66 // Operators
... ...
include/GEnergies.hpp
... ... @@ -49,8 +49,7 @@ class GEnergies : public GContainer {
49 49 public:
50 50 // Constructors and destructors
51 51 GEnergies(void);
52   - GEnergies(const std::string& filename,
53   - const std::string& extname = "ENERGIES");
  52 + explicit GEnergies(const std::string& filename);
54 53 GEnergies(const GEnergies& energies);
55 54 GEnergies(const int& num, const GEnergy& emin, const GEnergy& emax,
56 55 const bool& log = true);
... ... @@ -78,11 +77,9 @@ public:
78 77 const GEnergy& emax);
79 78 void set_log(const int& num, const GEnergy& emin,
80 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 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 83 void read(const GFitsTable& table);
87 84 void write(GFits& file,
88 85 const std::string& extname = "ENERGIES") const;
... ...
include/GGti.hpp
... ... @@ -58,6 +58,7 @@ class GGti : public GContainer {
58 58 public:
59 59 // Constructors and destructors
60 60 GGti(void);
  61 + explicit GGti(const std::string& filename);
61 62 GGti(const GGti& gti);
62 63 GGti(const GTime& tstart, const GTime& tstop);
63 64 explicit GGti(const GXmlElement& xml);
... ... @@ -81,11 +82,9 @@ public:
81 82 void remove(const int& index);
82 83 void reserve(const int& num);
83 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 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 88 void read(const GFitsTable& table);
90 89 void write(GFits& file,
91 90 const std::string& extname = "GTI") const;
... ...
include/GNodeArray.hpp
... ... @@ -59,9 +59,10 @@ class GNodeArray : public GContainer {
59 59 public:
60 60 // Constructors and destructors
61 61 GNodeArray(void);
62   - GNodeArray(const int& num, const double* array);
  62 + explicit GNodeArray(const std::string& filename);
63 63 explicit GNodeArray(const GVector& vector);
64 64 explicit GNodeArray(const std::vector<double>& vector);
  65 + GNodeArray(const int& num, const double* array);
65 66 GNodeArray(const GNodeArray& array);
66 67 virtual ~GNodeArray(void);
67 68  
... ... @@ -93,10 +94,9 @@ public:
93 94 const int& inx_right(void) const;
94 95 const double& wgt_left(void) const;
95 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 100 void read(const GFitsTable& table);
101 101 void write(GFits& file,
102 102 const std::string& extname = "NODES") const;
... ...
inst/cta/include/GCTAPointing.hpp
... ... @@ -61,8 +61,7 @@ public:
61 61 GCTAPointing(void);
62 62 explicit GCTAPointing(const GSkyDir& dir);
63 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 65 GCTAPointing(const GCTAPointing& pnt);
67 66 virtual ~GCTAPointing(void);
68 67  
... ... @@ -83,8 +82,7 @@ public:
83 82 void zenith(const double& zenith);
84 83 void azimuth(const double& azimuth);
85 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 86 void read(const GFitsTable& table);
89 87 void read(const GXmlElement& xml);
90 88 void write(GXmlElement& xml) const;
... ...
inst/cta/pyext/GCTAPointing.i
... ... @@ -40,8 +40,7 @@ public:
40 40 GCTAPointing(void);
41 41 explicit GCTAPointing(const GSkyDir& dir);
42 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 44 GCTAPointing(const GCTAPointing& pnt);
46 45 virtual ~GCTAPointing(void);
47 46  
... ... @@ -59,8 +58,7 @@ public:
59 58 void zenith(const double& zenith);
60 59 void azimuth(const double& azimuth);
61 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 62 void read(const GFitsTable& table);
65 63 void read(const GXmlElement& xml);
66 64 void write(GXmlElement& xml) const;
... ...
inst/cta/src/GCTAPointing.cpp
... ... @@ -28,8 +28,9 @@
28 28 #ifdef HAVE_CONFIG_H
29 29 #include <config.h>
30 30 #endif
31   -#include "GCTAPointing.hpp"
32 31 #include "GTools.hpp"
  32 +#include "GFilename.hpp"
  33 +#include "GCTAPointing.hpp"
33 34 #include "GFits.hpp"
34 35 #include "GHorizDir.hpp"
35 36  
... ... @@ -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 119 // Initialise members
121 120 init_members();
122 121  
123 122 // Load pointing table
124   - load(filename, extname);
  123 + load(filename);
125 124  
126 125 // Return
127 126 return;
... ... @@ -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 416 // Allocate FITS file
414 417 GFits file;
415 418  
416 419 // Open FITS file
417   - file.open(filename);
  420 + file.open(fname.filename());
418 421  
419 422 // Get pointing table
420   - const GFitsTable& table = *file.table(extname);
  423 + const GFitsTable& table = *file.table(fname.extname("POINTING"));
421 424  
422 425 // Read pointing from table
423 426 read(table);
... ... @@ -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 439 * @param[in] filename Pointing table filename.
437 440 * @param[in] extname Pointing extension name (defaults to "POINTING")
... ...
inst/mwl/include/GMWLObservation.hpp
1 1 /***************************************************************************
2 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 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -49,8 +49,6 @@ public:
49 49 // Constructors and destructors
50 50 GMWLObservation(void);
51 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 52 GMWLObservation(const GMWLObservation& obs);
55 53 virtual ~GMWLObservation(void);
56 54  
... ... @@ -73,8 +71,6 @@ public:
73 71  
74 72 // Other methods
75 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 74 const std::string& filename(void) const;
79 75 const std::string& extno(void) const;
80 76 const std::string& extname(void) const;
... ...
inst/mwl/include/GMWLSpectrum.hpp
... ... @@ -74,8 +74,6 @@ public:
74 74 virtual std::string print(const GChatter& chatter = NORMAL) const;
75 75  
76 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 77 void read(const GFits& file, const std::string& extname);
80 78 void read(const GFits& file, const int& extno);
81 79 const std::string& telescope(void) const;
... ...
inst/mwl/pyext/GMWLObservation.i
1 1 /***************************************************************************
2 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 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -39,12 +39,11 @@
39 39 * instrument. The spectral points are given in physical units.
40 40 ***************************************************************************/
41 41 class GMWLObservation : public GObservation {
  42 +
42 43 public:
43 44 // Constructors and destructors
44 45 GMWLObservation(void);
45 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 47 GMWLObservation(const GMWLObservation& obs);
49 48 virtual ~GMWLObservation(void);
50 49  
... ... @@ -63,8 +62,6 @@ public:
63 62  
64 63 // Other methods
65 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 65 const std::string& filename(void) const;
69 66 const std::string& extno(void) const;
70 67 const std::string& extname(void) const;
... ...
inst/mwl/pyext/GMWLSpectrum.i
... ... @@ -57,8 +57,6 @@ public:
57 57 virtual int number(void) const;
58 58  
59 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 60 void read(const GFits& file, const std::string& extname);
63 61 void read(const GFits& file, const int& extno);
64 62 const std::string& telescope(void) const;
... ...
inst/mwl/src/GMWLObservation.cpp
1 1 /***************************************************************************
2 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 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -28,8 +28,9 @@
28 28 #ifdef HAVE_CONFIG_H
29 29 #include <config.h>
30 30 #endif
31   -#include "GObservationRegistry.hpp"
32 31 #include "GTools.hpp"
  32 +#include "GFilename.hpp"
  33 +#include "GObservationRegistry.hpp"
33 34 #include "GException.hpp"
34 35 #include "GMWLObservation.hpp"
35 36 #include "GMWLSpectrum.hpp"
... ... @@ -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 97 * @brief Copy constructor
141 98 *
142 99 * @param[in] obs Observation.
... ... @@ -336,11 +293,11 @@ void GMWLObservation::read(const GXmlElement&amp; xml)
336 293  
337 294 // Load file (this also stores the filename, extno and
338 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 302 else {
346 303 load(filename);
... ... @@ -442,79 +399,32 @@ void GMWLObservation::load(const std::string&amp; filename)
442 399 // Clear observation
443 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 405 // Allocate spectrum
507 406 GMWLSpectrum* spec = new GMWLSpectrum;
508 407 m_events = spec;
509 408  
510 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 425 // Set attributes
514 426 name("Multi-wavelength observation");
515   - id(filename+"["+extname+"]");
516   - m_filename = filename;
517   - m_extname = extname;
  427 + m_filename = fname.filename();
518 428 m_instrument = spec->instrument();
519 429  
520 430 // Return
... ...
inst/mwl/src/GMWLSpectrum.cpp
1 1 /***************************************************************************
2 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 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -29,6 +29,7 @@
29 29 #include <config.h>
30 30 #endif
31 31 #include "GTools.hpp"
  32 +#include "GFilename.hpp"
32 33 #include "GFits.hpp"
33 34 #include "GFitsTable.hpp"
34 35 #include "GEnergy.hpp"
... ... @@ -259,70 +260,25 @@ GMWLSpectrum* GMWLSpectrum::clone(void) const
259 260 ***************************************************************************/
260 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 266 // Clear object
319 267 clear();
320 268  
321 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 283 // Close FITS file
328 284 file.close();
... ... @@ -336,7 +292,7 @@ void GMWLSpectrum::load(const std::string&amp; filename, const int&amp; extno)
336 292 * @brief Save spectrum
337 293 *
338 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 297 * @todo To be implemented.
342 298 ***************************************************************************/
... ...
inst/mwl/test/test_MWL.cpp
... ... @@ -191,9 +191,9 @@ void TestGMWL::test_optimizer(void)
191 191 test_try("Load multi-wavelength observations");
192 192 try {
193 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 197 obs.append(comptel);
198 198 obs.append(lat);
199 199 obs.append(hess);
... ...
pyext/GEbounds.i
... ... @@ -39,12 +39,12 @@ class GEbounds : public GContainer {
39 39 public:
40 40 // Constructors and destructors
41 41 GEbounds(void);
42   - GEbounds(const GEbounds& ebds);
  42 + explicit GEbounds(const std::string& filename);
43 43 explicit GEbounds(const GXmlElement& xml);
  44 + GEbounds(const GEbounds& ebds);
44 45 GEbounds(const GEnergy& emin, const GEnergy& emax);
45 46 GEbounds(const int& num, const GEnergy& emin, const GEnergy& emax,
46 47 const bool& log = true);
47   - GEbounds(const std::string& filename);
48 48 virtual ~GEbounds(void);
49 49  
50 50 // Methods
... ...
pyext/GEnergies.i
... ... @@ -41,8 +41,7 @@ class GEnergies : public GContainer {
41 41 public:
42 42 // Constructors and destructors
43 43 GEnergies(void);
44   - GEnergies(const std::string& filename,
45   - const std::string& extname = "ENERGIES");
  44 + explicit GEnergies(const std::string& filename);
46 45 GEnergies(const GEnergies& energies);
47 46 GEnergies(const int& num, const GEnergy& emin, const GEnergy& emax,
48 47 const bool& log = true);
... ... @@ -64,13 +63,12 @@ public:
64 63 const GEnergy& emax);
65 64 void set_log(const int& num, const GEnergy& emin,
66 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 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 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 36 * @brief Good Time Interval class
37 37 ***************************************************************************/
38 38 class GGti : public GBase {
  39 +
39 40 public:
40 41 // Constructors and destructors
41 42 GGti(void);
  43 + explicit GGti(const std::string& filename);
42 44 GGti(const GGti& gti);
43 45 GGti(const GTime& tstart, const GTime& tstop);
44 46 explicit GGti(const GXmlElement& xml);
... ... @@ -59,11 +61,9 @@ public:
59 61 void remove(const int& index);
60 62 void reserve(const int& num);
61 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 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 67 void read(const GFitsTable& table);
68 68 void write(GFits& file,
69 69 const std::string& extname = "GTI") const;
... ...
pyext/GNodeArray.i
... ... @@ -39,12 +39,14 @@ namespace std {
39 39 * @brief Node array class
40 40 ***************************************************************************/
41 41 class GNodeArray : public GContainer {
  42 +
42 43 public:
43 44 // Constructors and destructors
44 45 GNodeArray(void);
45   - GNodeArray(const int& num, const double* array);
  46 + explicit GNodeArray(const std::string& filename);
46 47 explicit GNodeArray(const GVector& vector);
47 48 explicit GNodeArray(const std::vector<double>& vector);
  49 + GNodeArray(const int& num, const double* array);
48 50 GNodeArray(const GNodeArray& array);
49 51 virtual ~GNodeArray(void);
50 52  
... ... @@ -70,10 +72,9 @@ public:
70 72 const int& inx_right(void) const;
71 73 const double& wgt_left(void) const;
72 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 78 void read(const GFitsTable& table);
78 79 void write(GFits& file,
79 80 const std::string& extname = "NODES") const;
... ...
src/obs/GEbounds.cpp
... ... @@ -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 89 init_members();
88 90  
89   - // Copy members
90   - copy_members(ebds);
  91 + // Load FITS file
  92 + load(filename);
91 93  
92 94 // Return
93 95 return;
... ... @@ -99,7 +101,7 @@ GEbounds::GEbounds(const GEbounds&amp; ebds)
99 101 *
100 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 106 GEbounds::GEbounds(const GXmlElement& xml)
105 107 {
... ... @@ -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 138 * @brief Single energy band constructor
119 139 *
120 140 * @param[in] emin Minimum energy of the interval.
121 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 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 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 190 * @brief Destructor
189 191 ***************************************************************************/
190 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 572 * @param[in] filename FITS file name.
571 573 *
572 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 579 void GEbounds::load(const std::string& filename)
575 580 {
... ... @@ -603,7 +608,10 @@ void GEbounds::load(const std::string&amp; filename)
603 608 * @param[in] clobber Overwrite any existing file (default: false)?
604 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 616 void GEbounds::save(const std::string& filename,
609 617 const bool& clobber,
... ...
src/obs/GEnergies.cpp
... ... @@ -30,6 +30,7 @@
30 30 #endif
31 31 #include "GTools.hpp"
32 32 #include "GException.hpp"
  33 +#include "GFilename.hpp"
33 34 #include "GEnergies.hpp"
34 35 #include "GFits.hpp"
35 36 #include "GFitsTable.hpp"
... ... @@ -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 83 // Initialise members
84 84 init_members();
85 85  
86 86 // Load energies
87   - load(filename, extname);
  87 + load(filename);
88 88  
89 89 // Return
90 90 return;
... ... @@ -534,21 +534,26 @@ void GEnergies::set_log(const int&amp; num,
534 534 /***********************************************************************//**
535 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 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 549 // Allocate FITS file
545 550 GFits file;
546 551  
547 552 // Open FITS file
548   - file.open(filename);
  553 + file.open(fname.filename());
549 554  
550 555 // Get energies table
551   - const GFitsTable& table = *file.table(extname);
  556 + const GFitsTable& table = *file.table(fname.extname("ENERGIES"));
552 557  
553 558 // Read energies from table
554 559 read(table);
... ... @@ -566,24 +571,25 @@ void GEnergies::load(const std::string&amp; filename, const std::string&amp; extname)
566 571 *
567 572 * @param[in] filename FITS filename.
568 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 585 // Allocate FITS file
580 586 GFits file;
581 587  
582 588 // Write energies to FITS file
583   - write(file, extname);
  589 + write(file, fname.extname("ENERGIES"));
584 590  
585 591 // Save to file
586   - file.saveto(filename, clobber);
  592 + file.saveto(fname.filename(), clobber);
587 593  
588 594 // Return
589 595 return;
... ... @@ -637,7 +643,7 @@ void GEnergies::read(const GFitsTable&amp; table)
637 643 * @brief Write energies into FITS object
638 644 *
639 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 648 * Writes energies into FITS object.
643 649 ***************************************************************************/
... ...
src/obs/GGti.cpp
... ... @@ -30,6 +30,7 @@
30 30 #endif
31 31 #include "GException.hpp"
32 32 #include "GTools.hpp"
  33 +#include "GFilename.hpp"
33 34 #include "GGti.hpp"
34 35 #include "GFits.hpp"
35 36 #include "GFitsTable.hpp"
... ... @@ -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 97 * @brief Copy constructor
77 98 *
78 99 * @param[in] gti Good Time Intervals.
... ... @@ -551,20 +572,25 @@ void GGti::extend(const GGti&amp; gti)
551 572 * @brief Load Good Time Intervals from FITS file
552 573 *
553 574 * @param[in] filename FITS filename.
554   - * @param[in] extname GTI extension name (defaults to "GTI")
555 575 *
556 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 586 // Allocate FITS file
561 587 GFits file;
562 588  
563 589 // Open FITS file
564   - file.open(filename);
  590 + file.open(fname.filename());
565 591  
566 592 // Get GTI table
567   - const GFitsTable& table = *file.table(extname);
  593 + const GFitsTable& table = *file.table(fname.extname("GTI"));
568 594  
569 595 // Read GTI from table
570 596 read(table);
... ... @@ -582,24 +608,25 @@ void GGti::load(const std::string&amp; filename, const std::string&amp; extname)
582 608 *
583 609 * @param[in] filename FITS filename.
584 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 622 // Allocate FITS file
596 623 GFits file;
597 624  
598 625 // Write GTI to FITS file
599   - write(file, extname);
  626 + write(file, fname.extname("GTI"));
600 627  
601 628 // Save to file
602   - file.saveto(filename, clobber);
  629 + file.saveto(fname.filename(), clobber);
603 630  
604 631 // Return
605 632 return;
... ...
src/support/GNodeArray.cpp
1 1 /***************************************************************************
2 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 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -29,9 +29,10 @@
29 29 #include <config.h>
30 30 #endif
31 31 #include <cmath>
  32 +#include "GTools.hpp"
32 33 #include "GException.hpp"
  34 +#include "GFilename.hpp"
33 35 #include "GNodeArray.hpp"
34   -#include "GTools.hpp"
35 36 #include "GFits.hpp"
36 37 #include "GFitsTable.hpp"
37 38 #include "GFitsBinTable.hpp"
... ... @@ -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 99 * @brief Element constructor
79 100 *
80 101 * @param[in] num Number of elements.
... ... @@ -673,20 +694,25 @@ void GNodeArray::set_value(const double&amp; value) const
673 694 * @brief Load nodes from FITS file
674 695 *
675 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 708 // Allocate FITS file
683 709 GFits file;
684 710  
685 711 // Open FITS file
686   - file.open(filename);
  712 + file.open(fname.filename());
687 713  
688 714 // Get nodes table
689   - const GFitsTable& table = *file.table(extname);
  715 + const GFitsTable& table = *file.table(fname.extname("NODES"));
690 716  
691 717 // Read nodes from table
692 718 read(table);
... ... @@ -704,24 +730,25 @@ void GNodeArray::load(const std::string&amp; filename, const std::string&amp; extname)
704 730 *
705 731 * @param[in] filename FITS filename.
706 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 744 // Allocate FITS file
718 745 GFits file;
719 746  
720 747 // Write nodes to FITS file
721   - write(file, extname);
  748 + write(file, fname.extname("NODES"));
722 749  
723 750 // Save to file
724   - file.saveto(filename, clobber);
  751 + file.saveto(fname.filename(), clobber);
725 752  
726 753 // Return
727 754 return;
... ... @@ -733,7 +760,7 @@ void GNodeArray::save(const std::string&amp; filename, const bool&amp; clobber,
733 760 *
734 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 765 void GNodeArray::read(const GFitsTable& table)
739 766 {
... ...