Commit bedebe80f05c78148cce2e92116aa00e672285a0
1 parent
710a5ee6
Use GFilename for filename arguments.
Showing
41 changed files
with
470 additions
and
431 deletions
NEWS
| ... | ... | @@ -43,7 +43,17 @@ of std::string: |
| 43 | 43 | - GGti |
| 44 | 44 | - GLog |
| 45 | 45 | - GModelSpatialDiffuseCube |
| 46 | +- GModelSpatialDiffuseMap | |
| 47 | +- GModelSpectralFunc | |
| 48 | +- GModels | |
| 49 | +- GNodeArray | |
| 50 | +- GObservations | |
| 51 | +- GPha | |
| 52 | +- GRmf | |
| 46 | 53 | - GSkyMap |
| 54 | +- GSkyRegions | |
| 55 | +- GTestSuites | |
| 56 | +- GXml | |
| 47 | 57 | |
| 48 | 58 | The return value has been changed for the following methods: |
| 49 | 59 | - GFits::filename() returns now GFilename instead of std::string | ... | ... |
include/GApplicationPars.hpp
| ... | ... | @@ -24,8 +24,8 @@ |
| 24 | 24 | * @author Juergen Knoedlseder |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -#ifndef GPARS_HPP | |
| 28 | -#define GPARS_HPP | |
| 27 | +#ifndef GAPPLICATIONPARS_HPP | |
| 28 | +#define GAPPLICATIONPARS_HPP | |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <vector> |
| ... | ... | @@ -53,7 +53,7 @@ public: |
| 53 | 53 | // Constructors and destructors |
| 54 | 54 | GApplicationPars(void); |
| 55 | 55 | explicit GApplicationPars(const GFilename& filename); |
| 56 | - GApplicationPars(const GFilename& filename, | |
| 56 | + GApplicationPars(const GFilename& filename, | |
| 57 | 57 | const std::vector<std::string>& args); |
| 58 | 58 | GApplicationPars(const GApplicationPars& pars); |
| 59 | 59 | virtual ~GApplicationPars(void); |
| ... | ... | @@ -76,7 +76,7 @@ public: |
| 76 | 76 | GApplicationPar& append(const GApplicationPar& par); |
| 77 | 77 | void append_standard(void); |
| 78 | 78 | GApplicationPar& insert(const int& index, const GApplicationPar& par); |
| 79 | - GApplicationPar& insert(const std::string& name, | |
| 79 | + GApplicationPar& insert(const std::string& name, | |
| 80 | 80 | const GApplicationPar& par); |
| 81 | 81 | void remove(const int& index); |
| 82 | 82 | void remove(const std::string& name); |
| ... | ... | @@ -84,7 +84,7 @@ public: |
| 84 | 84 | void extend(const GApplicationPars& pars); |
| 85 | 85 | bool contains(const std::string& name) const; |
| 86 | 86 | void load(const GFilename& filename); |
| 87 | - void load(const GFilename& filename, | |
| 87 | + void load(const GFilename& filename, | |
| 88 | 88 | const std::vector<std::string>& args); |
| 89 | 89 | void save(const GFilename& filename); |
| 90 | 90 | std::string print(const GChatter& chatter = NORMAL) const; |
| ... | ... | @@ -195,4 +195,4 @@ void GApplicationPars::reserve(const int& num) |
| 195 | 195 | return; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | -#endif /* GPARS_HPP */ | |
| 198 | +#endif /* GAPPLICATIONPARS_HPP */ | ... | ... |
include/GFilename.hpp
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include "GBase.hpp" |
| 33 | +#include "GTools.hpp" | |
| 33 | 34 | |
| 34 | 35 | |
| 35 | 36 | /***********************************************************************//** |
| ... | ... | @@ -78,12 +79,10 @@ public: |
| 78 | 79 | std::string classname(void) const; |
| 79 | 80 | bool is_empty(void) const; |
| 80 | 81 | int length(void) const; |
| 81 | - //const std::string& fullname(void) const; | |
| 82 | - //const std::string& filename(void) const; | |
| 83 | - const std::string& url(void) const; | |
| 84 | - //const std::string& protocol(void) const; | |
| 85 | - //const std::string& path(void) const; | |
| 86 | - //const std::string& file(void) const; | |
| 82 | + std::string url(void) const; | |
| 83 | + //std::string protocol(void) const; | |
| 84 | + //std::string& path(void) const; | |
| 85 | + //std::string& file(void) const; | |
| 87 | 86 | std::string extname(const std::string& defaultname = "") const; |
| 88 | 87 | const std::string& expression(void) const; |
| 89 | 88 | int extno(const int& defaultno = -1) const; |
| ... | ... | @@ -169,12 +168,13 @@ int GFilename::length(void) const |
| 169 | 168 | * |
| 170 | 169 | * @return Uniform Resource Locator without FITS extension. |
| 171 | 170 | * |
| 172 | - * Returns the Uniform Resource Locator without FITS extension. | |
| 171 | + * Returns the Uniform Resource Locator without FITS extension. Any | |
| 172 | + * environment variable in the URL string will be expanded. | |
| 173 | 173 | ***************************************************************************/ |
| 174 | 174 | inline |
| 175 | -const std::string& GFilename::url(void) const | |
| 175 | +std::string GFilename::url(void) const | |
| 176 | 176 | { |
| 177 | - return (m_filename); | |
| 177 | + return (gammalib::expand_env(m_filename)); | |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | ... | ... |
include/GModelSpatialDiffuseMap.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSpatialDiffuseMap.hpp - Spatial map model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -35,6 +35,7 @@ |
| 35 | 35 | #include "GSkyDir.hpp" |
| 36 | 36 | #include "GSkyMap.hpp" |
| 37 | 37 | #include "GXmlElement.hpp" |
| 38 | +#include "GFilename.hpp" | |
| 38 | 39 | |
| 39 | 40 | |
| 40 | 41 | /***********************************************************************//** |
| ... | ... | @@ -51,9 +52,9 @@ public: |
| 51 | 52 | // Constructors and destructors |
| 52 | 53 | GModelSpatialDiffuseMap(void); |
| 53 | 54 | explicit GModelSpatialDiffuseMap(const GXmlElement& xml); |
| 54 | - GModelSpatialDiffuseMap(const std::string& filename, | |
| 55 | - const double& value = 1.0, | |
| 56 | - const bool& normalize = true); | |
| 55 | + GModelSpatialDiffuseMap(const GFilename& filename, | |
| 56 | + const double& value = 1.0, | |
| 57 | + const bool& normalize = true); | |
| 57 | 58 | GModelSpatialDiffuseMap(const GSkyMap& map, |
| 58 | 59 | const double& value = 1.0, |
| 59 | 60 | const bool& normalize = true); |
| ... | ... | @@ -82,15 +83,15 @@ public: |
| 82 | 83 | virtual std::string print(const GChatter& chatter = NORMAL) const; |
| 83 | 84 | |
| 84 | 85 | // Other methods |
| 85 | - double value(void) const; | |
| 86 | - void value(const double& value); | |
| 87 | - const std::string& filename(void) const; | |
| 88 | - void load(const std::string& filename); | |
| 89 | - const GSkyMap& map(void) const; | |
| 90 | - void map(const GSkyMap& map); | |
| 91 | - bool normalize(void) const; | |
| 92 | - void set_mc_cone(const GSkyDir& centre, | |
| 93 | - const double& radius) const; | |
| 86 | + double value(void) const; | |
| 87 | + void value(const double& value); | |
| 88 | + const GFilename& filename(void) const; | |
| 89 | + void load(const GFilename& filename); | |
| 90 | + const GSkyMap& map(void) const; | |
| 91 | + void map(const GSkyMap& map); | |
| 92 | + bool normalize(void) const; | |
| 93 | + void set_mc_cone(const GSkyDir& centre, | |
| 94 | + const double& radius) const; | |
| 94 | 95 | |
| 95 | 96 | protected: |
| 96 | 97 | // Protected methods |
| ... | ... | @@ -100,13 +101,13 @@ protected: |
| 100 | 101 | void prepare_map(void); |
| 101 | 102 | |
| 102 | 103 | // Protected members |
| 103 | - GModelPar m_value; //!< Value | |
| 104 | - GSkyMap m_map; //!< Skymap | |
| 105 | - std::string m_filename; //!< Name of skymap | |
| 106 | - GSkyDir m_centre; //!< Centre of bounding circle | |
| 107 | - double m_radius; //!< Radius of bounding circle | |
| 108 | - bool m_normalize; //!< Normalize map (default: true) | |
| 109 | - bool m_has_normalize; //!< XML has normalize attribute | |
| 104 | + GModelPar m_value; //!< Value | |
| 105 | + GSkyMap m_map; //!< Skymap | |
| 106 | + GFilename m_filename; //!< Name of skymap | |
| 107 | + GSkyDir m_centre; //!< Centre of bounding circle | |
| 108 | + double m_radius; //!< Radius of bounding circle | |
| 109 | + bool m_normalize; //!< Normalize map (default: true) | |
| 110 | + bool m_has_normalize; //!< XML has normalize attribute | |
| 110 | 111 | |
| 111 | 112 | // MC simulation cache |
| 112 | 113 | mutable double m_mc_norm; //!< Map normalization |
| ... | ... | @@ -178,7 +179,7 @@ void GModelSpatialDiffuseMap::value(const double& value) |
| 178 | 179 | * Returns the file name of the spatial map model. |
| 179 | 180 | ***************************************************************************/ |
| 180 | 181 | inline |
| 181 | -const std::string& GModelSpatialDiffuseMap::filename(void) const | |
| 182 | +const GFilename& GModelSpatialDiffuseMap::filename(void) const | |
| 182 | 183 | { |
| 183 | 184 | return (m_filename); |
| 184 | 185 | } | ... | ... |
include/GModelSpectralFunc.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSpectralFunc.hpp - Spectral function model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -35,6 +35,7 @@ |
| 35 | 35 | #include "GEnergy.hpp" |
| 36 | 36 | #include "GXmlElement.hpp" |
| 37 | 37 | #include "GNodeArray.hpp" |
| 38 | +#include "GFilename.hpp" | |
| 38 | 39 | |
| 39 | 40 | |
| 40 | 41 | /***********************************************************************//** |
| ... | ... | @@ -57,8 +58,8 @@ class GModelSpectralFunc : public GModelSpectral { |
| 57 | 58 | public: |
| 58 | 59 | // Constructors and destructors |
| 59 | 60 | GModelSpectralFunc(void); |
| 60 | - explicit GModelSpectralFunc(const std::string& filename, | |
| 61 | - const double& norm); | |
| 61 | + GModelSpectralFunc(const GFilename& filename, | |
| 62 | + const double& norm); | |
| 62 | 63 | explicit GModelSpectralFunc(const GXmlElement& xml); |
| 63 | 64 | GModelSpectralFunc(const GModelSpectralFunc& model); |
| 64 | 65 | virtual ~GModelSpectralFunc(void); |
| ... | ... | @@ -88,17 +89,17 @@ public: |
| 88 | 89 | virtual std::string print(const GChatter& chatter = NORMAL) const; |
| 89 | 90 | |
| 90 | 91 | // Other methods |
| 91 | - const std::string& filename(void) const; | |
| 92 | - void filename(const std::string& filename); | |
| 93 | - double norm(void) const; | |
| 94 | - void norm(const double& norm); | |
| 92 | + const GFilename& filename(void) const; | |
| 93 | + void filename(const GFilename& filename); | |
| 94 | + double norm(void) const; | |
| 95 | + void norm(const double& norm); | |
| 95 | 96 | |
| 96 | 97 | protected: |
| 97 | 98 | // Protected methods |
| 98 | 99 | void init_members(void); |
| 99 | 100 | void copy_members(const GModelSpectralFunc& model); |
| 100 | 101 | void free_members(void); |
| 101 | - void load_nodes(const std::string& filename); | |
| 102 | + void load_nodes(const GFilename& filename); | |
| 102 | 103 | void set_cache(void) const; |
| 103 | 104 | void mc_update(const GEnergy& emin, const GEnergy& emax) const; |
| 104 | 105 | |
| ... | ... | @@ -108,7 +109,7 @@ protected: |
| 108 | 109 | mutable GNodeArray m_log_nodes; //!< lof10(Energy) nodes of function |
| 109 | 110 | std::vector<double> m_lin_values; //!< Function values at nodes |
| 110 | 111 | std::vector<double> m_log_values; //!< log10(Function) values at nodes |
| 111 | - std::string m_filename; //!< Name of file function | |
| 112 | + GFilename m_filename; //!< Name of file function | |
| 112 | 113 | |
| 113 | 114 | // Cached members used for pre-computations |
| 114 | 115 | mutable std::vector<double> m_prefactor; //!< Power-law normalisations |
| ... | ... | @@ -190,7 +191,7 @@ void GModelSpectralFunc::norm(const double& norm) |
| 190 | 191 | * Returns the name of the file function node file. |
| 191 | 192 | ***************************************************************************/ |
| 192 | 193 | inline |
| 193 | -const std::string& GModelSpectralFunc::filename(void) const | |
| 194 | +const GFilename& GModelSpectralFunc::filename(void) const | |
| 194 | 195 | { |
| 195 | 196 | return (m_filename); |
| 196 | 197 | } |
| ... | ... | @@ -204,7 +205,7 @@ const std::string& GModelSpectralFunc::filename(void) const |
| 204 | 205 | * Loads the nodes from a file function node file and sets the filename. |
| 205 | 206 | ***************************************************************************/ |
| 206 | 207 | inline |
| 207 | -void GModelSpectralFunc::filename(const std::string& filename) | |
| 208 | +void GModelSpectralFunc::filename(const GFilename& filename) | |
| 208 | 209 | { |
| 209 | 210 | load_nodes(filename); |
| 210 | 211 | return; | ... | ... |
include/GModels.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModels.hpp - Model container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -37,6 +37,7 @@ |
| 37 | 37 | /* __ Forward declarations _______________________________________________ */ |
| 38 | 38 | class GEvent; |
| 39 | 39 | class GObservation; |
| 40 | +class GFilename; | |
| 40 | 41 | |
| 41 | 42 | |
| 42 | 43 | /***********************************************************************//** |
| ... | ... | @@ -148,7 +149,7 @@ public: |
| 148 | 149 | // Constructors and destructors |
| 149 | 150 | GModels(void); |
| 150 | 151 | GModels(const GModels& models); |
| 151 | - explicit GModels(const std::string& filename); | |
| 152 | + explicit GModels(const GFilename& filename); | |
| 152 | 153 | virtual ~GModels(void); |
| 153 | 154 | |
| 154 | 155 | // Operators |
| ... | ... | @@ -176,8 +177,8 @@ public: |
| 176 | 177 | void reserve(const int& num); |
| 177 | 178 | void extend(const GModels& models); |
| 178 | 179 | bool contains(const std::string& name) const; |
| 179 | - void load(const std::string& filename); | |
| 180 | - void save(const std::string& filename) const; | |
| 180 | + void load(const GFilename& filename); | |
| 181 | + void save(const GFilename& filename) const; | |
| 181 | 182 | void read(const GXml& xml); |
| 182 | 183 | void write(GXml& xml) const; |
| 183 | 184 | int npars(void) const; | ... | ... |
include/GNodeArray.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GNodeArray.hpp - Array of nodes class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -31,9 +31,12 @@ |
| 31 | 31 | #include <vector> |
| 32 | 32 | #include <string> |
| 33 | 33 | #include "GContainer.hpp" |
| 34 | -#include "GVector.hpp" | |
| 35 | -#include "GFits.hpp" | |
| 36 | -#include "GFitsTable.hpp" | |
| 34 | + | |
| 35 | +/* __ Forward declarations _______________________________________________ */ | |
| 36 | +class GFilename; | |
| 37 | +class GVector; | |
| 38 | +class GFits; | |
| 39 | +class GFitsTable; | |
| 37 | 40 | |
| 38 | 41 | |
| 39 | 42 | /***********************************************************************//** |
| ... | ... | @@ -59,7 +62,7 @@ class GNodeArray : public GContainer { |
| 59 | 62 | public: |
| 60 | 63 | // Constructors and destructors |
| 61 | 64 | GNodeArray(void); |
| 62 | - explicit GNodeArray(const std::string& filename); | |
| 65 | + explicit GNodeArray(const GFilename& filename); | |
| 63 | 66 | explicit GNodeArray(const GVector& vector); |
| 64 | 67 | explicit GNodeArray(const std::vector<double>& vector); |
| 65 | 68 | GNodeArray(const int& num, const double* array); |
| ... | ... | @@ -94,11 +97,11 @@ public: |
| 94 | 97 | const int& inx_right(void) const; |
| 95 | 98 | const double& wgt_left(void) const; |
| 96 | 99 | const double& wgt_right(void) const; |
| 97 | - void load(const std::string& filename); | |
| 98 | - void save(const std::string& filename, | |
| 99 | - const bool& clobber = false) const; | |
| 100 | + void load(const GFilename& filename); | |
| 101 | + void save(const GFilename& filename, | |
| 102 | + const bool& clobber = false) const; | |
| 100 | 103 | void read(const GFitsTable& table); |
| 101 | - void write(GFits& file, | |
| 104 | + void write(GFits& fits, | |
| 102 | 105 | const std::string& extname = "NODES") const; |
| 103 | 106 | std::string print(const GChatter& chatter = NORMAL) const; |
| 104 | 107 | ... | ... |
include/GObservations.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GObservations.hpp - Observation container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -32,11 +32,13 @@ |
| 32 | 32 | #include <vector> |
| 33 | 33 | #include "GContainer.hpp" |
| 34 | 34 | #include "GObservation.hpp" |
| 35 | -#include "GEvent.hpp" | |
| 36 | -#include "GOptimizer.hpp" | |
| 37 | 35 | #include "GOptimizerFunction.hpp" |
| 38 | 36 | #include "GModels.hpp" |
| 39 | 37 | |
| 38 | +/* __ Forward declarations _______________________________________________ */ | |
| 39 | +class GFilename; | |
| 40 | +class GOptimizer; | |
| 41 | + | |
| 40 | 42 | |
| 41 | 43 | /***********************************************************************//** |
| 42 | 44 | * @class GObservations |
| ... | ... | @@ -93,7 +95,7 @@ public: |
| 93 | 95 | // Constructors and destructors |
| 94 | 96 | GObservations(void); |
| 95 | 97 | GObservations(const GObservations& obs); |
| 96 | - explicit GObservations(const std::string& filename); | |
| 98 | + explicit GObservations(const GFilename& filename); | |
| 97 | 99 | virtual ~GObservations(void); |
| 98 | 100 | |
| 99 | 101 | // Operators |
| ... | ... | @@ -117,12 +119,12 @@ public: |
| 117 | 119 | void extend(const GObservations& obs); |
| 118 | 120 | bool contains(const std::string& instrument, |
| 119 | 121 | const std::string& id) const; |
| 120 | - void load(const std::string& filename); | |
| 121 | - void save(const std::string& filename) const; | |
| 122 | + void load(const GFilename& filename); | |
| 123 | + void save(const GFilename& filename) const; | |
| 122 | 124 | void read(const GXml& xml); |
| 123 | 125 | void write(GXml& xml) const; |
| 124 | 126 | void models(const GModels& models); |
| 125 | - void models(const std::string& filename); | |
| 127 | + void models(const GFilename& filename); | |
| 126 | 128 | const GModels& models(void) const; |
| 127 | 129 | void optimize(GOptimizer& opt); |
| 128 | 130 | void errors(GOptimizer& opt); | ... | ... |
include/GPha.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GPha.hpp - XSPEC Pulse Height Analyzer class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -30,10 +30,13 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include "GBase.hpp" |
| 33 | -#include "GEnergy.hpp" | |
| 34 | 33 | #include "GEbounds.hpp" |
| 35 | -#include "GFits.hpp" | |
| 36 | -#include "GFitsTable.hpp" | |
| 34 | +#include "GFilename.hpp" | |
| 35 | + | |
| 36 | +/* __ Forward declarations _______________________________________________ */ | |
| 37 | +class GEnergy; | |
| 38 | +class GFits; | |
| 39 | +class GFitsTable; | |
| 37 | 40 | |
| 38 | 41 | |
| 39 | 42 | /***********************************************************************//** |
| ... | ... | @@ -56,7 +59,7 @@ class GPha : public GBase { |
| 56 | 59 | public: |
| 57 | 60 | // Constructors and destructors |
| 58 | 61 | GPha(void); |
| 59 | - explicit GPha(const std::string& filename); | |
| 62 | + explicit GPha(const GFilename& filename); | |
| 60 | 63 | explicit GPha(const GEbounds& ebds); |
| 61 | 64 | explicit GPha(const int& bins); |
| 62 | 65 | GPha(const GPha& pha); |
| ... | ... | @@ -68,25 +71,25 @@ public: |
| 68 | 71 | const double& operator[](const int& index) const; |
| 69 | 72 | |
| 70 | 73 | // Methods |
| 71 | - void clear(void); | |
| 72 | - GPha* clone(void) const; | |
| 73 | - std::string classname(void) const; | |
| 74 | - int size(void) const; | |
| 75 | - double& at(const int& index); | |
| 76 | - const double& at(const int& index) const; | |
| 77 | - const GEbounds& ebounds(void) const; | |
| 78 | - double counts(void) const; | |
| 79 | - const double& underflow(void) const; | |
| 80 | - const double& overflow(void) const; | |
| 81 | - const double& outflow(void) const; | |
| 82 | - void fill(const GEnergy& energy, const double& value = 1.0); | |
| 83 | - void load(const std::string& filename); | |
| 84 | - void save(const std::string& filename, | |
| 85 | - const bool& clobber = false) const; | |
| 86 | - void read(const GFitsTable& table); | |
| 87 | - void write(GFits& fits) const; | |
| 88 | - const std::string& filename(void) const; | |
| 89 | - std::string print(const GChatter& chatter = NORMAL) const; | |
| 74 | + void clear(void); | |
| 75 | + GPha* clone(void) const; | |
| 76 | + std::string classname(void) const; | |
| 77 | + int size(void) const; | |
| 78 | + double& at(const int& index); | |
| 79 | + const double& at(const int& index) const; | |
| 80 | + const GEbounds& ebounds(void) const; | |
| 81 | + double counts(void) const; | |
| 82 | + const double& underflow(void) const; | |
| 83 | + const double& overflow(void) const; | |
| 84 | + const double& outflow(void) const; | |
| 85 | + void fill(const GEnergy& energy, const double& value = 1.0); | |
| 86 | + void load(const GFilename& filename); | |
| 87 | + void save(const GFilename& filename, | |
| 88 | + const bool& clobber = false) const; | |
| 89 | + void read(const GFitsTable& table); | |
| 90 | + void write(GFits& fits) const; | |
| 91 | + const GFilename& filename(void) const; | |
| 92 | + std::string print(const GChatter& chatter = NORMAL) const; | |
| 90 | 93 | |
| 91 | 94 | protected: |
| 92 | 95 | // Protected methods |
| ... | ... | @@ -95,7 +98,7 @@ protected: |
| 95 | 98 | void free_members(void); |
| 96 | 99 | |
| 97 | 100 | // Protected members |
| 98 | - mutable std::string m_filename; //!< Filename of origin | |
| 101 | + mutable GFilename m_filename; //!< Filename of origin | |
| 99 | 102 | std::vector<double> m_counts; //!< Counts data |
| 100 | 103 | double m_underflow; //!< Number of underflowing events |
| 101 | 104 | double m_overflow; //!< Number of overflowing events |
| ... | ... | @@ -227,7 +230,7 @@ const double& GPha::outflow(void) const |
| 227 | 230 | * no load() or save() method has been called before. |
| 228 | 231 | ***************************************************************************/ |
| 229 | 232 | inline |
| 230 | -const std::string& GPha::filename(void) const | |
| 233 | +const GFilename& GPha::filename(void) const | |
| 231 | 234 | { |
| 232 | 235 | return (m_filename); |
| 233 | 236 | } | ... | ... |
include/GRmf.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GRmf.hpp - XSPEC Redistribution Matrix File class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -30,10 +30,13 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include "GBase.hpp" |
| 33 | +#include "GFilename.hpp" | |
| 33 | 34 | #include "GEbounds.hpp" |
| 34 | 35 | #include "GMatrixSparse.hpp" |
| 35 | -#include "GFits.hpp" | |
| 36 | -#include "GFitsTable.hpp" | |
| 36 | + | |
| 37 | +/* __ Forward declarations _______________________________________________ */ | |
| 38 | +class GFits; | |
| 39 | +class GFitsTable; | |
| 37 | 40 | |
| 38 | 41 | |
| 39 | 42 | /***********************************************************************//** |
| ... | ... | @@ -48,7 +51,7 @@ class GRmf : public GBase { |
| 48 | 51 | public: |
| 49 | 52 | // Constructors and destructors |
| 50 | 53 | GRmf(void); |
| 51 | - explicit GRmf(const std::string& filename); | |
| 54 | + explicit GRmf(const GFilename& filename); | |
| 52 | 55 | GRmf(const GEbounds& etrue, const GEbounds& emeasured); |
| 53 | 56 | GRmf(const GRmf& rmf); |
| 54 | 57 | virtual ~GRmf(void); |
| ... | ... | @@ -74,14 +77,14 @@ public: |
| 74 | 77 | GEbounds etrue(const GEnergy& emeasured) const; |
| 75 | 78 | GEbounds emeasured(const GEnergy& etrue) const; |
| 76 | 79 | const GMatrixSparse& matrix(void) const; |
| 77 | - void load(const std::string& filename); | |
| 78 | - void save(const std::string& filename, | |
| 79 | - const bool& clobber = false, | |
| 80 | + void load(const GFilename& filename); | |
| 81 | + void save(const GFilename& filename, | |
| 82 | + const bool& clobber = false, | |
| 80 | 83 | const std::string& unit = "keV") const; |
| 81 | 84 | void read(const GFitsTable& table); |
| 82 | 85 | void write(GFits& fits, |
| 83 | 86 | const std::string& unit = "keV") const; |
| 84 | - const std::string& filename(void) const; | |
| 87 | + const GFilename& filename(void) const; | |
| 85 | 88 | std::string print(const GChatter& chatter = NORMAL) const; |
| 86 | 89 | |
| 87 | 90 | protected: |
| ... | ... | @@ -91,12 +94,12 @@ protected: |
| 91 | 94 | void free_members(void); |
| 92 | 95 | |
| 93 | 96 | // Protected members |
| 94 | - mutable std::string m_filename; //!< Filename of origin | |
| 95 | - GEbounds m_ebds_true; //!< True energy boundaries | |
| 96 | - GEbounds m_ebds_measured; //!< Measured energy boundaries | |
| 97 | - GMatrixSparse m_matrix; //!< Sparse redistribution matrix | |
| 98 | - int m_imeasmax; //!< Index of measured maximum | |
| 99 | - int m_itruemax; //!< Index of true maximum | |
| 97 | + mutable GFilename m_filename; //!< Filename of origin | |
| 98 | + GEbounds m_ebds_true; //!< True energy boundaries | |
| 99 | + GEbounds m_ebds_measured; //!< Measured energy boundaries | |
| 100 | + GMatrixSparse m_matrix; //!< Sparse redistribution matrix | |
| 101 | + int m_imeasmax; //!< Index of measured maximum | |
| 102 | + int m_itruemax; //!< Index of true maximum | |
| 100 | 103 | |
| 101 | 104 | }; |
| 102 | 105 | |
| ... | ... | @@ -268,7 +271,7 @@ const GMatrixSparse& GRmf::matrix(void) const |
| 268 | 271 | * no load() or save() method has been called before. |
| 269 | 272 | ***************************************************************************/ |
| 270 | 273 | inline |
| 271 | -const std::string& GRmf::filename(void) const | |
| 274 | +const GFilename& GRmf::filename(void) const | |
| 272 | 275 | { |
| 273 | 276 | return (m_filename); |
| 274 | 277 | } | ... | ... |
include/GSkyRegions.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GSkyRegions.hpp - Sky region container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013-2015 by Pierrick Martin * | |
| 4 | + * copyright (C) 2013-2016 by Pierrick Martin * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -33,7 +33,11 @@ |
| 33 | 33 | #include "GContainer.hpp" |
| 34 | 34 | #include "GSkyRegion.hpp" |
| 35 | 35 | #include "GException.hpp" |
| 36 | -#include "GSkyDir.hpp" | |
| 36 | +#include "GFilename.hpp" | |
| 37 | + | |
| 38 | +/* __ Forward declarations _______________________________________________ */ | |
| 39 | +class GSkyDir; | |
| 40 | + | |
| 37 | 41 | |
| 38 | 42 | /***********************************************************************//** |
| 39 | 43 | * @class GSkyRegions |
| ... | ... | @@ -56,7 +60,7 @@ public: |
| 56 | 60 | // Constructors and destructors |
| 57 | 61 | GSkyRegions(void); |
| 58 | 62 | GSkyRegions(const GSkyRegions& regions); |
| 59 | - explicit GSkyRegions(const std::string& filename); | |
| 63 | + explicit GSkyRegions(const GFilename& filename); | |
| 60 | 64 | virtual ~GSkyRegions(void); |
| 61 | 65 | |
| 62 | 66 | // Operators |
| ... | ... | @@ -65,25 +69,25 @@ public: |
| 65 | 69 | const GSkyRegion* operator[](const int& index) const; |
| 66 | 70 | |
| 67 | 71 | // Methods |
| 68 | - void clear(void); | |
| 69 | - GSkyRegions* clone(void) const; | |
| 70 | - std::string classname(void) const; | |
| 71 | - GSkyRegion* at(const int& index); | |
| 72 | - const GSkyRegion* at(const int& index) const; | |
| 73 | - int size(void) const; | |
| 74 | - bool is_empty(void) const; | |
| 75 | - GSkyRegion* set(const int& index, const GSkyRegion& region); | |
| 76 | - GSkyRegion* append(const GSkyRegion& region); | |
| 77 | - GSkyRegion* insert(const int& index, const GSkyRegion& region); | |
| 78 | - void remove(const int& index); | |
| 79 | - void reserve(const int& num); | |
| 80 | - void extend(const GSkyRegions& regions); | |
| 81 | - bool contains(const GSkyDir& dir) const; | |
| 82 | - bool overlaps(const GSkyRegion& reg) const; | |
| 83 | - void load(const std::string& filename); | |
| 84 | - void save(const std::string& filename) const; | |
| 85 | - const std::string& filename(void) const; | |
| 86 | - std::string print(const GChatter& chatter = NORMAL) const; | |
| 72 | + void clear(void); | |
| 73 | + GSkyRegions* clone(void) const; | |
| 74 | + std::string classname(void) const; | |
| 75 | + GSkyRegion* at(const int& index); | |
| 76 | + const GSkyRegion* at(const int& index) const; | |
| 77 | + int size(void) const; | |
| 78 | + bool is_empty(void) const; | |
| 79 | + GSkyRegion* set(const int& index, const GSkyRegion& region); | |
| 80 | + GSkyRegion* append(const GSkyRegion& region); | |
| 81 | + GSkyRegion* insert(const int& index, const GSkyRegion& region); | |
| 82 | + void remove(const int& index); | |
| 83 | + void reserve(const int& num); | |
| 84 | + void extend(const GSkyRegions& regions); | |
| 85 | + bool contains(const GSkyDir& dir) const; | |
| 86 | + bool overlaps(const GSkyRegion& reg) const; | |
| 87 | + void load(const GFilename& filename); | |
| 88 | + void save(const GFilename& filename) const; | |
| 89 | + const GFilename& filename(void) const; | |
| 90 | + std::string print(const GChatter& chatter = NORMAL) const; | |
| 87 | 91 | |
| 88 | 92 | protected: |
| 89 | 93 | // Protected methods |
| ... | ... | @@ -92,7 +96,7 @@ protected: |
| 92 | 96 | void free_members(void); |
| 93 | 97 | |
| 94 | 98 | // Protected members |
| 95 | - mutable std::string m_filename; //!< Filename of origin | |
| 99 | + mutable GFilename m_filename; //!< Filename of origin | |
| 96 | 100 | std::vector<GSkyRegion*> m_regions; //!< List of regions |
| 97 | 101 | }; |
| 98 | 102 | |
| ... | ... | @@ -191,7 +195,7 @@ void GSkyRegions::reserve(const int& num) |
| 191 | 195 | * no load() or save() method has been called before. |
| 192 | 196 | ***************************************************************************/ |
| 193 | 197 | inline |
| 194 | -const std::string& GSkyRegions::filename(void) const | |
| 198 | +const GFilename& GSkyRegions::filename(void) const | |
| 195 | 199 | { |
| 196 | 200 | return (m_filename); |
| 197 | 201 | } | ... | ... |
include/GTestSuites.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GTestSuites.hpp - Test suite container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2015 by Jean-Baptiste Cayrou * | |
| 4 | + * copyright (C) 2012-2016 by Jean-Baptiste Cayrou * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -32,9 +32,12 @@ |
| 32 | 32 | #include <vector> |
| 33 | 33 | #include "GContainer.hpp" |
| 34 | 34 | #include "GLog.hpp" |
| 35 | -#include "GXml.hpp" | |
| 36 | 35 | #include "GTestSuite.hpp" |
| 37 | 36 | |
| 37 | +/* __ Forward declarations _______________________________________________ */ | |
| 38 | +class GFilename; | |
| 39 | +class GXml; | |
| 40 | + | |
| 38 | 41 | |
| 39 | 42 | /***********************************************************************//** |
| 40 | 43 | * @class GTestSuites |
| ... | ... | @@ -53,7 +56,7 @@ public: |
| 53 | 56 | // Constructors and destructors |
| 54 | 57 | GTestSuites(void); |
| 55 | 58 | GTestSuites(const GTestSuites& suites); |
| 56 | - GTestSuites(const std::string& name); | |
| 59 | + explicit GTestSuites(const std::string& name); | |
| 57 | 60 | virtual ~GTestSuites(void); |
| 58 | 61 | |
| 59 | 62 | // Operators |
| ... | ... | @@ -83,7 +86,7 @@ public: |
| 83 | 86 | int tests(void) const; |
| 84 | 87 | const time_t& timestamp(void) const; |
| 85 | 88 | bool run(void); |
| 86 | - void save(const std::string& filename) const; | |
| 89 | + void save(const GFilename& filename) const; | |
| 87 | 90 | std::string print(const GChatter& chatter = NORMAL) const; |
| 88 | 91 | |
| 89 | 92 | protected: | ... | ... |
include/GXml.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GXml.hpp - XML class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -37,6 +37,7 @@ |
| 37 | 37 | #include "GXmlText.hpp" |
| 38 | 38 | |
| 39 | 39 | /* __ Forward declarations _______________________________________________ */ |
| 40 | +class GFilename; | |
| 40 | 41 | |
| 41 | 42 | |
| 42 | 43 | /***********************************************************************//** |
| ... | ... | @@ -208,8 +209,8 @@ public: |
| 208 | 209 | const GXmlElement* element(const std::string& name) const; |
| 209 | 210 | GXmlElement* element(const std::string& name, const int& index); |
| 210 | 211 | const GXmlElement* element(const std::string& name, const int& index) const; |
| 211 | - void load(const std::string& filename); | |
| 212 | - void save(const std::string& filename); | |
| 212 | + void load(const GFilename& filename); | |
| 213 | + void save(const GFilename& filename); | |
| 213 | 214 | void read(const GUrl& url); |
| 214 | 215 | void write(GUrl& url, const int& indent = 0) const; |
| 215 | 216 | std::string print(const GChatter& chatter = NORMAL) const; | ... | ... |
inst/cta/src/GCTAOnOffObservation.cpp
| ... | ... | @@ -388,25 +388,25 @@ void GCTAOnOffObservation::write(GXmlElement& xml) const |
| 388 | 388 | |
| 389 | 389 | // Handle on counts |
| 390 | 390 | if (par->attribute("name") == "Pha_on") { |
| 391 | - par->attribute("file", m_on_spec.filename()); | |
| 391 | + par->attribute("file", m_on_spec.filename().url()); | |
| 392 | 392 | npar[0]++; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | // Handle off counts |
| 396 | 396 | else if (par->attribute("name") == "Pha_off") { |
| 397 | - par->attribute("file", m_off_spec.filename()); | |
| 397 | + par->attribute("file", m_off_spec.filename().url()); | |
| 398 | 398 | npar[1]++; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | // Handle on regions |
| 402 | 402 | else if (par->attribute("name") == "Regions_on") { |
| 403 | - par->attribute("file", m_on_regions.filename()); | |
| 403 | + par->attribute("file", m_on_regions.filename().url()); | |
| 404 | 404 | npar[2]++; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | // Handle off regions |
| 408 | 408 | else if (par->attribute("name") == "Regions_off") { |
| 409 | - par->attribute("file", m_off_regions.filename()); | |
| 409 | + par->attribute("file", m_off_regions.filename().url()); | |
| 410 | 410 | npar[3]++; |
| 411 | 411 | } |
| 412 | 412 | |
| ... | ... | @@ -418,7 +418,7 @@ void GCTAOnOffObservation::write(GXmlElement& xml) const |
| 418 | 418 | |
| 419 | 419 | // Handle energy resolution |
| 420 | 420 | else if (par->attribute("name") == "Rmf") { |
| 421 | - par->attribute("file", m_rmf.filename()); | |
| 421 | + par->attribute("file", m_rmf.filename().url()); | |
| 422 | 422 | npar[5]++; |
| 423 | 423 | } |
| 424 | 424 | } | ... | ... |
pyext/GArf.i
| ... | ... | @@ -50,7 +50,6 @@ public: |
| 50 | 50 | std::string classname(void) const; |
| 51 | 51 | int size(void) const; |
| 52 | 52 | double& at(const int& index); |
| 53 | - const double& at(const int& index) const; | |
| 54 | 53 | const GEbounds& ebounds(void) const; |
| 55 | 54 | void load(const GFilename& filename); |
| 56 | 55 | void save(const GFilename& filename, | ... | ... |
pyext/GFilename.i
| ... | ... | @@ -53,10 +53,10 @@ public: |
| 53 | 53 | std::string classname(void) const; |
| 54 | 54 | bool is_empty(void) const; |
| 55 | 55 | int length(void) const; |
| 56 | - const std::string& url(void) const; | |
| 57 | - //const std::string& protocol(void) const; | |
| 58 | - //const std::string& path(void) const; | |
| 59 | - //const std::string& file(void) const; | |
| 56 | + std::string url(void) const; | |
| 57 | + //std::string protocol(void) const; | |
| 58 | + //std::string path(void) const; | |
| 59 | + //std::string file(void) const; | |
| 60 | 60 | std::string extname(const std::string& defaultname = "") const; |
| 61 | 61 | const std::string& expression(void) const; |
| 62 | 62 | int extno(const int& defaultno = -1) const; | ... | ... |
pyext/GModelSpatialDiffuseMap.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSpatialDiffuseMap.i - Spatial map model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,9 +39,9 @@ public: |
| 39 | 39 | // Constructors and destructors |
| 40 | 40 | GModelSpatialDiffuseMap(void); |
| 41 | 41 | explicit GModelSpatialDiffuseMap(const GXmlElement& xml); |
| 42 | - GModelSpatialDiffuseMap(const std::string& filename, | |
| 43 | - const double& value = 1.0, | |
| 44 | - const bool& normalize = true); | |
| 42 | + GModelSpatialDiffuseMap(const GFilename& filename, | |
| 43 | + const double& value = 1.0, | |
| 44 | + const bool& normalize = true); | |
| 45 | 45 | GModelSpatialDiffuseMap(const GSkyMap& map, |
| 46 | 46 | const double& value = 1.0, |
| 47 | 47 | const bool& normalize = true); |
| ... | ... | @@ -66,15 +66,15 @@ public: |
| 66 | 66 | virtual void write(GXmlElement& xml) const; |
| 67 | 67 | |
| 68 | 68 | // Other methods |
| 69 | - double value(void) const; | |
| 70 | - void value(const double& value); | |
| 71 | - const std::string& filename(void) const; | |
| 72 | - void load(const std::string& filename); | |
| 73 | - const GSkyMap& map(void) const; | |
| 74 | - void map(const GSkyMap& map); | |
| 75 | - bool normalize(void) const; | |
| 76 | - void set_mc_cone(const GSkyDir& centre, | |
| 77 | - const double& radius) const; | |
| 69 | + double value(void) const; | |
| 70 | + void value(const double& value); | |
| 71 | + const GFilename& filename(void) const; | |
| 72 | + void load(const GFilename& filename); | |
| 73 | + const GSkyMap& map(void) const; | |
| 74 | + void map(const GSkyMap& map); | |
| 75 | + bool normalize(void) const; | |
| 76 | + void set_mc_cone(const GSkyDir& centre, | |
| 77 | + const double& radius) const; | |
| 78 | 78 | }; |
| 79 | 79 | |
| 80 | 80 | ... | ... |
pyext/GModelSpectralFunc.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSpectralFunc.i - Spectral function model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -38,8 +38,8 @@ class GModelSpectralFunc : public GModelSpectral { |
| 38 | 38 | public: |
| 39 | 39 | // Constructors and destructors |
| 40 | 40 | GModelSpectralFunc(void); |
| 41 | - explicit GModelSpectralFunc(const std::string& filename, | |
| 42 | - const double& norm); | |
| 41 | + GModelSpectralFunc(const GFilename& filename, | |
| 42 | + const double& norm); | |
| 43 | 43 | explicit GModelSpectralFunc(const GXmlElement& xml); |
| 44 | 44 | GModelSpectralFunc(const GModelSpectralFunc& model); |
| 45 | 45 | virtual ~GModelSpectralFunc(void); |
| ... | ... | @@ -65,10 +65,10 @@ public: |
| 65 | 65 | virtual void write(GXmlElement& xml) const; |
| 66 | 66 | |
| 67 | 67 | // Other methods |
| 68 | - const std::string& filename(void) const; | |
| 69 | - void filename(const std::string& filename); | |
| 70 | - double norm(void) const; | |
| 71 | - void norm(const double& norm); | |
| 68 | + const GFilename& filename(void) const; | |
| 69 | + void filename(const GFilename& filename); | |
| 70 | + double norm(void) const; | |
| 71 | + void norm(const double& norm); | |
| 72 | 72 | }; |
| 73 | 73 | |
| 74 | 74 | ... | ... |
pyext/GModels.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModels.i - Model container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -42,7 +42,7 @@ public: |
| 42 | 42 | // Constructors and destructors |
| 43 | 43 | GModels(void); |
| 44 | 44 | GModels(const GModels& models); |
| 45 | - explicit GModels(const std::string& filename); | |
| 45 | + explicit GModels(const GFilename& filename); | |
| 46 | 46 | virtual ~GModels(void); |
| 47 | 47 | |
| 48 | 48 | // Methods |
| ... | ... | @@ -62,8 +62,8 @@ public: |
| 62 | 62 | void reserve(const int& num); |
| 63 | 63 | void extend(const GModels& models); |
| 64 | 64 | bool contains(const std::string& name) const; |
| 65 | - void load(const std::string& filename); | |
| 66 | - void save(const std::string& filename) const; | |
| 65 | + void load(const GFilename& filename); | |
| 66 | + void save(const GFilename& filename) const; | |
| 67 | 67 | void read(const GXml& xml); |
| 68 | 68 | void write(GXml& xml) const; |
| 69 | 69 | int npars(void) const; | ... | ... |
pyext/GNodeArray.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GNodeArray.i - Array of nodes class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -43,7 +43,7 @@ class GNodeArray : public GContainer { |
| 43 | 43 | public: |
| 44 | 44 | // Constructors and destructors |
| 45 | 45 | GNodeArray(void); |
| 46 | - explicit GNodeArray(const std::string& filename); | |
| 46 | + explicit GNodeArray(const GFilename& filename); | |
| 47 | 47 | explicit GNodeArray(const GVector& vector); |
| 48 | 48 | explicit GNodeArray(const std::vector<double>& vector); |
| 49 | 49 | GNodeArray(const int& num, const double* array); |
| ... | ... | @@ -72,11 +72,11 @@ public: |
| 72 | 72 | const int& inx_right(void) const; |
| 73 | 73 | const double& wgt_left(void) const; |
| 74 | 74 | const double& wgt_right(void) const; |
| 75 | - void load(const std::string& filename); | |
| 76 | - void save(const std::string& filename, | |
| 77 | - const bool& clobber = false) const; | |
| 75 | + void load(const GFilename& filename); | |
| 76 | + void save(const GFilename& filename, | |
| 77 | + const bool& clobber = false) const; | |
| 78 | 78 | void read(const GFitsTable& table); |
| 79 | - void write(GFits& file, | |
| 79 | + void write(GFits& fits, | |
| 80 | 80 | const std::string& extname = "NODES") const; |
| 81 | 81 | }; |
| 82 | 82 | ... | ... |
pyext/GObservations.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GObservations.i - Observations container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,7 +39,7 @@ public: |
| 39 | 39 | // Constructors and destructors |
| 40 | 40 | GObservations(void); |
| 41 | 41 | GObservations(const GObservations& obs); |
| 42 | - explicit GObservations(const std::string& filename); | |
| 42 | + explicit GObservations(const GFilename& filename); | |
| 43 | 43 | virtual ~GObservations(void); |
| 44 | 44 | |
| 45 | 45 | // Methods |
| ... | ... | @@ -56,12 +56,12 @@ public: |
| 56 | 56 | void extend(const GObservations& obs); |
| 57 | 57 | bool contains(const std::string& instrument, |
| 58 | 58 | const std::string& id) const; |
| 59 | - void load(const std::string& filename); | |
| 60 | - void save(const std::string& filename) const; | |
| 59 | + void load(const GFilename& filename); | |
| 60 | + void save(const GFilename& filename) const; | |
| 61 | 61 | void read(const GXml& xml); |
| 62 | 62 | void write(GXml& xml) const; |
| 63 | 63 | void models(const GModels& models); |
| 64 | - void models(const std::string& filename); | |
| 64 | + void models(const GFilename& filename); | |
| 65 | 65 | const GModels& models(void); |
| 66 | 66 | void optimize(GOptimizer& opt); |
| 67 | 67 | void errors(GOptimizer& opt); | ... | ... |
pyext/GPha.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GPha.i - XSPEC Pulse Height Analyzer class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -38,30 +38,30 @@ class GPha : public GBase { |
| 38 | 38 | public: |
| 39 | 39 | // Constructors and destructors |
| 40 | 40 | GPha(void); |
| 41 | - explicit GPha(const std::string& filename); | |
| 41 | + explicit GPha(const GFilename& filename); | |
| 42 | 42 | explicit GPha(const GEbounds& ebds); |
| 43 | 43 | explicit GPha(const int& bins); |
| 44 | 44 | GPha(const GPha& pha); |
| 45 | 45 | virtual ~GPha(void); |
| 46 | 46 | |
| 47 | 47 | // Methods |
| 48 | - void clear(void); | |
| 49 | - GPha* clone(void) const; | |
| 50 | - std::string classname(void) const; | |
| 51 | - int size(void) const; | |
| 52 | - double& at(const int& index); | |
| 53 | - const GEbounds& ebounds(void) const; | |
| 54 | - double counts(void) const; | |
| 55 | - const double& underflow(void) const; | |
| 56 | - const double& overflow(void) const; | |
| 57 | - const double& outflow(void) const; | |
| 58 | - void fill(const GEnergy& energy, const double& value = 1.0); | |
| 59 | - void load(const std::string& filename); | |
| 60 | - void save(const std::string& filename, | |
| 61 | - const bool& clobber = false) const; | |
| 62 | - void read(const GFitsTable& table); | |
| 63 | - void write(GFits& fits) const; | |
| 64 | - const std::string& filename(void) const; | |
| 48 | + void clear(void); | |
| 49 | + GPha* clone(void) const; | |
| 50 | + std::string classname(void) const; | |
| 51 | + int size(void) const; | |
| 52 | + double& at(const int& index); | |
| 53 | + const GEbounds& ebounds(void) const; | |
| 54 | + double counts(void) const; | |
| 55 | + const double& underflow(void) const; | |
| 56 | + const double& overflow(void) const; | |
| 57 | + const double& outflow(void) const; | |
| 58 | + void fill(const GEnergy& energy, const double& value = 1.0); | |
| 59 | + void load(const GFilename& filename); | |
| 60 | + void save(const GFilename& filename, | |
| 61 | + const bool& clobber = false) const; | |
| 62 | + void read(const GFitsTable& table); | |
| 63 | + void write(GFits& fits) const; | |
| 64 | + const GFilename& filename(void) const; | |
| 65 | 65 | }; |
| 66 | 66 | |
| 67 | 67 | ... | ... |
pyext/GRmf.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GRmf.i - XSPEC Redistribution Matrix File class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -41,7 +41,7 @@ class GRmf : public GBase { |
| 41 | 41 | public: |
| 42 | 42 | // Constructors and destructors |
| 43 | 43 | GRmf(void); |
| 44 | - explicit GRmf(const std::string& filename); | |
| 44 | + explicit GRmf(const GFilename& filename); | |
| 45 | 45 | GRmf(const GEbounds& etrue, const GEbounds& emeasured); |
| 46 | 46 | GRmf(const GRmf& rmf); |
| 47 | 47 | virtual ~GRmf(void); |
| ... | ... | @@ -59,14 +59,14 @@ public: |
| 59 | 59 | GEbounds etrue(const GEnergy& emeasured) const; |
| 60 | 60 | GEbounds emeasured(const GEnergy& etrue) const; |
| 61 | 61 | const GMatrixSparse& matrix(void) const; |
| 62 | - void load(const std::string& filename); | |
| 63 | - void save(const std::string& filename, | |
| 64 | - const bool& clobber = false, | |
| 62 | + void load(const GFilename& filename); | |
| 63 | + void save(const GFilename& filename, | |
| 64 | + const bool& clobber = false, | |
| 65 | 65 | const std::string& unit = "keV") const; |
| 66 | 66 | void read(const GFitsTable& table); |
| 67 | 67 | void write(GFits& fits, |
| 68 | 68 | const std::string& unit = "keV") const; |
| 69 | - const std::string& filename(void) const; | |
| 69 | + const GFilename& filename(void) const; | |
| 70 | 70 | }; |
| 71 | 71 | |
| 72 | 72 | ... | ... |
pyext/GSkyRegions.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GSkyRegions.i - Sky region container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013-2015 by Pierrick Martin * | |
| 4 | + * copyright (C) 2013-2016 by Pierrick Martin * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,25 +39,27 @@ public: |
| 39 | 39 | // Constructors and destructors |
| 40 | 40 | GSkyRegions(void); |
| 41 | 41 | GSkyRegions(const GSkyRegions& regions); |
| 42 | - explicit GSkyRegions(const std::string& filename); | |
| 42 | + explicit GSkyRegions(const GFilename& filename); | |
| 43 | 43 | virtual ~GSkyRegions(void); |
| 44 | 44 | |
| 45 | 45 | // Methods |
| 46 | - void clear(void); | |
| 47 | - GSkyRegions* clone(void) const; | |
| 48 | - std::string classname(void) const; | |
| 49 | - GSkyRegion* at(const int& index); | |
| 50 | - int size(void) const; | |
| 51 | - bool is_empty(void) const; | |
| 52 | - GSkyRegion* set(const int& index, const GSkyRegion& region); | |
| 53 | - GSkyRegion* append(const GSkyRegion& region); | |
| 54 | - GSkyRegion* insert(const int& index, const GSkyRegion& region); | |
| 55 | - void remove(const int& index); | |
| 56 | - void reserve(const int& num); | |
| 57 | - void extend(const GSkyRegions& regions); | |
| 58 | - void load(const std::string& filename); | |
| 59 | - void save(const std::string& filename) const; | |
| 60 | - | |
| 46 | + void clear(void); | |
| 47 | + GSkyRegions* clone(void) const; | |
| 48 | + std::string classname(void) const; | |
| 49 | + GSkyRegion* at(const int& index); | |
| 50 | + int size(void) const; | |
| 51 | + bool is_empty(void) const; | |
| 52 | + GSkyRegion* set(const int& index, const GSkyRegion& region); | |
| 53 | + GSkyRegion* append(const GSkyRegion& region); | |
| 54 | + GSkyRegion* insert(const int& index, const GSkyRegion& region); | |
| 55 | + void remove(const int& index); | |
| 56 | + void reserve(const int& num); | |
| 57 | + void extend(const GSkyRegions& regions); | |
| 58 | + bool contains(const GSkyDir& dir) const; | |
| 59 | + bool overlaps(const GSkyRegion& reg) const; | |
| 60 | + void load(const GFilename& filename); | |
| 61 | + void save(const GFilename& filename) const; | |
| 62 | + const GFilename& filename(void) const; | |
| 61 | 63 | }; |
| 62 | 64 | |
| 63 | 65 | /***********************************************************************//** | ... | ... |
pyext/GTestSuites.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GTestSuites.i - Test suite container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2015 Jean-Baptiste Cayrou * | |
| 4 | + * copyright (C) 2012-2016 Jean-Baptiste Cayrou * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -35,12 +35,12 @@ |
| 35 | 35 | * @brief Test suites container class |
| 36 | 36 | ***************************************************************************/ |
| 37 | 37 | class GTestSuites : public GContainer { |
| 38 | - public: | |
| 39 | 38 | |
| 39 | +public: | |
| 40 | 40 | // Constructors and destructors |
| 41 | 41 | GTestSuites(void); |
| 42 | 42 | GTestSuites(const GTestSuites& suites); |
| 43 | - GTestSuites(const std::string& name); | |
| 43 | + explicit GTestSuites(const std::string& name); | |
| 44 | 44 | virtual ~GTestSuites(void); |
| 45 | 45 | |
| 46 | 46 | // Methods |
| ... | ... | @@ -64,7 +64,7 @@ class GTestSuites : public GContainer { |
| 64 | 64 | int tests(void) const; |
| 65 | 65 | const time_t& timestamp(void) const; |
| 66 | 66 | bool run(void); |
| 67 | - void save(const std::string& filename) const; | |
| 67 | + void save(const GFilename& filename) const; | |
| 68 | 68 | }; |
| 69 | 69 | |
| 70 | 70 | ... | ... |
pyext/GXml.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GXml.i - XML class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -27,6 +27,7 @@ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| 28 | 28 | #include "GXml.hpp" |
| 29 | 29 | #include "GTools.hpp" |
| 30 | +#include "GFilename.hpp" | |
| 30 | 31 | %} |
| 31 | 32 | |
| 32 | 33 | |
| ... | ... | @@ -61,8 +62,8 @@ public: |
| 61 | 62 | GXmlElement* element(const int& index); |
| 62 | 63 | GXmlElement* element(const std::string& name); |
| 63 | 64 | GXmlElement* element(const std::string& name, const int& index); |
| 64 | - void load(const std::string& filename); | |
| 65 | - void save(const std::string& filename); | |
| 65 | + void load(const GFilename& filename); | |
| 66 | + void save(const GFilename& filename); | |
| 66 | 67 | void read(const GUrl& url); |
| 67 | 68 | void write(GUrl& url, const int& indent = 0) const; |
| 68 | 69 | }; | ... | ... |
src/model/GModelSpatialDiffuseMap.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSpatialDiffuseMap.cpp - Spatial map model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -107,9 +107,9 @@ GModelSpatialDiffuseMap::GModelSpatialDiffuseMap(const GXmlElement& xml) : |
| 107 | 107 | * Constructs spatial map model by loading a skymap from the file specified |
| 108 | 108 | * by @p filename and by setting the normalization @p value. |
| 109 | 109 | ***************************************************************************/ |
| 110 | -GModelSpatialDiffuseMap::GModelSpatialDiffuseMap(const std::string& filename, | |
| 111 | - const double& value, | |
| 112 | - const bool& normalize) : | |
| 110 | +GModelSpatialDiffuseMap::GModelSpatialDiffuseMap(const GFilename& filename, | |
| 111 | + const double& value, | |
| 112 | + const bool& normalize) : | |
| 113 | 113 | GModelSpatialDiffuse() |
| 114 | 114 | { |
| 115 | 115 | // Initialise members |
| ... | ... | @@ -585,7 +585,7 @@ void GModelSpatialDiffuseMap::write(GXmlElement& xml) const |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | // Set model filename |
| 588 | - xml.attribute("file", m_filename); | |
| 588 | + xml.attribute("file", m_filename.url()); | |
| 589 | 589 | |
| 590 | 590 | // Verify model type |
| 591 | 591 | if (xml.attribute("type") != "SpatialMap") { |
| ... | ... | @@ -830,7 +830,8 @@ std::string GModelSpatialDiffuseMap::print(const GChatter& chatter) const |
| 830 | 830 | result.append("=== GModelSpatialDiffuseMap ==="); |
| 831 | 831 | |
| 832 | 832 | // Append parameters |
| 833 | - result.append("\n"+gammalib::parformat("Sky map file")+m_filename); | |
| 833 | + result.append("\n"+gammalib::parformat("Sky map file")); | |
| 834 | + result.append(m_filename.url()); | |
| 834 | 835 | result.append("\n"+gammalib::parformat("Map normalization")); |
| 835 | 836 | result.append(gammalib::str(m_mc_norm)+" ph/cm2/s"); |
| 836 | 837 | if (normalize()) { |
| ... | ... | @@ -861,7 +862,7 @@ std::string GModelSpatialDiffuseMap::print(const GChatter& chatter) const |
| 861 | 862 | * Loads skymap into the model class. The method calls the protected method |
| 862 | 863 | * prepare_map() that prepares the map for usage by the class. |
| 863 | 864 | ***************************************************************************/ |
| 864 | -void GModelSpatialDiffuseMap::load(const std::string& filename) | |
| 865 | +void GModelSpatialDiffuseMap::load(const GFilename& filename) | |
| 865 | 866 | { |
| 866 | 867 | // Initialise skymap |
| 867 | 868 | m_map.clear(); |
| ... | ... | @@ -873,7 +874,7 @@ void GModelSpatialDiffuseMap::load(const std::string& filename) |
| 873 | 874 | m_filename = filename; |
| 874 | 875 | |
| 875 | 876 | // Load skymap |
| 876 | - m_map.load(gammalib::expand_env(m_filename)); | |
| 877 | + m_map.load(m_filename.url()); | |
| 877 | 878 | |
| 878 | 879 | // Prepare sky map |
| 879 | 880 | prepare_map(); | ... | ... |
src/model/GModelSpectralFunc.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSpectralFunc.cpp - Spectral function model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -47,7 +47,7 @@ const GModelSpectralRegistry g_spectral_func_registry(&g_spectral_func_seed); |
| 47 | 47 | #define G_MC "GModelSpectralFunc::mc(GEnergy&, GEnergy&, GTime&, GRan&)" |
| 48 | 48 | #define G_READ "GModelSpectralFunc::read(GXmlElement&)" |
| 49 | 49 | #define G_WRITE "GModelSpectralFunc::write(GXmlElement&)" |
| 50 | -#define G_LOAD_NODES "GModelSpectralFunc::load_nodes(std::string&)" | |
| 50 | +#define G_LOAD_NODES "GModelSpectralFunc::load_nodes(GFilename&)" | |
| 51 | 51 | |
| 52 | 52 | /* __ Macros _____________________________________________________________ */ |
| 53 | 53 | |
| ... | ... | @@ -85,8 +85,8 @@ GModelSpectralFunc::GModelSpectralFunc(void) : GModelSpectral() |
| 85 | 85 | * in the specified ASCII file. See the load_nodes() method for more |
| 86 | 86 | * information about the expected structure of the file. |
| 87 | 87 | ***************************************************************************/ |
| 88 | -GModelSpectralFunc::GModelSpectralFunc(const std::string& filename, | |
| 89 | - const double& norm) : | |
| 88 | +GModelSpectralFunc::GModelSpectralFunc(const GFilename& filename, | |
| 89 | + const double& norm) : | |
| 90 | 90 | GModelSpectral() |
| 91 | 91 | { |
| 92 | 92 | // Initialise members |
| ... | ... | @@ -684,7 +684,7 @@ void GModelSpectralFunc::write(GXmlElement& xml) const |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | // Set file attribute |
| 687 | - xml.attribute("file", m_filename); | |
| 687 | + xml.attribute("file", m_filename.url()); | |
| 688 | 688 | |
| 689 | 689 | // Return |
| 690 | 690 | return; |
| ... | ... | @@ -709,7 +709,8 @@ std::string GModelSpectralFunc::print(const GChatter& chatter) const |
| 709 | 709 | result.append("=== GModelSpectralFunc ==="); |
| 710 | 710 | |
| 711 | 711 | // Append information |
| 712 | - result.append("\n"+gammalib::parformat("Function file")+m_filename); | |
| 712 | + result.append("\n"+gammalib::parformat("Function file")); | |
| 713 | + result.append(m_filename.url()); | |
| 713 | 714 | result.append("\n"+gammalib::parformat("Number of nodes")); |
| 714 | 715 | result.append(gammalib::str(m_lin_nodes.size())); |
| 715 | 716 | result.append("\n"+gammalib::parformat("Number of parameters")); |
| ... | ... | @@ -850,7 +851,7 @@ void GModelSpectralFunc::free_members(void) |
| 850 | 851 | * positive. Also, at least 2 nodes and 2 columns are required in the file |
| 851 | 852 | * function. |
| 852 | 853 | ***************************************************************************/ |
| 853 | -void GModelSpectralFunc::load_nodes(const std::string& filename) | |
| 854 | +void GModelSpectralFunc::load_nodes(const GFilename& filename) | |
| 854 | 855 | { |
| 855 | 856 | // Clear nodes and values |
| 856 | 857 | m_lin_nodes.clear(); |
| ... | ... | @@ -862,17 +863,17 @@ void GModelSpectralFunc::load_nodes(const std::string& filename) |
| 862 | 863 | m_filename = filename; |
| 863 | 864 | |
| 864 | 865 | // Load file |
| 865 | - GCsv csv = GCsv(filename); | |
| 866 | + GCsv csv = GCsv(filename.url()); | |
| 866 | 867 | |
| 867 | 868 | // Check if there are at least 2 nodes |
| 868 | 869 | if (csv.nrows() < 2) { |
| 869 | - throw GException::file_function_data(G_LOAD_NODES, filename, | |
| 870 | + throw GException::file_function_data(G_LOAD_NODES, filename.url(), | |
| 870 | 871 | csv.nrows()); |
| 871 | 872 | } |
| 872 | 873 | |
| 873 | 874 | // Check if there are at least 2 columns |
| 874 | 875 | if (csv.ncols() < 2) { |
| 875 | - throw GException::file_function_columns(G_LOAD_NODES, filename, | |
| 876 | + throw GException::file_function_columns(G_LOAD_NODES, filename.url(), | |
| 876 | 877 | csv.ncols()); |
| 877 | 878 | } |
| 878 | 879 | |
| ... | ... | @@ -887,20 +888,20 @@ void GModelSpectralFunc::load_nodes(const std::string& filename) |
| 887 | 888 | log10energy = std::log10(csv.real(i,0)); |
| 888 | 889 | } |
| 889 | 890 | else { |
| 890 | - throw GException::file_function_value(G_LOAD_NODES, filename, | |
| 891 | + throw GException::file_function_value(G_LOAD_NODES, filename.url(), | |
| 891 | 892 | csv.real(i,0), "Energy value must be positive."); |
| 892 | 893 | } |
| 893 | 894 | if (csv.real(i,1) > 0) { |
| 894 | 895 | log10value = std::log10(csv.real(i,1)); |
| 895 | 896 | } |
| 896 | 897 | else { |
| 897 | - throw GException::file_function_value(G_LOAD_NODES, filename, | |
| 898 | + throw GException::file_function_value(G_LOAD_NODES, filename.url(), | |
| 898 | 899 | csv.real(i,1), "Intensity value must be positive."); |
| 899 | 900 | } |
| 900 | 901 | |
| 901 | 902 | // Make sure that energies are increasing |
| 902 | 903 | if (csv.real(i,0) <= last_energy) { |
| 903 | - throw GException::file_function_value(G_LOAD_NODES, filename, | |
| 904 | + throw GException::file_function_value(G_LOAD_NODES, filename.url(), | |
| 904 | 905 | csv.real(i,0), "Energy values must be monotonically increasing."); |
| 905 | 906 | } |
| 906 | 907 | ... | ... |
src/model/GModels.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModels.cpp - Model container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | #endif |
| 31 | 31 | #include "GTools.hpp" |
| 32 | 32 | #include "GException.hpp" |
| 33 | +#include "GFilename.hpp" | |
| 33 | 34 | #include "GModels.hpp" |
| 34 | 35 | #include "GModel.hpp" |
| 35 | 36 | #include "GModelRegistry.hpp" |
| ... | ... | @@ -102,7 +103,7 @@ GModels::GModels(const GModels& models) |
| 102 | 103 | * Constructs model container from an XML file. See the read() method for |
| 103 | 104 | * more information about the expected structure of the XML file. |
| 104 | 105 | ***************************************************************************/ |
| 105 | -GModels::GModels(const std::string& filename) | |
| 106 | +GModels::GModels(const GFilename& filename) | |
| 106 | 107 | { |
| 107 | 108 | // Initialise members |
| 108 | 109 | init_members(); |
| ... | ... | @@ -662,13 +663,13 @@ bool GModels::contains(const std::string& name) const |
| 662 | 663 | * Loads all models from an XML file. See the read() method for more |
| 663 | 664 | * information about the expected structure of the XML file. |
| 664 | 665 | ***************************************************************************/ |
| 665 | -void GModels::load(const std::string& filename) | |
| 666 | +void GModels::load(const GFilename& filename) | |
| 666 | 667 | { |
| 667 | 668 | // Clear any existing models |
| 668 | 669 | clear(); |
| 669 | 670 | |
| 670 | 671 | // Load XML document |
| 671 | - GXml xml(filename); | |
| 672 | + GXml xml(filename.url()); | |
| 672 | 673 | |
| 673 | 674 | // Read models from XML document |
| 674 | 675 | read(xml); |
| ... | ... | @@ -685,7 +686,7 @@ void GModels::load(const std::string& filename) |
| 685 | 686 | * |
| 686 | 687 | * Saves all models in the container into an XML file. |
| 687 | 688 | ***************************************************************************/ |
| 688 | -void GModels::save(const std::string& filename) const | |
| 689 | +void GModels::save(const GFilename& filename) const | |
| 689 | 690 | { |
| 690 | 691 | // Declare empty XML document |
| 691 | 692 | GXml xml; | ... | ... |
src/obs/GEbounds.cpp
| ... | ... | @@ -578,11 +578,8 @@ void GEbounds::set_log(const int& num, const GEnergy& emin, const GEnergy& emax) |
| 578 | 578 | ***************************************************************************/ |
| 579 | 579 | void GEbounds::load(const GFilename& filename) |
| 580 | 580 | { |
| 581 | - // Allocate FITS file | |
| 582 | - GFits file; | |
| 583 | - | |
| 584 | 581 | // Open FITS file |
| 585 | - file.open(filename); | |
| 582 | + GFits file(filename); | |
| 586 | 583 | |
| 587 | 584 | // Get energy boundary table |
| 588 | 585 | const GFitsTable& table = *file.table(filename.extname("EBOUNDS")); |
| ... | ... | @@ -687,7 +684,7 @@ void GEbounds::read(const GFitsTable& table) |
| 687 | 684 | /***********************************************************************//** |
| 688 | 685 | * @brief Write energy boundaries into FITS object |
| 689 | 686 | * |
| 690 | - * @param[in] file FITS file. | |
| 687 | + * @param[in] fits FITS file. | |
| 691 | 688 | * @param[in] extname Energy boundary extension name (defaults to "EBOUNDS") |
| 692 | 689 | * @param[in] unit Energy units (defaults to "keV") |
| 693 | 690 | * |
| ... | ... | @@ -697,13 +694,13 @@ void GEbounds::read(const GFitsTable& table) |
| 697 | 694 | * |
| 698 | 695 | * @todo Write header keywords. |
| 699 | 696 | ***************************************************************************/ |
| 700 | -void GEbounds::write(GFits& file, | |
| 697 | +void GEbounds::write(GFits& fits, | |
| 701 | 698 | const std::string& extname, |
| 702 | 699 | const std::string& unit) const |
| 703 | 700 | { |
| 704 | 701 | // Create energy boundary columns |
| 705 | - GFitsTableDoubleCol cemin = GFitsTableDoubleCol("E_MIN", m_num); | |
| 706 | - GFitsTableDoubleCol cemax = GFitsTableDoubleCol("E_MAX", m_num); | |
| 702 | + GFitsTableDoubleCol cemin("E_MIN", m_num); | |
| 703 | + GFitsTableDoubleCol cemax("E_MAX", m_num); | |
| 707 | 704 | |
| 708 | 705 | // Fill energy boundary columns |
| 709 | 706 | for (int i = 0; i < m_num; ++i) { |
| ... | ... | @@ -716,16 +713,19 @@ void GEbounds::write(GFits& file, |
| 716 | 713 | cemax.unit(unit); |
| 717 | 714 | |
| 718 | 715 | // Create binary table |
| 719 | - GFitsBinTable* table = new GFitsBinTable(m_num); | |
| 720 | - table->append(cemin); | |
| 721 | - table->append(cemax); | |
| 722 | - table->extname(extname); | |
| 723 | - | |
| 724 | - // Write to FITS file | |
| 725 | - file.append(*table); | |
| 716 | + GFitsBinTable table(m_num); | |
| 717 | + table.append(cemin); | |
| 718 | + table.append(cemax); | |
| 719 | + table.extname(extname); | |
| 720 | + | |
| 721 | + // If the FITS object contains already an extension with the same | |
| 722 | + // name then remove now this extension | |
| 723 | + if (fits.contains(extname)) { | |
| 724 | + fits.remove(extname); | |
| 725 | + } | |
| 726 | 726 | |
| 727 | - // Free table | |
| 728 | - delete table; | |
| 727 | + // Append EBOUNDS table to FITS file | |
| 728 | + fits.append(table); | |
| 729 | 729 | |
| 730 | 730 | // Return |
| 731 | 731 | return; | ... | ... |
src/obs/GEnergies.cpp
| ... | ... | @@ -547,11 +547,8 @@ void GEnergies::set_log(const int& num, |
| 547 | 547 | ***************************************************************************/ |
| 548 | 548 | void GEnergies::load(const GFilename& filename) |
| 549 | 549 | { |
| 550 | - // Allocate FITS file | |
| 551 | - GFits file; | |
| 552 | - | |
| 553 | 550 | // Open FITS file |
| 554 | - file.open(filename); | |
| 551 | + GFits file(filename); | |
| 555 | 552 | |
| 556 | 553 | // Get energies table |
| 557 | 554 | const GFitsTable& table = *file.table(filename.extname("ENERGIES")); |
| ... | ... | @@ -644,18 +641,18 @@ void GEnergies::read(const GFitsTable& table) |
| 644 | 641 | /***********************************************************************//** |
| 645 | 642 | * @brief Write energies into FITS object |
| 646 | 643 | * |
| 647 | - * @param[in] file FITS file. | |
| 644 | + * @param[in] fits FITS file. | |
| 648 | 645 | * @param[in] extname Energy extension name (default: "ENERGIES") |
| 649 | 646 | * |
| 650 | 647 | * Writes energies into FITS object. |
| 651 | 648 | ***************************************************************************/ |
| 652 | -void GEnergies::write(GFits& file, const std::string& extname) const | |
| 649 | +void GEnergies::write(GFits& fits, const std::string& extname) const | |
| 653 | 650 | { |
| 654 | 651 | // Set number of energies |
| 655 | 652 | int num = m_energies.size(); |
| 656 | 653 | |
| 657 | 654 | // Create Energy column |
| 658 | - GFitsTableDoubleCol col_energy = GFitsTableDoubleCol("Energy", num); | |
| 655 | + GFitsTableDoubleCol col_energy("Energy", num); | |
| 659 | 656 | |
| 660 | 657 | // Fill energy column in units of MeV |
| 661 | 658 | for (int i = 0; i < num; ++i) { |
| ... | ... | @@ -664,15 +661,18 @@ void GEnergies::write(GFits& file, const std::string& extname) const |
| 664 | 661 | col_energy.unit("MeV"); |
| 665 | 662 | |
| 666 | 663 | // Create energies table |
| 667 | - GFitsBinTable* table = new GFitsBinTable(num); | |
| 668 | - table->append(col_energy); | |
| 669 | - table->extname(extname); | |
| 670 | - | |
| 671 | - // Write to FITS file | |
| 672 | - file.append(*table); | |
| 664 | + GFitsBinTable table(num); | |
| 665 | + table.append(col_energy); | |
| 666 | + table.extname(extname); | |
| 667 | + | |
| 668 | + // If the FITS object contains already an extension with the same | |
| 669 | + // name then remove now this extension | |
| 670 | + if (fits.contains(extname)) { | |
| 671 | + fits.remove(extname); | |
| 672 | + } | |
| 673 | 673 | |
| 674 | - // Free table | |
| 675 | - delete table; | |
| 674 | + // Append ENERGIES table to FITS file | |
| 675 | + fits.append(table); | |
| 676 | 676 | |
| 677 | 677 | // Return |
| 678 | 678 | return; | ... | ... |
src/obs/GGti.cpp
| ... | ... | @@ -584,11 +584,8 @@ void GGti::extend(const GGti& gti) |
| 584 | 584 | ***************************************************************************/ |
| 585 | 585 | void GGti::load(const GFilename& filename) |
| 586 | 586 | { |
| 587 | - // Allocate FITS file | |
| 588 | - GFits file; | |
| 589 | - | |
| 590 | 587 | // Open FITS file |
| 591 | - file.open(filename); | |
| 588 | + GFits file(filename); | |
| 592 | 589 | |
| 593 | 590 | // Get GTI table |
| 594 | 591 | const GFitsTable& table = *file.table(filename.extname("GTI")); |
| ... | ... | @@ -678,7 +675,7 @@ void GGti::read(const GFitsTable& table) |
| 678 | 675 | /***********************************************************************//** |
| 679 | 676 | * @brief Write Good Time Intervals and time reference into FITS object |
| 680 | 677 | * |
| 681 | - * @param[in] fits FITS object. | |
| 678 | + * @param[in] fits FITS file. | |
| 682 | 679 | * @param[in] extname GTI extension name (defaults to "GTI") |
| 683 | 680 | * |
| 684 | 681 | * Writes Good Time Intervals and time reference into a FITS object. If an |
| ... | ... | @@ -691,8 +688,8 @@ void GGti::read(const GFitsTable& table) |
| 691 | 688 | void GGti::write(GFits& fits, const std::string& extname) const |
| 692 | 689 | { |
| 693 | 690 | // Create GTI columns |
| 694 | - GFitsTableDoubleCol cstart = GFitsTableDoubleCol("START", m_num); | |
| 695 | - GFitsTableDoubleCol cstop = GFitsTableDoubleCol("STOP", m_num); | |
| 691 | + GFitsTableDoubleCol cstart("START", m_num); | |
| 692 | + GFitsTableDoubleCol cstop("STOP", m_num); | |
| 696 | 693 | |
| 697 | 694 | // Fill GTI columns in specified time reference |
| 698 | 695 | for (int i = 0; i < m_num; ++i) { |
| ... | ... | @@ -715,7 +712,7 @@ void GGti::write(GFits& fits, const std::string& extname) const |
| 715 | 712 | fits.remove(extname); |
| 716 | 713 | } |
| 717 | 714 | |
| 718 | - // Append GTI table to FITS object | |
| 715 | + // Append GTI table to FITS file | |
| 719 | 716 | fits.append(table); |
| 720 | 717 | |
| 721 | 718 | // Return | ... | ... |
src/obs/GObservations.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GObservations.cpp - Observation container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -30,9 +30,11 @@ |
| 30 | 30 | #endif |
| 31 | 31 | #include "GTools.hpp" |
| 32 | 32 | #include "GException.hpp" |
| 33 | +#include "GFilename.hpp" | |
| 33 | 34 | #include "GObservations.hpp" |
| 34 | 35 | #include "GObservationRegistry.hpp" |
| 35 | 36 | #include "GMatrixSparse.hpp" |
| 37 | +#include "GOptimizer.hpp" | |
| 36 | 38 | |
| 37 | 39 | /* __ Method name definitions ____________________________________________ */ |
| 38 | 40 | #define G_AT "GObservations::at(int&)" |
| ... | ... | @@ -96,7 +98,7 @@ GObservations::GObservations(const GObservations& obs) |
| 96 | 98 | * from a XML file. Please refer to the read() method for more information |
| 97 | 99 | * about the structure of the XML file. |
| 98 | 100 | ***************************************************************************/ |
| 99 | -GObservations::GObservations(const std::string& filename) | |
| 101 | +GObservations::GObservations(const GFilename& filename) | |
| 100 | 102 | { |
| 101 | 103 | // Initialise members |
| 102 | 104 | init_members(); |
| ... | ... | @@ -497,13 +499,13 @@ bool GObservations::contains(const std::string& instrument, |
| 497 | 499 | * Loads observation from a XML file into the container. Please refer to the |
| 498 | 500 | * read() method for more information about the structure of the XML file. |
| 499 | 501 | ***************************************************************************/ |
| 500 | -void GObservations::load(const std::string& filename) | |
| 502 | +void GObservations::load(const GFilename& filename) | |
| 501 | 503 | { |
| 502 | 504 | // Clear any existing observations |
| 503 | 505 | clear(); |
| 504 | 506 | |
| 505 | 507 | // Load XML document |
| 506 | - GXml xml(filename); | |
| 508 | + GXml xml(filename.url()); | |
| 507 | 509 | |
| 508 | 510 | // Read observations from XML document |
| 509 | 511 | read(xml); |
| ... | ... | @@ -521,7 +523,7 @@ void GObservations::load(const std::string& filename) |
| 521 | 523 | * Saves observations into a XML file. Please refer to the read() method for |
| 522 | 524 | * more information about the structure of the XML file. |
| 523 | 525 | ***************************************************************************/ |
| 524 | -void GObservations::save(const std::string& filename) const | |
| 526 | +void GObservations::save(const GFilename& filename) const | |
| 525 | 527 | { |
| 526 | 528 | // Declare empty XML document |
| 527 | 529 | GXml xml; |
| ... | ... | @@ -691,7 +693,7 @@ void GObservations::write(GXml& xml) const |
| 691 | 693 | * method for more information about the expected structure of the XML |
| 692 | 694 | * file. |
| 693 | 695 | ***************************************************************************/ |
| 694 | -void GObservations::models(const std::string& filename) | |
| 696 | +void GObservations::models(const GFilename& filename) | |
| 695 | 697 | { |
| 696 | 698 | // Load models |
| 697 | 699 | m_models.load(filename); | ... | ... |
src/sky/GSkyRegions.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GSkyRegions.cpp - Sky region container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013-2015 by Pierrick Martin * | |
| 4 | + * copyright (C) 2013-2016 by Pierrick Martin * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -30,10 +30,11 @@ |
| 30 | 30 | #include <fstream> |
| 31 | 31 | #endif |
| 32 | 32 | #include "GBase.hpp" |
| 33 | +#include "GTools.hpp" | |
| 34 | +#include "GSkyDir.hpp" | |
| 33 | 35 | #include "GSkyRegion.hpp" |
| 34 | 36 | #include "GSkyRegionCircle.hpp" |
| 35 | 37 | #include "GSkyRegions.hpp" |
| 36 | -#include "GTools.hpp" | |
| 37 | 38 | |
| 38 | 39 | /* __ Method name definitions ____________________________________________ */ |
| 39 | 40 | #define G_ACCESS "GSkyRegions::operator[](std::string&)" |
| ... | ... | @@ -46,8 +47,8 @@ |
| 46 | 47 | #define G_REMOVE1 "GSkyRegions::remove(int&)" |
| 47 | 48 | #define G_REMOVE2 "GSkyRegions::remove(std::string&)" |
| 48 | 49 | #define G_EXTEND "GSkyRegions::extend(GSkyRegions&)" |
| 49 | -#define G_LOAD "GSkyRegions::load(std::string&)" | |
| 50 | -#define G_SAVE "GSkyRegions::save(std::string&)" | |
| 50 | +#define G_LOAD "GSkyRegions::load(GFilename&)" | |
| 51 | +#define G_SAVE "GSkyRegions::save(GFilename&)" | |
| 51 | 52 | |
| 52 | 53 | /* __ Macros _____________________________________________________________ */ |
| 53 | 54 | |
| ... | ... | @@ -100,7 +101,7 @@ GSkyRegions::GSkyRegions(const GSkyRegions& regions) |
| 100 | 101 | * |
| 101 | 102 | * Constructs region container from a DS9 region file. |
| 102 | 103 | ***************************************************************************/ |
| 103 | -GSkyRegions::GSkyRegions(const std::string& filename) | |
| 104 | +GSkyRegions::GSkyRegions(const GFilename& filename) | |
| 104 | 105 | { |
| 105 | 106 | // Initialise members |
| 106 | 107 | init_members(); |
| ... | ... | @@ -416,14 +417,14 @@ void GSkyRegions::extend(const GSkyRegions& regions) |
| 416 | 417 | * |
| 417 | 418 | * Loads all regions from a DS9 region file. |
| 418 | 419 | ***************************************************************************/ |
| 419 | -void GSkyRegions::load(const std::string& filename) | |
| 420 | +void GSkyRegions::load(const GFilename& filename) | |
| 420 | 421 | { |
| 421 | 422 | // Clear any existing regions |
| 422 | 423 | clear(); |
| 423 | 424 | |
| 424 | 425 | // Open file. Throw an exception if opening failed. |
| 425 | 426 | std::ifstream ds9file; |
| 426 | - ds9file.open(filename.c_str()); | |
| 427 | + ds9file.open(filename.url().c_str()); | |
| 427 | 428 | if (ds9file.is_open()) { |
| 428 | 429 | |
| 429 | 430 | // Loop over file lines |
| ... | ... | @@ -482,7 +483,7 @@ void GSkyRegions::load(const std::string& filename) |
| 482 | 483 | |
| 483 | 484 | // File could not be opened |
| 484 | 485 | else { |
| 485 | - throw GException::file_open_error(G_LOAD, filename); | |
| 486 | + throw GException::file_open_error(G_LOAD, filename.url()); | |
| 486 | 487 | } |
| 487 | 488 | |
| 488 | 489 | // Return |
| ... | ... | @@ -500,11 +501,11 @@ void GSkyRegions::load(const std::string& filename) |
| 500 | 501 | * |
| 501 | 502 | * Saves all regions in the container into a DS9 region file. |
| 502 | 503 | ***************************************************************************/ |
| 503 | -void GSkyRegions::save(const std::string& filename) const | |
| 504 | +void GSkyRegions::save(const GFilename& filename) const | |
| 504 | 505 | { |
| 505 | 506 | // Open file |
| 506 | 507 | std::ofstream ds9file; |
| 507 | - ds9file.open(filename.c_str()); | |
| 508 | + ds9file.open(filename.url().c_str()); | |
| 508 | 509 | |
| 509 | 510 | // If file opened correctly, then save regions |
| 510 | 511 | if (ds9file.is_open()) { |
| ... | ... | @@ -533,7 +534,7 @@ void GSkyRegions::save(const std::string& filename) const |
| 533 | 534 | |
| 534 | 535 | // ... otherwise, if file could not be opened then throw an exception |
| 535 | 536 | else { |
| 536 | - throw GException::file_open_error(G_SAVE, filename); | |
| 537 | + throw GException::file_open_error(G_SAVE, filename.url()); | |
| 537 | 538 | } |
| 538 | 539 | |
| 539 | 540 | // Return | ... | ... |
src/support/GNodeArray.cpp
| ... | ... | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include "GException.hpp" |
| 34 | 34 | #include "GFilename.hpp" |
| 35 | 35 | #include "GNodeArray.hpp" |
| 36 | +#include "GVector.hpp" | |
| 36 | 37 | #include "GFits.hpp" |
| 37 | 38 | #include "GFitsTable.hpp" |
| 38 | 39 | #include "GFitsBinTable.hpp" |
| ... | ... | @@ -82,7 +83,7 @@ GNodeArray::GNodeArray(void) |
| 82 | 83 | * |
| 83 | 84 | * Constructs node array from a FITS file. |
| 84 | 85 | ***************************************************************************/ |
| 85 | -GNodeArray::GNodeArray(const std::string& filename) | |
| 86 | +GNodeArray::GNodeArray(const GFilename& filename) | |
| 86 | 87 | { |
| 87 | 88 | // Initialise members |
| 88 | 89 | init_members(); |
| ... | ... | @@ -700,25 +701,19 @@ void GNodeArray::set_value(const double& value) const |
| 700 | 701 | * If no extension name is provided, the node array is loaded from the |
| 701 | 702 | * "NODES" extension. |
| 702 | 703 | ***************************************************************************/ |
| 703 | -void GNodeArray::load(const std::string& filename) | |
| 704 | +void GNodeArray::load(const GFilename& filename) | |
| 704 | 705 | { |
| 705 | - // Create file name | |
| 706 | - GFilename fname(filename); | |
| 707 | - | |
| 708 | - // Allocate FITS file | |
| 709 | - GFits file; | |
| 710 | - | |
| 711 | 706 | // Open FITS file |
| 712 | - file.open(fname.url()); | |
| 707 | + GFits fits(filename); | |
| 713 | 708 | |
| 714 | 709 | // Get nodes table |
| 715 | - const GFitsTable& table = *file.table(fname.extname("NODES")); | |
| 710 | + const GFitsTable& table = *fits.table(filename.extname("NODES")); | |
| 716 | 711 | |
| 717 | 712 | // Read nodes from table |
| 718 | 713 | read(table); |
| 719 | 714 | |
| 720 | 715 | // Close FITS file |
| 721 | - file.close(); | |
| 716 | + fits.close(); | |
| 722 | 717 | |
| 723 | 718 | // Return |
| 724 | 719 | return; |
| ... | ... | @@ -729,26 +724,27 @@ void GNodeArray::load(const std::string& filename) |
| 729 | 724 | * @brief Save nodes to FITS file |
| 730 | 725 | * |
| 731 | 726 | * @param[in] filename FITS filename. |
| 732 | - * @param[in] clobber Overwrite any existing nodes extension? | |
| 727 | + * @param[in] clobber Overwrite any existing nodes extension? (default: false) | |
| 733 | 728 | * |
| 734 | - * Saves node array into a FITS file. | |
| 729 | + * Saves node array into a FITS file. If a file with the given @p filename | |
| 730 | + * does not yet exist it will be created, otherwise the method opens the | |
| 731 | + * existing file. The method will create (or replace an existing) node array | |
| 732 | + * extension. The extension name can be specified as part of the @p filename, | |
| 733 | + * or if no extension name is given, is assumed to be "NODES". | |
| 735 | 734 | * |
| 736 | - * If no extension name is provided, the node array is saved into a | |
| 737 | - * "NODES" extension. | |
| 735 | + * An existing file will only be modified if the @p clobber flag is set to | |
| 736 | + * true. | |
| 738 | 737 | ***************************************************************************/ |
| 739 | -void GNodeArray::save(const std::string& filename, const bool& clobber) const | |
| 738 | +void GNodeArray::save(const GFilename& filename, const bool& clobber) const | |
| 740 | 739 | { |
| 741 | - // Create file name | |
| 742 | - GFilename fname(filename); | |
| 740 | + // Open or create FITS file | |
| 741 | + GFits fits(filename, true); | |
| 743 | 742 | |
| 744 | - // Allocate FITS file | |
| 745 | - GFits file; | |
| 746 | - | |
| 747 | - // Write nodes to FITS file | |
| 748 | - write(file, fname.extname("NODES")); | |
| 743 | + // Write GTI to FITS object | |
| 744 | + write(fits, filename.extname("NODES")); | |
| 749 | 745 | |
| 750 | 746 | // Save to file |
| 751 | - file.saveto(fname.url(), clobber); | |
| 747 | + fits.save(clobber); | |
| 752 | 748 | |
| 753 | 749 | // Return |
| 754 | 750 | return; |
| ... | ... | @@ -794,18 +790,18 @@ void GNodeArray::read(const GFitsTable& table) |
| 794 | 790 | /***********************************************************************//** |
| 795 | 791 | * @brief Write nodes into FITS object |
| 796 | 792 | * |
| 797 | - * @param[in] file FITS file. | |
| 793 | + * @param[in] fits FITS file. | |
| 798 | 794 | * @param[in] extname Nodes extension name (defaults to "NODES") |
| 799 | 795 | * |
| 800 | 796 | * Writes nodes into FITS object. |
| 801 | 797 | ***************************************************************************/ |
| 802 | -void GNodeArray::write(GFits& file, const std::string& extname) const | |
| 798 | +void GNodeArray::write(GFits& fits, const std::string& extname) const | |
| 803 | 799 | { |
| 804 | 800 | // Set number of nodes |
| 805 | 801 | int num = m_node.size(); |
| 806 | 802 | |
| 807 | 803 | // Create node column |
| 808 | - GFitsTableDoubleCol col_nodes = GFitsTableDoubleCol("Value", num); | |
| 804 | + GFitsTableDoubleCol col_nodes("Value", num); | |
| 809 | 805 | |
| 810 | 806 | // Fill node column |
| 811 | 807 | for (int i = 0; i < num; ++i) { |
| ... | ... | @@ -813,15 +809,18 @@ void GNodeArray::write(GFits& file, const std::string& extname) const |
| 813 | 809 | } |
| 814 | 810 | |
| 815 | 811 | // Create nodes table |
| 816 | - GFitsBinTable* table = new GFitsBinTable(num); | |
| 817 | - table->append(col_nodes); | |
| 818 | - table->extname(extname); | |
| 819 | - | |
| 820 | - // Write to FITS file | |
| 821 | - file.append(*table); | |
| 812 | + GFitsBinTable table(num); | |
| 813 | + table.append(col_nodes); | |
| 814 | + table.extname(extname); | |
| 815 | + | |
| 816 | + // If the FITS object contains already an extension with the same | |
| 817 | + // name then remove now this extension | |
| 818 | + if (fits.contains(extname)) { | |
| 819 | + fits.remove(extname); | |
| 820 | + } | |
| 822 | 821 | |
| 823 | - // Free table | |
| 824 | - delete table; | |
| 822 | + // Append NODES table to FITS file | |
| 823 | + fits.append(table); | |
| 825 | 824 | |
| 826 | 825 | // Return |
| 827 | 826 | return; | ... | ... |
src/test/GTestSuites.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GTestSuites.cpp - Test suite container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2013 by Jean-Baptiste Cayrou * | |
| 4 | + * copyright (C) 2012-2016 by Jean-Baptiste Cayrou * | |
| 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 <ctime> |
| 32 | +#include "GTools.hpp" | |
| 33 | +#include "GXml.hpp" | |
| 32 | 34 | #include "GTestSuites.hpp" |
| 33 | 35 | #include "GTestCase.hpp" |
| 34 | -#include "GTools.hpp" | |
| 35 | 36 | |
| 36 | 37 | /* __ Method name definitions ____________________________________________ */ |
| 37 | 38 | #define G_AT "GTestSuites::at(int&)" |
| ... | ... | @@ -474,7 +475,7 @@ bool GTestSuites::run(void) |
| 474 | 475 | * |
| 475 | 476 | * Saves the test results in a JUnit compliant format into an XML file. |
| 476 | 477 | ***************************************************************************/ |
| 477 | -void GTestSuites::save(const std::string& filename) const | |
| 478 | +void GTestSuites::save(const GFilename& filename) const | |
| 478 | 479 | { |
| 479 | 480 | // Declare empty XML document |
| 480 | 481 | GXml xml; | ... | ... |
src/xml/GXml.cpp
| ... | ... | @@ -28,6 +28,9 @@ |
| 28 | 28 | #ifdef HAVE_CONFIG_H |
| 29 | 29 | #include <config.h> |
| 30 | 30 | #endif |
| 31 | +#include "GTools.hpp" | |
| 32 | +#include "GException.hpp" | |
| 33 | +#include "GFilename.hpp" | |
| 31 | 34 | #include "GUrlFile.hpp" |
| 32 | 35 | #include "GUrlString.hpp" |
| 33 | 36 | #include "GXml.hpp" |
| ... | ... | @@ -37,8 +40,6 @@ |
| 37 | 40 | #include "GXmlElement.hpp" |
| 38 | 41 | #include "GXmlComment.hpp" |
| 39 | 42 | #include "GXmlPI.hpp" |
| 40 | -#include "GException.hpp" | |
| 41 | -#include "GTools.hpp" | |
| 42 | 43 | |
| 43 | 44 | /* __ Method name definitions ____________________________________________ */ |
| 44 | 45 | #define G_LOAD "GXml::load(std::string&)" |
| ... | ... | @@ -515,18 +516,15 @@ const GXmlElement* GXml::element(const std::string& name, const int& index) cons |
| 515 | 516 | * @todo Ideally, we would like to extract the URL type from the filename |
| 516 | 517 | * so that any kind of URL can be used for loading. |
| 517 | 518 | ***************************************************************************/ |
| 518 | -void GXml::load(const std::string& filename) | |
| 519 | +void GXml::load(const GFilename& filename) | |
| 519 | 520 | { |
| 520 | - // Expand environment variables | |
| 521 | - std::string fname = gammalib::expand_env(filename); | |
| 522 | - | |
| 523 | 521 | // Check if file exists |
| 524 | - if (!gammalib::file_exists(fname)) { | |
| 525 | - throw GException::file_open_error(G_LOAD, fname); | |
| 522 | + if (!gammalib::file_exists(filename.url())) { | |
| 523 | + throw GException::file_open_error(G_LOAD, filename.url()); | |
| 526 | 524 | } |
| 527 | 525 | |
| 528 | 526 | // Open XML URL as file for reading |
| 529 | - GUrlFile url(fname.c_str(), "r"); | |
| 527 | + GUrlFile url(filename.url().c_str(), "r"); | |
| 530 | 528 | |
| 531 | 529 | // Read XML document from URL |
| 532 | 530 | read(url); |
| ... | ... | @@ -554,10 +552,10 @@ void GXml::load(const std::string& filename) |
| 554 | 552 | * @todo Ideally, we would like to extract the URL type from the filename |
| 555 | 553 | * so that any kind of URL can be used for loading. |
| 556 | 554 | ***************************************************************************/ |
| 557 | -void GXml::save(const std::string& filename) | |
| 555 | +void GXml::save(const GFilename& filename) | |
| 558 | 556 | { |
| 559 | 557 | // Open XML file for writing |
| 560 | - GUrlFile url(filename.c_str(), "w"); | |
| 558 | + GUrlFile url(filename.url().c_str(), "w"); | |
| 561 | 559 | |
| 562 | 560 | // Write XML document |
| 563 | 561 | write(url, 0); | ... | ... |
src/xspec/GPha.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GPha.cpp - XSPEC Pulse Height Analyzer class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -31,6 +31,9 @@ |
| 31 | 31 | #include "GPha.hpp" |
| 32 | 32 | #include "GException.hpp" |
| 33 | 33 | #include "GTools.hpp" |
| 34 | +#include "GEnergy.hpp" | |
| 35 | +#include "GFits.hpp" | |
| 36 | +#include "GFitsTable.hpp" | |
| 34 | 37 | #include "GFitsBinTable.hpp" |
| 35 | 38 | #include "GFitsTableShortCol.hpp" |
| 36 | 39 | #include "GFitsTableFloatCol.hpp" |
| ... | ... | @@ -70,7 +73,7 @@ GPha::GPha(void) |
| 70 | 73 | * |
| 71 | 74 | * @param[in] filename File name. |
| 72 | 75 | ***************************************************************************/ |
| 73 | -GPha::GPha(const std::string& filename) | |
| 76 | +GPha::GPha(const GFilename& filename) | |
| 74 | 77 | { |
| 75 | 78 | // Initialise members |
| 76 | 79 | init_members(); |
| ... | ... | @@ -330,7 +333,7 @@ void GPha::fill(const GEnergy& energy, const double& value) |
| 330 | 333 | * Loads the Pulse Height Analyzer spectrum from a FITS file. If an EBOUNDS |
| 331 | 334 | * extension is given, the energy boundaries information is also loaded |
| 332 | 335 | ***************************************************************************/ |
| 333 | -void GPha::load(const std::string& filename) | |
| 336 | +void GPha::load(const GFilename& filename) | |
| 334 | 337 | { |
| 335 | 338 | // Clear any existing models |
| 336 | 339 | clear(); |
| ... | ... | @@ -372,7 +375,7 @@ void GPha::load(const std::string& filename) |
| 372 | 375 | * @param[in] filename File name. |
| 373 | 376 | * @param[in] clobber Overwrite existing file? (defaults to true) |
| 374 | 377 | ***************************************************************************/ |
| 375 | -void GPha::save(const std::string& filename, const bool& clobber) const | |
| 378 | +void GPha::save(const GFilename& filename, const bool& clobber) const | |
| 376 | 379 | { |
| 377 | 380 | // Open FITS file |
| 378 | 381 | GFits fits; |
| ... | ... | @@ -447,7 +450,7 @@ void GPha::write(GFits& fits) const |
| 447 | 450 | if (length > 0) { |
| 448 | 451 | |
| 449 | 452 | // Create new binary table |
| 450 | - GFitsBinTable* hdu = new GFitsBinTable; | |
| 453 | + GFitsBinTable hdu; | |
| 451 | 454 | |
| 452 | 455 | // Allocate floating point vector columns |
| 453 | 456 | GFitsTableShortCol col_chan("CHANNEL", length); |
| ... | ... | @@ -466,23 +469,20 @@ void GPha::write(GFits& fits) const |
| 466 | 469 | } |
| 467 | 470 | |
| 468 | 471 | // Set table attributes |
| 469 | - hdu->extname("SPECTRUM"); | |
| 472 | + hdu.extname("SPECTRUM"); | |
| 470 | 473 | |
| 471 | 474 | // Append columns to table |
| 472 | - hdu->append(col_chan); | |
| 473 | - hdu->append(col_data); | |
| 474 | - hdu->append(col_stat); | |
| 475 | - hdu->append(col_syst); | |
| 476 | - hdu->append(col_qual); | |
| 477 | - hdu->append(col_grpg); | |
| 478 | - hdu->append(col_area); | |
| 479 | - hdu->append(col_back); | |
| 475 | + hdu.append(col_chan); | |
| 476 | + hdu.append(col_data); | |
| 477 | + hdu.append(col_stat); | |
| 478 | + hdu.append(col_syst); | |
| 479 | + hdu.append(col_qual); | |
| 480 | + hdu.append(col_grpg); | |
| 481 | + hdu.append(col_area); | |
| 482 | + hdu.append(col_back); | |
| 480 | 483 | |
| 481 | 484 | // Append HDU to FITS file |
| 482 | - fits.append(*hdu); | |
| 483 | - | |
| 484 | - // Free binary table | |
| 485 | - delete hdu; | |
| 485 | + fits.append(hdu); | |
| 486 | 486 | |
| 487 | 487 | // Optionally append energy boundaries |
| 488 | 488 | if (m_ebounds.size() > 0) { | ... | ... |
src/xspec/GRmf.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GRmf.cpp - XSPEC Redistribution Matrix File class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -32,6 +32,8 @@ |
| 32 | 32 | #include "GMath.hpp" |
| 33 | 33 | #include "GRmf.hpp" |
| 34 | 34 | #include "GException.hpp" |
| 35 | +#include "GFits.hpp" | |
| 36 | +#include "GFitsTable.hpp" | |
| 35 | 37 | #include "GFitsBinTable.hpp" |
| 36 | 38 | #include "GFitsTableShortCol.hpp" |
| 37 | 39 | #include "GFitsTableFloatCol.hpp" |
| ... | ... | @@ -70,7 +72,7 @@ GRmf::GRmf(void) |
| 70 | 72 | * |
| 71 | 73 | * @param[in] filename File name. |
| 72 | 74 | ***************************************************************************/ |
| 73 | -GRmf::GRmf(const std::string& filename) | |
| 75 | +GRmf::GRmf(const GFilename& filename) | |
| 74 | 76 | { |
| 75 | 77 | // Initialise members |
| 76 | 78 | init_members(); |
| ... | ... | @@ -368,7 +370,7 @@ GEbounds GRmf::emeasured(const GEnergy& etrue) const |
| 368 | 370 | * |
| 369 | 371 | * @param[in] filename File name. |
| 370 | 372 | ***************************************************************************/ |
| 371 | -void GRmf::load(const std::string& filename) | |
| 373 | +void GRmf::load(const GFilename& filename) | |
| 372 | 374 | { |
| 373 | 375 | // Clear any existing models |
| 374 | 376 | clear(); |
| ... | ... | @@ -380,7 +382,7 @@ void GRmf::load(const std::string& filename) |
| 380 | 382 | m_ebds_measured.load(filename); |
| 381 | 383 | |
| 382 | 384 | // Get RMF table |
| 383 | - const GFitsTable& table = *file.table("MATRIX"); | |
| 385 | + const GFitsTable& table = *file.table(filename.extname("MATRIX")); | |
| 384 | 386 | |
| 385 | 387 | // Read RMF data |
| 386 | 388 | read(table); |
| ... | ... | @@ -400,21 +402,21 @@ void GRmf::load(const std::string& filename) |
| 400 | 402 | * @brief Save Redistribution Matrix File |
| 401 | 403 | * |
| 402 | 404 | * @param[in] filename File name. |
| 403 | - * @param[in] clobber Overwrite existing file? (defaults to true) | |
| 404 | - * @param[in] unit Energy unit (defaults to "keV") | |
| 405 | + * @param[in] clobber Overwrite existing file? (default: false) | |
| 406 | + * @param[in] unit Energy unit (default: "keV") | |
| 405 | 407 | ***************************************************************************/ |
| 406 | -void GRmf::save(const std::string& filename, | |
| 408 | +void GRmf::save(const GFilename& filename, | |
| 407 | 409 | const bool& clobber, |
| 408 | 410 | const std::string& unit) const |
| 409 | 411 | { |
| 410 | - // Open FITS file | |
| 411 | - GFits fits; | |
| 412 | + // Open or create FITS file | |
| 413 | + GFits fits(filename, true); | |
| 412 | 414 | |
| 413 | 415 | // Write RMF into file |
| 414 | 416 | write(fits, unit); |
| 415 | 417 | |
| 416 | - // Close FITS file | |
| 417 | - fits.saveto(filename, clobber); | |
| 418 | + // Save to file | |
| 419 | + fits.save(clobber); | |
| 418 | 420 | |
| 419 | 421 | // Store filename |
| 420 | 422 | m_filename = filename; |
| ... | ... | @@ -449,8 +451,8 @@ void GRmf::read(const GFitsTable& table) |
| 449 | 451 | // Initialize matrix |
| 450 | 452 | m_matrix = GMatrixSparse(rows, columns); |
| 451 | 453 | |
| 452 | - // Initialize matrix maximum | |
| 453 | - double max = 0.0; | |
| 454 | + // Initialize matrix maximum | |
| 455 | + double max = 0.0; | |
| 454 | 456 | |
| 455 | 457 | // Set true energy bins |
| 456 | 458 | for (int itrue = 0; itrue < rows; ++itrue) { |
| ... | ... | @@ -536,7 +538,7 @@ void GRmf::write(GFits& fits, const std::string& unit) const |
| 536 | 538 | } // endfor: looped over true energies |
| 537 | 539 | |
| 538 | 540 | // Create new binary table |
| 539 | - GFitsBinTable* hdu = new GFitsBinTable; | |
| 541 | + GFitsBinTable hdu; | |
| 540 | 542 | |
| 541 | 543 | // Allocate columns |
| 542 | 544 | GFitsTableFloatCol energy_lo("ENERG_LO", length); |
| ... | ... | @@ -593,21 +595,18 @@ void GRmf::write(GFits& fits, const std::string& unit) const |
| 593 | 595 | energy_hi.unit(unit); |
| 594 | 596 | |
| 595 | 597 | // Set table attributes |
| 596 | - hdu->extname("MATRIX"); | |
| 598 | + hdu.extname("MATRIX"); | |
| 597 | 599 | |
| 598 | 600 | // Append columns to table |
| 599 | - hdu->append(energy_lo); | |
| 600 | - hdu->append(energy_hi); | |
| 601 | - hdu->append(n_grp); | |
| 602 | - hdu->append(f_chan); | |
| 603 | - hdu->append(n_chan); | |
| 604 | - hdu->append(matrix); | |
| 601 | + hdu.append(energy_lo); | |
| 602 | + hdu.append(energy_hi); | |
| 603 | + hdu.append(n_grp); | |
| 604 | + hdu.append(f_chan); | |
| 605 | + hdu.append(n_chan); | |
| 606 | + hdu.append(matrix); | |
| 605 | 607 | |
| 606 | 608 | // Append HDU to FITS file |
| 607 | - fits.append(*hdu); | |
| 608 | - | |
| 609 | - // Free binary table | |
| 610 | - delete hdu; | |
| 609 | + fits.append(hdu); | |
| 611 | 610 | |
| 612 | 611 | // Append measured energy boundaries |
| 613 | 612 | m_ebds_measured.write(fits); | ... | ... |
test/test_GModel.cpp
| ... | ... | @@ -681,8 +681,9 @@ void TestGModel::test_diffuse_map(void) |
| 681 | 681 | try { |
| 682 | 682 | GModelSpatialDiffuseMap model; |
| 683 | 683 | test_assert(model.type() == "SpatialMap", |
| 684 | - "Model type \"SpatialMap\" expected."); | |
| 685 | - test_assert(model.filename() == "", "Model filename \"\" expected."); | |
| 684 | + "Model type \"SpatialMap\" expected."); | |
| 685 | + test_assert(model.filename().url() == "", | |
| 686 | + "Model filename \"\" expected."); | |
| 686 | 687 | test_try_success(); |
| 687 | 688 | } |
| 688 | 689 | catch (std::exception &e) { |
| ... | ... | @@ -694,7 +695,8 @@ void TestGModel::test_diffuse_map(void) |
| 694 | 695 | try { |
| 695 | 696 | GModelSpatialDiffuseMap model(m_map_file, 3.0); |
| 696 | 697 | test_value(model.value(), 3.0); |
| 697 | - test_assert(model.filename() == m_map_file, "Expected \""+m_map_file+"\""); | |
| 698 | + test_assert(model.filename().url() == m_map_file, | |
| 699 | + "Expected \""+m_map_file+"\""); | |
| 698 | 700 | test_try_success(); |
| 699 | 701 | } |
| 700 | 702 | catch (std::exception &e) { |
| ... | ... | @@ -707,7 +709,7 @@ void TestGModel::test_diffuse_map(void) |
| 707 | 709 | GSkyMap map("GAL", 16, "RING", 10); |
| 708 | 710 | GModelSpatialDiffuseMap model(map, 3.0); |
| 709 | 711 | test_value(model.value(), 3.0); |
| 710 | - test_assert(model.filename() == "", "Expected \"\""); | |
| 712 | + test_assert(model.filename().url() == "", "Expected \"\""); | |
| 711 | 713 | test_try_success(); |
| 712 | 714 | } |
| 713 | 715 | catch (std::exception &e) { |
| ... | ... | @@ -724,8 +726,8 @@ void TestGModel::test_diffuse_map(void) |
| 724 | 726 | test_value(model.size(), 1); |
| 725 | 727 | test_assert(model.type() == "SpatialMap", "Expected \"SpatialMap\""); |
| 726 | 728 | test_value(model.value(), 1.0); |
| 727 | - test_assert(model.filename() == m_map_file, | |
| 728 | - "Model filename \""+m_map_file+"\" expected."); | |
| 729 | + test_assert(model.filename().url() == m_map_file, | |
| 730 | + "Model filename \""+m_map_file+"\" expected."); | |
| 729 | 731 | |
| 730 | 732 | // Test value method |
| 731 | 733 | model.value(3.9); |
| ... | ... | @@ -733,8 +735,8 @@ void TestGModel::test_diffuse_map(void) |
| 733 | 735 | |
| 734 | 736 | // Test load method |
| 735 | 737 | model.load(m_map_file); |
| 736 | - test_assert(model.filename() == m_map_file, | |
| 737 | - "Model filename \""+m_map_file+"\" expected."); | |
| 738 | + test_assert(model.filename().url() == m_map_file, | |
| 739 | + "Model filename \""+m_map_file+"\" expected."); | |
| 738 | 740 | |
| 739 | 741 | // Test map method |
| 740 | 742 | model.map(GSkyMap("GAL", 16, "RING", 10)); |
| ... | ... | @@ -2055,7 +2057,8 @@ void TestGModel::test_filefct(void) |
| 2055 | 2057 | test_try("Test value constructor"); |
| 2056 | 2058 | try { |
| 2057 | 2059 | GModelSpectralFunc model("data/filefunction.txt", 2.0); |
| 2058 | - test_assert(model.filename() == "data/filefunction.txt", "Expected \"data/filefunction.txt\""); | |
| 2060 | + test_assert(model.filename().url() == "data/filefunction.txt", | |
| 2061 | + "Expected \"data/filefunction.txt\""); | |
| 2059 | 2062 | test_value(model.norm(), 2.0); |
| 2060 | 2063 | test_try_success(); |
| 2061 | 2064 | } |
| ... | ... | @@ -2072,12 +2075,14 @@ void TestGModel::test_filefct(void) |
| 2072 | 2075 | GModelSpectralFunc model(*element); |
| 2073 | 2076 | test_value(model.size(), 1); |
| 2074 | 2077 | test_assert(model.type() == "FileFunction", "Expected \"FileFunction\""); |
| 2075 | - test_assert(model.filename() == "data/filefunction.txt", "Expected \"data/filefunction.txt\""); | |
| 2078 | + test_assert(model.filename().url() == "data/filefunction.txt", | |
| 2079 | + "Expected \"data/filefunction.txt\""); | |
| 2076 | 2080 | test_value(model.norm(), 1.0); |
| 2077 | 2081 | |
| 2078 | 2082 | // Test filename method |
| 2079 | 2083 | model.filename("data/filefunction.txt"); |
| 2080 | - test_assert(model.filename() == "data/filefunction.txt", "Expected \"data/filefunction.txt\""); | |
| 2084 | + test_assert(model.filename().url() == "data/filefunction.txt", | |
| 2085 | + "Expected \"data/filefunction.txt\""); | |
| 2081 | 2086 | |
| 2082 | 2087 | // Test norm method |
| 2083 | 2088 | model.norm(3.0); | ... | ... |
test/test_GXspec.cpp
| ... | ... | @@ -117,11 +117,11 @@ void TestGXspec::test_GPha(void) |
| 117 | 117 | |
| 118 | 118 | // Test saving and loading |
| 119 | 119 | pha.save("pha.fits", true); |
| 120 | - test_assert(pha.filename() == "pha.fits", | |
| 121 | - "Unexpected filename \""+pha.filename()+"\"."); | |
| 120 | + test_assert(pha.filename().url() == "pha.fits", | |
| 121 | + "Unexpected filename \""+pha.filename().url()+"\"."); | |
| 122 | 122 | pha.load("pha.fits"); |
| 123 | - test_assert(pha.filename() == "pha.fits", | |
| 124 | - "Unexpected filename \""+pha.filename()+"\"."); | |
| 123 | + test_assert(pha.filename().url() == "pha.fits", | |
| 124 | + "Unexpected filename \""+pha.filename().url()+"\"."); | |
| 125 | 125 | test_value(pha[0], 5.0, 1.0e-6); |
| 126 | 126 | test_value(pha[1], 3.7, 1.0e-6); |
| 127 | 127 | test_value(pha.counts(), 11.7, 1.0e-6); |
| ... | ... | @@ -139,8 +139,8 @@ void TestGXspec::test_GPha(void) |
| 139 | 139 | |
| 140 | 140 | // Test constructing |
| 141 | 141 | GPha pha2("pha.fits"); |
| 142 | - test_assert(pha2.filename() == "pha.fits", | |
| 143 | - "Unexpected filename \""+pha2.filename()+"\"."); | |
| 142 | + test_assert(pha2.filename().url() == "pha.fits", | |
| 143 | + "Unexpected filename \""+pha2.filename().url()+"\"."); | |
| 144 | 144 | test_value(pha2[0], 5.0, 1.0e-6); |
| 145 | 145 | test_value(pha2[1], 3.7, 1.0e-6); |
| 146 | 146 | test_value(pha2.counts(), 11.7, 1.0e-6); |
| ... | ... | @@ -310,11 +310,11 @@ void TestGXspec::test_GRmf(void) |
| 310 | 310 | |
| 311 | 311 | // Test saving and loading |
| 312 | 312 | rmf.save("rmf.fits", true); |
| 313 | - test_assert(rmf.filename() == "rmf.fits", | |
| 314 | - "Unexpected filename \""+rmf.filename()+"\"."); | |
| 313 | + test_assert(rmf.filename().url() == "rmf.fits", | |
| 314 | + "Unexpected filename \""+rmf.filename().url()+"\"."); | |
| 315 | 315 | rmf.load("rmf.fits"); |
| 316 | - test_assert(rmf.filename() == "rmf.fits", | |
| 317 | - "Unexpected filename \""+rmf.filename()+"\"."); | |
| 316 | + test_assert(rmf.filename().url() == "rmf.fits", | |
| 317 | + "Unexpected filename \""+rmf.filename().url()+"\"."); | |
| 318 | 318 | /* |
| 319 | 319 | for (int i = 0; i < 9; ++i) { |
| 320 | 320 | for (int k = 0; k < 9; ++k) { |
| ... | ... | @@ -341,8 +341,8 @@ void TestGXspec::test_GRmf(void) |
| 341 | 341 | |
| 342 | 342 | // Test constructing |
| 343 | 343 | GRmf rmf2("rmf.fits"); |
| 344 | - test_assert(rmf2.filename() == "rmf.fits", | |
| 345 | - "Unexpected filename \""+rmf2.filename()+"\"."); | |
| 344 | + test_assert(rmf2.filename().url() == "rmf.fits", | |
| 345 | + "Unexpected filename \""+rmf2.filename().url()+"\"."); | |
| 346 | 346 | for (int i = 0; i < 9; ++i) { |
| 347 | 347 | int k = 0; |
| 348 | 348 | for (; k < i; ++k) { | ... | ... |