Commit 124728fdc2b17fb847f0a3adc4d9fdffc63254bb
1 parent
45bcd2e8
Review CTA effective area classes.
GCTAAeff2D The read() method now takes a reference instead of a pointer. GCTAAeffArf Rename read_arf() to read(). read() now takes a reference as argument instead of a pointer.
Showing
14 changed files
with
373 additions
and
251 deletions
NEWS
| @@ -267,6 +267,13 @@ GWcsHPX => GHealpix | @@ -267,6 +267,13 @@ GWcsHPX => GHealpix | ||
| 267 | GWcsRegistry | 267 | GWcsRegistry |
| 268 | Now holds objects of renamed type GWcs (see GHealpix). | 268 | Now holds objects of renamed type GWcs (see GHealpix). |
| 269 | 269 | ||
| 270 | +GCTAAeff2D | ||
| 271 | + The read() method now takes a reference instead of a pointer. | ||
| 272 | + | ||
| 273 | +GCTAAeffArf | ||
| 274 | + Rename read_arf() to read(). read() now takes a reference as | ||
| 275 | + argument instead of a pointer. | ||
| 276 | + | ||
| 270 | All GammaLib constants, defined in GTools.hpp, and functions are now | 277 | All GammaLib constants, defined in GTools.hpp, and functions are now |
| 271 | put in the gammalib namespace to avoid name clashes. Mathematical | 278 | put in the gammalib namespace to avoid name clashes. Mathematical |
| 272 | constants and functions have been moved to a new model named GMath. | 279 | constants and functions have been moved to a new model named GMath. |
inst/cta/include/GCTAAeff2D.hpp
| @@ -47,7 +47,7 @@ class GCTAAeff2D : public GCTAAeff { | @@ -47,7 +47,7 @@ class GCTAAeff2D : public GCTAAeff { | ||
| 47 | public: | 47 | public: |
| 48 | // Constructors and destructors | 48 | // Constructors and destructors |
| 49 | GCTAAeff2D(void); | 49 | GCTAAeff2D(void); |
| 50 | - GCTAAeff2D(const std::string& filename); | 50 | + explicit GCTAAeff2D(const std::string& filename); |
| 51 | GCTAAeff2D(const GCTAAeff2D& cta); | 51 | GCTAAeff2D(const GCTAAeff2D& cta); |
| 52 | virtual ~GCTAAeff2D(void); | 52 | virtual ~GCTAAeff2D(void); |
| 53 | 53 | ||
| @@ -68,7 +68,7 @@ public: | @@ -68,7 +68,7 @@ public: | ||
| 68 | std::string print(const GChatter& chatter = NORMAL) const; | 68 | std::string print(const GChatter& chatter = NORMAL) const; |
| 69 | 69 | ||
| 70 | // Methods | 70 | // Methods |
| 71 | - void read(const GFits* file); | 71 | + void read(const GFits& file); |
| 72 | 72 | ||
| 73 | private: | 73 | private: |
| 74 | // Methods | 74 | // Methods |
inst/cta/include/GCTAAeffArf.hpp
| @@ -52,7 +52,7 @@ class GCTAAeffArf : public GCTAAeff { | @@ -52,7 +52,7 @@ class GCTAAeffArf : public GCTAAeff { | ||
| 52 | public: | 52 | public: |
| 53 | // Constructors and destructors | 53 | // Constructors and destructors |
| 54 | GCTAAeffArf(void); | 54 | GCTAAeffArf(void); |
| 55 | - GCTAAeffArf(const std::string& filename); | 55 | + explicit GCTAAeffArf(const std::string& filename); |
| 56 | GCTAAeffArf(const GCTAAeffArf& cta); | 56 | GCTAAeffArf(const GCTAAeffArf& cta); |
| 57 | virtual ~GCTAAeffArf(void); | 57 | virtual ~GCTAAeffArf(void); |
| 58 | 58 | ||
| @@ -73,14 +73,14 @@ public: | @@ -73,14 +73,14 @@ public: | ||
| 73 | std::string print(const GChatter& chatter = NORMAL) const; | 73 | std::string print(const GChatter& chatter = NORMAL) const; |
| 74 | 74 | ||
| 75 | // Methods | 75 | // Methods |
| 76 | - int size(void) const { return m_logE.size(); } | ||
| 77 | - void sigma(const double& sigma) { m_sigma=sigma; } | ||
| 78 | - const double& sigma(void) const { return m_sigma; } | ||
| 79 | - void thetacut(const double& thetacut) { m_thetacut=thetacut; } | ||
| 80 | - const double& thetacut(void) const { return m_thetacut; } | ||
| 81 | - void scale(const double& scale) { m_scale=scale; } | ||
| 82 | - const double& scale(void) const { return m_scale; } | ||
| 83 | - void read_arf(const GFitsTable* hdu); | 76 | + int size(void) const; |
| 77 | + void sigma(const double& sigma); | ||
| 78 | + const double& sigma(void) const; | ||
| 79 | + void thetacut(const double& thetacut); | ||
| 80 | + const double& thetacut(void) const; | ||
| 81 | + void scale(const double& scale); | ||
| 82 | + const double& scale(void) const; | ||
| 83 | + void read(const GFitsTable& hdu); | ||
| 84 | void remove_thetacut(const GCTAResponse& rsp); | 84 | void remove_thetacut(const GCTAResponse& rsp); |
| 85 | 85 | ||
| 86 | private: | 86 | private: |
| @@ -98,4 +98,113 @@ private: | @@ -98,4 +98,113 @@ private: | ||
| 98 | double m_scale; //!< Scale for ARF | 98 | double m_scale; //!< Scale for ARF |
| 99 | }; | 99 | }; |
| 100 | 100 | ||
| 101 | + | ||
| 102 | +/***********************************************************************//** | ||
| 103 | + * @brief Return filename | ||
| 104 | + * | ||
| 105 | + * @return Returns filename from which effective area was loaded. | ||
| 106 | + ***************************************************************************/ | ||
| 107 | +inline | ||
| 108 | +std::string GCTAAeffArf::filename(void) const | ||
| 109 | +{ | ||
| 110 | + return m_filename; | ||
| 111 | +} | ||
| 112 | + | ||
| 113 | + | ||
| 114 | +/***********************************************************************//** | ||
| 115 | + * @brief Return number of node energies in response | ||
| 116 | + * | ||
| 117 | + * @return Number of node energies. | ||
| 118 | + ***************************************************************************/ | ||
| 119 | +inline | ||
| 120 | +int GCTAAeffArf::size(void) const | ||
| 121 | +{ | ||
| 122 | + return (m_logE.size()); | ||
| 123 | +} | ||
| 124 | + | ||
| 125 | + | ||
| 126 | +/***********************************************************************//** | ||
| 127 | + * @brief Set sigma for offset angle dependence | ||
| 128 | + * | ||
| 129 | + * @param[in] sigma Sigma for offset angle dependence. | ||
| 130 | + * | ||
| 131 | + * Sets the sigma parameter for the offset angle dependence of the effective | ||
| 132 | + * area. If @p sigma is 0 (which is the default value), no offset angle | ||
| 133 | + * dependency will be assumed. | ||
| 134 | + ***************************************************************************/ | ||
| 135 | +inline | ||
| 136 | +void GCTAAeffArf::sigma(const double& sigma) | ||
| 137 | +{ | ||
| 138 | + m_sigma = sigma; | ||
| 139 | + return; | ||
| 140 | +} | ||
| 141 | + | ||
| 142 | + | ||
| 143 | +/***********************************************************************//** | ||
| 144 | + * @brief Return sigma for offset angle dependence | ||
| 145 | + * | ||
| 146 | + * @return Sigma for offset angle dependence. | ||
| 147 | + ***************************************************************************/ | ||
| 148 | +inline | ||
| 149 | +const double& GCTAAeffArf::sigma(void) const | ||
| 150 | +{ | ||
| 151 | + return (m_sigma); | ||
| 152 | +} | ||
| 153 | + | ||
| 154 | + | ||
| 155 | +/***********************************************************************//** | ||
| 156 | + * @brief Set theta cut angle | ||
| 157 | + * | ||
| 158 | + * @param[in] thetacut Set theta cut angle. | ||
| 159 | + * | ||
| 160 | + * Sets the theta cut angle which defines the energy independent cut that | ||
| 161 | + * has been assumed in deriving the ARF values. If @p thetacut os 0 (which | ||
| 162 | + * is the default avlue), not thetacut will be applied. | ||
| 163 | + ***************************************************************************/ | ||
| 164 | +inline | ||
| 165 | +void GCTAAeffArf::thetacut(const double& thetacut) | ||
| 166 | +{ | ||
| 167 | + m_thetacut = thetacut; | ||
| 168 | + return; | ||
| 169 | +} | ||
| 170 | + | ||
| 171 | + | ||
| 172 | +/***********************************************************************//** | ||
| 173 | + * @brief Return theta cut angle | ||
| 174 | + * | ||
| 175 | + * @return Theta cut angle. | ||
| 176 | + ***************************************************************************/ | ||
| 177 | +inline | ||
| 178 | +const double& GCTAAeffArf::thetacut(void) const | ||
| 179 | +{ | ||
| 180 | + return (m_thetacut); | ||
| 181 | +} | ||
| 182 | + | ||
| 183 | + | ||
| 184 | +/***********************************************************************//** | ||
| 185 | + * @brief Set effective area scaling factor | ||
| 186 | + * | ||
| 187 | + * @param[in] scale Set effective area scaling factor. | ||
| 188 | + * | ||
| 189 | + * Sets the scaling factor for the effective area (by default is 1). | ||
| 190 | + ***************************************************************************/ | ||
| 191 | +inline | ||
| 192 | +void GCTAAeffArf::scale(const double& scale) | ||
| 193 | +{ | ||
| 194 | + m_scale = scale; | ||
| 195 | + return; | ||
| 196 | +} | ||
| 197 | + | ||
| 198 | + | ||
| 199 | +/***********************************************************************//** | ||
| 200 | + * @brief Return effective area scaling factor | ||
| 201 | + * | ||
| 202 | + * @return Effective area scaling factor. | ||
| 203 | + ***************************************************************************/ | ||
| 204 | +inline | ||
| 205 | +const double& GCTAAeffArf::scale(void) const | ||
| 206 | +{ | ||
| 207 | + return (m_scale); | ||
| 208 | +} | ||
| 209 | + | ||
| 101 | #endif /* GCTAAEFFARF_HPP */ | 210 | #endif /* GCTAAEFFARF_HPP */ |
inst/cta/include/GCTAAeffPerfTable.hpp
| @@ -49,7 +49,7 @@ class GCTAAeffPerfTable : public GCTAAeff { | @@ -49,7 +49,7 @@ class GCTAAeffPerfTable : public GCTAAeff { | ||
| 49 | public: | 49 | public: |
| 50 | // Constructors and destructors | 50 | // Constructors and destructors |
| 51 | GCTAAeffPerfTable(void); | 51 | GCTAAeffPerfTable(void); |
| 52 | - GCTAAeffPerfTable(const std::string& filename); | 52 | + explicit GCTAAeffPerfTable(const std::string& filename); |
| 53 | GCTAAeffPerfTable(const GCTAAeffPerfTable& cta); | 53 | GCTAAeffPerfTable(const GCTAAeffPerfTable& cta); |
| 54 | virtual ~GCTAAeffPerfTable(void); | 54 | virtual ~GCTAAeffPerfTable(void); |
| 55 | 55 | ||
| @@ -70,9 +70,9 @@ public: | @@ -70,9 +70,9 @@ public: | ||
| 70 | std::string print(const GChatter& chatter = NORMAL) const; | 70 | std::string print(const GChatter& chatter = NORMAL) const; |
| 71 | 71 | ||
| 72 | // Methods | 72 | // Methods |
| 73 | - int size(void) const { return m_logE.size(); } | ||
| 74 | - void sigma(const double& sigma) { m_sigma=sigma; } | ||
| 75 | - const double& sigma(void) const { return m_sigma; } | 73 | + int size(void) const; |
| 74 | + void sigma(const double& sigma); | ||
| 75 | + const double& sigma(void) const; | ||
| 76 | 76 | ||
| 77 | private: | 77 | private: |
| 78 | // Methods | 78 | // Methods |
| @@ -87,4 +87,57 @@ private: | @@ -87,4 +87,57 @@ private: | ||
| 87 | double m_sigma; //!< Sigma for offset angle computation (0=none) | 87 | double m_sigma; //!< Sigma for offset angle computation (0=none) |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | + | ||
| 91 | +/***********************************************************************//** | ||
| 92 | + * @brief Return filename | ||
| 93 | + * | ||
| 94 | + * @return Returns filename from which effective area was loaded. | ||
| 95 | + ***************************************************************************/ | ||
| 96 | +inline | ||
| 97 | +std::string GCTAAeffPerfTable::filename(void) const | ||
| 98 | +{ | ||
| 99 | + return m_filename; | ||
| 100 | +} | ||
| 101 | + | ||
| 102 | + | ||
| 103 | +/***********************************************************************//** | ||
| 104 | + * @brief Return number of node energies in response | ||
| 105 | + * | ||
| 106 | + * @return Number of node energies. | ||
| 107 | + ***************************************************************************/ | ||
| 108 | +inline | ||
| 109 | +int GCTAAeffPerfTable::size(void) const | ||
| 110 | +{ | ||
| 111 | + return (m_logE.size()); | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | + | ||
| 115 | +/***********************************************************************//** | ||
| 116 | + * @brief Set sigma for offset angle dependence | ||
| 117 | + * | ||
| 118 | + * @param[in] sigma Sigma for offset angle dependence. | ||
| 119 | + * | ||
| 120 | + * Sets the sigma parameter for the offset angle dependence of the effective | ||
| 121 | + * area. If @p sigma is 0, no offset angle dependency will be assumed. By | ||
| 122 | + * default, @p sigma = 3. | ||
| 123 | + ***************************************************************************/ | ||
| 124 | +inline | ||
| 125 | +void GCTAAeffPerfTable::sigma(const double& sigma) | ||
| 126 | +{ | ||
| 127 | + m_sigma = sigma; | ||
| 128 | + return; | ||
| 129 | +} | ||
| 130 | + | ||
| 131 | + | ||
| 132 | +/***********************************************************************//** | ||
| 133 | + * @brief Return sigma for offset angle dependence | ||
| 134 | + * | ||
| 135 | + * @return Sigma for offset angle dependence. | ||
| 136 | + ***************************************************************************/ | ||
| 137 | +inline | ||
| 138 | +const double& GCTAAeffPerfTable::sigma(void) const | ||
| 139 | +{ | ||
| 140 | + return (m_sigma); | ||
| 141 | +} | ||
| 142 | + | ||
| 90 | #endif /* GCTAAEFFPERFTABLE_HPP */ | 143 | #endif /* GCTAAEFFPERFTABLE_HPP */ |
inst/cta/include/GCTAResponseTable.hpp
| @@ -49,11 +49,11 @@ public: | @@ -49,11 +49,11 @@ public: | ||
| 49 | // Constructors and destructors | 49 | // Constructors and destructors |
| 50 | GCTAResponseTable(void); | 50 | GCTAResponseTable(void); |
| 51 | GCTAResponseTable(const GCTAResponseTable& table); | 51 | GCTAResponseTable(const GCTAResponseTable& table); |
| 52 | - GCTAResponseTable(const GFitsTable* hdu); | 52 | + explicit GCTAResponseTable(const GFitsTable& hdu); |
| 53 | virtual ~GCTAResponseTable(void); | 53 | virtual ~GCTAResponseTable(void); |
| 54 | 54 | ||
| 55 | // Operators | 55 | // Operators |
| 56 | - GCTAResponseTable& operator= (const GCTAResponseTable & table); | 56 | + GCTAResponseTable& operator= (const GCTAResponseTable& table); |
| 57 | std::vector<double> operator()(const double& arg) const; | 57 | std::vector<double> operator()(const double& arg) const; |
| 58 | std::vector<double> operator()(const double& arg1, const double& arg2) const; | 58 | std::vector<double> operator()(const double& arg1, const double& arg2) const; |
| 59 | double operator()(const int& index, const double& arg) const; | 59 | double operator()(const int& index, const double& arg) const; |
| @@ -73,7 +73,7 @@ public: | @@ -73,7 +73,7 @@ public: | ||
| 73 | void axis_log10(const int& index); | 73 | void axis_log10(const int& index); |
| 74 | void axis_radians(const int& index); | 74 | void axis_radians(const int& index); |
| 75 | void scale(const int& index, const double& scale); | 75 | void scale(const int& index, const double& scale); |
| 76 | - void read(const GFitsTable* hdu); | 76 | + void read(const GFitsTable& hdu); |
| 77 | void write(GFitsTable* hdu) const; | 77 | void write(GFitsTable* hdu) const; |
| 78 | std::string print(const GChatter& chatter = NORMAL) const; | 78 | std::string print(const GChatter& chatter = NORMAL) const; |
| 79 | 79 | ||
| @@ -82,9 +82,9 @@ private: | @@ -82,9 +82,9 @@ private: | ||
| 82 | void init_members(void); | 82 | void init_members(void); |
| 83 | void copy_members(const GCTAResponseTable& table); | 83 | void copy_members(const GCTAResponseTable& table); |
| 84 | void free_members(void); | 84 | void free_members(void); |
| 85 | - void read_colnames(const GFitsTable* hdu); | ||
| 86 | - void read_axes(const GFitsTable* hdu); | ||
| 87 | - void read_pars(const GFitsTable* hdu); | 85 | + void read_colnames(const GFitsTable& hdu); |
| 86 | + void read_axes(const GFitsTable& hdu); | ||
| 87 | + void read_pars(const GFitsTable& hdu); | ||
| 88 | void update(const double& arg) const; | 88 | void update(const double& arg) const; |
| 89 | void update(const double& arg1, const double& arg2) const; | 89 | void update(const double& arg1, const double& arg2) const; |
| 90 | 90 |
inst/cta/pyext/GCTAAeff2D.i
| @@ -40,7 +40,7 @@ class GCTAAeff2D : public GCTAAeff { | @@ -40,7 +40,7 @@ class GCTAAeff2D : public GCTAAeff { | ||
| 40 | public: | 40 | public: |
| 41 | // Constructors and destructors | 41 | // Constructors and destructors |
| 42 | GCTAAeff2D(void); | 42 | GCTAAeff2D(void); |
| 43 | - GCTAAeff2D(const std::string& filename); | 43 | + explicit GCTAAeff2D(const std::string& filename); |
| 44 | GCTAAeff2D(const GCTAAeff2D& cta); | 44 | GCTAAeff2D(const GCTAAeff2D& cta); |
| 45 | virtual ~GCTAAeff2D(void); | 45 | virtual ~GCTAAeff2D(void); |
| 46 | 46 | ||
| @@ -59,7 +59,7 @@ public: | @@ -59,7 +59,7 @@ public: | ||
| 59 | std::string filename(void) const; | 59 | std::string filename(void) const; |
| 60 | 60 | ||
| 61 | // Methods | 61 | // Methods |
| 62 | - void read(const GFits* file); | 62 | + void read(const GFits& file); |
| 63 | }; | 63 | }; |
| 64 | 64 | ||
| 65 | 65 |
inst/cta/pyext/GCTAAeffArf.i
| 1 | /*************************************************************************** | 1 | /*************************************************************************** |
| 2 | * GCTAAeffArf.i - CTA ARF effective area class * | 2 | * GCTAAeffArf.i - CTA ARF effective area class * |
| 3 | * ----------------------------------------------------------------------- * | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012 by Juergen Knoedlseder * | 4 | + * copyright (C) 2012-2013 by Juergen Knoedlseder * |
| 5 | * ----------------------------------------------------------------------- * | 5 | * ----------------------------------------------------------------------- * |
| 6 | * * | 6 | * * |
| 7 | * This program is free software: you can redistribute it and/or modify * | 7 | * This program is free software: you can redistribute it and/or modify * |
| @@ -40,7 +40,7 @@ class GCTAAeffArf : public GCTAAeff { | @@ -40,7 +40,7 @@ class GCTAAeffArf : public GCTAAeff { | ||
| 40 | public: | 40 | public: |
| 41 | // Constructors and destructors | 41 | // Constructors and destructors |
| 42 | GCTAAeffArf(void); | 42 | GCTAAeffArf(void); |
| 43 | - GCTAAeffArf(const std::string& filename); | 43 | + explicit GCTAAeffArf(const std::string& filename); |
| 44 | GCTAAeffArf(const GCTAAeffArf& cta); | 44 | GCTAAeffArf(const GCTAAeffArf& cta); |
| 45 | virtual ~GCTAAeffArf(void); | 45 | virtual ~GCTAAeffArf(void); |
| 46 | 46 | ||
| @@ -66,7 +66,8 @@ public: | @@ -66,7 +66,8 @@ public: | ||
| 66 | const double& thetacut(void) const; | 66 | const double& thetacut(void) const; |
| 67 | void scale(const double& scale); | 67 | void scale(const double& scale); |
| 68 | const double& scale(void) const; | 68 | const double& scale(void) const; |
| 69 | - void read_arf(const GFitsTable* hdu); | 69 | + void read(const GFitsTable& hdu); |
| 70 | + void remove_thetacut(const GCTAResponse& rsp); | ||
| 70 | }; | 71 | }; |
| 71 | 72 | ||
| 72 | 73 |
inst/cta/pyext/GCTAAeffPerfTable.i
| @@ -40,7 +40,7 @@ class GCTAAeffPerfTable : public GCTAAeff { | @@ -40,7 +40,7 @@ class GCTAAeffPerfTable : public GCTAAeff { | ||
| 40 | public: | 40 | public: |
| 41 | // Constructors and destructors | 41 | // Constructors and destructors |
| 42 | GCTAAeffPerfTable(void); | 42 | GCTAAeffPerfTable(void); |
| 43 | - GCTAAeffPerfTable(const std::string& filename); | 43 | + explicit GCTAAeffPerfTable(const std::string& filename); |
| 44 | GCTAAeffPerfTable(const GCTAAeffPerfTable& cta); | 44 | GCTAAeffPerfTable(const GCTAAeffPerfTable& cta); |
| 45 | virtual ~GCTAAeffPerfTable(void); | 45 | virtual ~GCTAAeffPerfTable(void); |
| 46 | 46 |
inst/cta/pyext/GCTAResponseTable.i
| @@ -46,7 +46,7 @@ public: | @@ -46,7 +46,7 @@ public: | ||
| 46 | // Constructors and destructors | 46 | // Constructors and destructors |
| 47 | GCTAResponseTable(void); | 47 | GCTAResponseTable(void); |
| 48 | GCTAResponseTable(const GCTAResponseTable& table); | 48 | GCTAResponseTable(const GCTAResponseTable& table); |
| 49 | - GCTAResponseTable(const GFitsTable* hdu); | 49 | + explicit GCTAResponseTable(const GFitsTable& hdu); |
| 50 | virtual ~GCTAResponseTable(void); | 50 | virtual ~GCTAResponseTable(void); |
| 51 | 51 | ||
| 52 | // Interpolation operators | 52 | // Interpolation operators |
| @@ -69,7 +69,7 @@ public: | @@ -69,7 +69,7 @@ public: | ||
| 69 | void axis_log10(const int& index); | 69 | void axis_log10(const int& index); |
| 70 | void axis_radians(const int& index); | 70 | void axis_radians(const int& index); |
| 71 | void scale(const int& index, const double& scale); | 71 | void scale(const int& index, const double& scale); |
| 72 | - void read(const GFitsTable* hdu); | 72 | + void read(const GFitsTable& hdu); |
| 73 | void write(GFitsTable* hdu) const; | 73 | void write(GFitsTable* hdu) const; |
| 74 | }; | 74 | }; |
| 75 | 75 |
inst/cta/src/GCTAAeff2D.cpp
| @@ -243,7 +243,7 @@ void GCTAAeff2D::load(const std::string& filename) | @@ -243,7 +243,7 @@ void GCTAAeff2D::load(const std::string& filename) | ||
| 243 | GFits fits(filename); | 243 | GFits fits(filename); |
| 244 | 244 | ||
| 245 | // Read effective area from file | 245 | // Read effective area from file |
| 246 | - read(&fits); | 246 | + read(fits); |
| 247 | 247 | ||
| 248 | // Close FITS file | 248 | // Close FITS file |
| 249 | fits.close(); | 249 | fits.close(); |
| @@ -277,16 +277,16 @@ std::string GCTAAeff2D::filename(void) const | @@ -277,16 +277,16 @@ std::string GCTAAeff2D::filename(void) const | ||
| 277 | * The data are stored in m_aeff which is of type GCTAResponseTable. The | 277 | * The data are stored in m_aeff which is of type GCTAResponseTable. The |
| 278 | * energy axis will be set to log10, the offset angle axis to radians. | 278 | * energy axis will be set to log10, the offset angle axis to radians. |
| 279 | ***************************************************************************/ | 279 | ***************************************************************************/ |
| 280 | -void GCTAAeff2D::read(const GFits* fits) | 280 | +void GCTAAeff2D::read(const GFits& fits) |
| 281 | { | 281 | { |
| 282 | // Clear response table | 282 | // Clear response table |
| 283 | m_aeff.clear(); | 283 | m_aeff.clear(); |
| 284 | 284 | ||
| 285 | - // Get pointer to effective area HDU | ||
| 286 | - const GFitsTable* hdu = fits->table("EFFECTIVE AREA"); | 285 | + // Get effective area table |
| 286 | + const GFitsTable& table = *fits.table("EFFECTIVE AREA"); | ||
| 287 | 287 | ||
| 288 | // Read effective area table | 288 | // Read effective area table |
| 289 | - m_aeff.read(hdu); | 289 | + m_aeff.read(table); |
| 290 | 290 | ||
| 291 | // Set energy axis to logarithmic scale | 291 | // Set energy axis to logarithmic scale |
| 292 | m_aeff.axis_log10(0); | 292 | m_aeff.axis_log10(0); |
inst/cta/src/GCTAAeffArf.cpp
| @@ -39,7 +39,6 @@ | @@ -39,7 +39,6 @@ | ||
| 39 | #include "GCTAException.hpp" | 39 | #include "GCTAException.hpp" |
| 40 | 40 | ||
| 41 | /* __ Method name definitions ____________________________________________ */ | 41 | /* __ Method name definitions ____________________________________________ */ |
| 42 | -#define G_LOAD "GCTAAeffArf::load(std::string&)" | ||
| 43 | 42 | ||
| 44 | /* __ Macros _____________________________________________________________ */ | 43 | /* __ Macros _____________________________________________________________ */ |
| 45 | 44 | ||
| @@ -134,7 +133,7 @@ GCTAAeffArf::~GCTAAeffArf(void) | @@ -134,7 +133,7 @@ GCTAAeffArf::~GCTAAeffArf(void) | ||
| 134 | * @param[in] aeff Effective area. | 133 | * @param[in] aeff Effective area. |
| 135 | * @return Effective area. | 134 | * @return Effective area. |
| 136 | ***************************************************************************/ | 135 | ***************************************************************************/ |
| 137 | -GCTAAeffArf& GCTAAeffArf::operator= (const GCTAAeffArf& aeff) | 136 | +GCTAAeffArf& GCTAAeffArf::operator=(const GCTAAeffArf& aeff) |
| 138 | { | 137 | { |
| 139 | // Execute only if object is not identical | 138 | // Execute only if object is not identical |
| 140 | if (this != &aeff) { | 139 | if (this != &aeff) { |
| @@ -243,9 +242,6 @@ GCTAAeffArf* GCTAAeffArf::clone(void) const | @@ -243,9 +242,6 @@ GCTAAeffArf* GCTAAeffArf::clone(void) const | ||
| 243 | * | 242 | * |
| 244 | * @param[in] filename Performance table file name. | 243 | * @param[in] filename Performance table file name. |
| 245 | * | 244 | * |
| 246 | - * @exception GCTAExceptionHandler::file_open_error | ||
| 247 | - * File could not be opened for read access. | ||
| 248 | - * | ||
| 249 | * This method loads the effective area information from an ASCII | 245 | * This method loads the effective area information from an ASCII |
| 250 | * performance table. | 246 | * performance table. |
| 251 | ***************************************************************************/ | 247 | ***************************************************************************/ |
| @@ -255,10 +251,10 @@ void GCTAAeffArf::load(const std::string& filename) | @@ -255,10 +251,10 @@ void GCTAAeffArf::load(const std::string& filename) | ||
| 255 | GFits file(filename); | 251 | GFits file(filename); |
| 256 | 252 | ||
| 257 | // Get ARF table | 253 | // Get ARF table |
| 258 | - GFitsTable* table = file.table("SPECRESP"); | 254 | + const GFitsTable& table = *file.table("SPECRESP"); |
| 259 | 255 | ||
| 260 | // Read ARF | 256 | // Read ARF |
| 261 | - read_arf(table); | 257 | + read(table); |
| 262 | 258 | ||
| 263 | // Close ARF FITS file | 259 | // Close ARF FITS file |
| 264 | file.close(); | 260 | file.close(); |
| @@ -272,21 +268,9 @@ void GCTAAeffArf::load(const std::string& filename) | @@ -272,21 +268,9 @@ void GCTAAeffArf::load(const std::string& filename) | ||
| 272 | 268 | ||
| 273 | 269 | ||
| 274 | /***********************************************************************//** | 270 | /***********************************************************************//** |
| 275 | - * @brief Return filename | ||
| 276 | - * | ||
| 277 | - * @return Returns filename from which effective area was loaded | ||
| 278 | - ***************************************************************************/ | ||
| 279 | -std::string GCTAAeffArf::filename(void) const | ||
| 280 | -{ | ||
| 281 | - // Return filename | ||
| 282 | - return m_filename; | ||
| 283 | -} | ||
| 284 | - | ||
| 285 | - | ||
| 286 | -/***********************************************************************//** | ||
| 287 | * @brief Read CTA ARF vector | 271 | * @brief Read CTA ARF vector |
| 288 | * | 272 | * |
| 289 | - * @param[in] hdu FITS table pointer. | 273 | + * @param[in] hdu FITS table. |
| 290 | * | 274 | * |
| 291 | * This method reads a CTA ARF vector from the FITS HDU. Note that the | 275 | * This method reads a CTA ARF vector from the FITS HDU. Note that the |
| 292 | * energies are converted to TeV and the effective area is converted to cm2. | 276 | * energies are converted to TeV and the effective area is converted to cm2. |
| @@ -298,16 +282,16 @@ std::string GCTAAeffArf::filename(void) const | @@ -298,16 +282,16 @@ std::string GCTAAeffArf::filename(void) const | ||
| 298 | * For appropriate theta angle assignment, we would need this | 282 | * For appropriate theta angle assignment, we would need this |
| 299 | * information in the response header. | 283 | * information in the response header. |
| 300 | ***************************************************************************/ | 284 | ***************************************************************************/ |
| 301 | -void GCTAAeffArf::read_arf(const GFitsTable* hdu) | 285 | +void GCTAAeffArf::read(const GFitsTable& hdu) |
| 302 | { | 286 | { |
| 303 | // Clear arrays | 287 | // Clear arrays |
| 304 | m_logE.clear(); | 288 | m_logE.clear(); |
| 305 | m_aeff.clear(); | 289 | m_aeff.clear(); |
| 306 | 290 | ||
| 307 | // Get pointers to table columns | 291 | // Get pointers to table columns |
| 308 | - const GFitsTableCol* energy_lo = (*hdu)["ENERG_LO"]; | ||
| 309 | - const GFitsTableCol* energy_hi = (*hdu)["ENERG_HI"]; | ||
| 310 | - const GFitsTableCol* specresp = (*hdu)["SPECRESP"]; | 292 | + const GFitsTableCol* energy_lo = hdu["ENERG_LO"]; |
| 293 | + const GFitsTableCol* energy_hi = hdu["ENERG_HI"]; | ||
| 294 | + const GFitsTableCol* specresp = hdu["SPECRESP"]; | ||
| 311 | 295 | ||
| 312 | // Determine unit conversion factors (default: TeV and cm^2) | 296 | // Determine unit conversion factors (default: TeV and cm^2) |
| 313 | std::string u_energy_lo = gammalib::tolower(gammalib::strip_whitespace(energy_lo->unit())); | 297 | std::string u_energy_lo = gammalib::tolower(gammalib::strip_whitespace(energy_lo->unit())); |
inst/cta/src/GCTAAeffPerfTable.cpp
| @@ -130,7 +130,7 @@ GCTAAeffPerfTable::~GCTAAeffPerfTable(void) | @@ -130,7 +130,7 @@ GCTAAeffPerfTable::~GCTAAeffPerfTable(void) | ||
| 130 | * @param[in] aeff Effective area. | 130 | * @param[in] aeff Effective area. |
| 131 | * @return Effective area. | 131 | * @return Effective area. |
| 132 | ***************************************************************************/ | 132 | ***************************************************************************/ |
| 133 | -GCTAAeffPerfTable& GCTAAeffPerfTable::operator= (const GCTAAeffPerfTable& aeff) | 133 | +GCTAAeffPerfTable& GCTAAeffPerfTable::operator=(const GCTAAeffPerfTable& aeff) |
| 134 | { | 134 | { |
| 135 | // Execute only if object is not identical | 135 | // Execute only if object is not identical |
| 136 | if (this != &aeff) { | 136 | if (this != &aeff) { |
| @@ -303,18 +303,6 @@ void GCTAAeffPerfTable::load(const std::string& filename) | @@ -303,18 +303,6 @@ void GCTAAeffPerfTable::load(const std::string& filename) | ||
| 303 | 303 | ||
| 304 | 304 | ||
| 305 | /***********************************************************************//** | 305 | /***********************************************************************//** |
| 306 | - * @brief Return filename | ||
| 307 | - * | ||
| 308 | - * @return Returns filename from which effective area was loaded | ||
| 309 | - ***************************************************************************/ | ||
| 310 | -std::string GCTAAeffPerfTable::filename(void) const | ||
| 311 | -{ | ||
| 312 | - // Return filename | ||
| 313 | - return m_filename; | ||
| 314 | -} | ||
| 315 | - | ||
| 316 | - | ||
| 317 | -/***********************************************************************//** | ||
| 318 | * @brief Print effective area information | 306 | * @brief Print effective area information |
| 319 | * | 307 | * |
| 320 | * @param[in] chatter Chattiness (defaults to NORMAL). | 308 | * @param[in] chatter Chattiness (defaults to NORMAL). |
inst/cta/src/GCTAPsf2D.cpp
| @@ -259,7 +259,7 @@ void GCTAPsf2D::load(const std::string& filename) | @@ -259,7 +259,7 @@ void GCTAPsf2D::load(const std::string& filename) | ||
| 259 | GFits file(filename); | 259 | GFits file(filename); |
| 260 | 260 | ||
| 261 | // Get PSF table | 261 | // Get PSF table |
| 262 | - GFitsTable* table = file.table("POINT SPREAD FUNCTION"); | 262 | + const GFitsTable& table = *file.table("POINT SPREAD FUNCTION"); |
| 263 | 263 | ||
| 264 | // Read PSF table | 264 | // Read PSF table |
| 265 | m_psf.read(table); | 265 | m_psf.read(table); |
inst/cta/src/GCTAResponseTable.cpp
| @@ -119,7 +119,7 @@ GCTAResponseTable::GCTAResponseTable(const GCTAResponseTable& table) | @@ -119,7 +119,7 @@ GCTAResponseTable::GCTAResponseTable(const GCTAResponseTable& table) | ||
| 119 | * the object to a clean state (equivalent of GCTAResponseTable::clean | 119 | * the object to a clean state (equivalent of GCTAResponseTable::clean |
| 120 | * method). | 120 | * method). |
| 121 | ***************************************************************************/ | 121 | ***************************************************************************/ |
| 122 | -GCTAResponseTable::GCTAResponseTable(const GFitsTable* hdu) | 122 | +GCTAResponseTable::GCTAResponseTable(const GFitsTable& hdu) |
| 123 | { | 123 | { |
| 124 | // Initialise class members | 124 | // Initialise class members |
| 125 | init_members(); | 125 | init_members(); |
| @@ -715,24 +715,19 @@ void GCTAResponseTable::scale(const int& index, const double& scale) | @@ -715,24 +715,19 @@ void GCTAResponseTable::scale(const int& index, const double& scale) | ||
| 715 | * In case that the HDU table pointer is not valid (i.e. NULL), this method | 715 | * In case that the HDU table pointer is not valid (i.e. NULL), this method |
| 716 | * clears the objects and does nothing else. | 716 | * clears the objects and does nothing else. |
| 717 | ***************************************************************************/ | 717 | ***************************************************************************/ |
| 718 | -void GCTAResponseTable::read(const GFitsTable* hdu) | 718 | +void GCTAResponseTable::read(const GFitsTable& hdu) |
| 719 | { | 719 | { |
| 720 | // Clear instance | 720 | // Clear instance |
| 721 | clear(); | 721 | clear(); |
| 722 | 722 | ||
| 723 | - // Continue only if HDU pointer is valid | ||
| 724 | - if (hdu != NULL) { | 723 | + // Read column names |
| 724 | + read_colnames(hdu); | ||
| 725 | 725 | ||
| 726 | - // Read column names | ||
| 727 | - read_colnames(hdu); | 726 | + // Read axes |
| 727 | + read_axes(hdu); | ||
| 728 | 728 | ||
| 729 | - // Read axes | ||
| 730 | - read_axes(hdu); | ||
| 731 | - | ||
| 732 | - // Read parameter cubes | ||
| 733 | - read_pars(hdu); | ||
| 734 | - | ||
| 735 | - } // endif: HDU pointer was valid | 729 | + // Read parameter cubes |
| 730 | + read_pars(hdu); | ||
| 736 | 731 | ||
| 737 | // Return | 732 | // Return |
| 738 | return; | 733 | return; |
| @@ -923,7 +918,7 @@ void GCTAResponseTable::free_members(void) | @@ -923,7 +918,7 @@ void GCTAResponseTable::free_members(void) | ||
| 923 | /***********************************************************************//** | 918 | /***********************************************************************//** |
| 924 | * @brief Read column names from FITS HDU | 919 | * @brief Read column names from FITS HDU |
| 925 | * | 920 | * |
| 926 | - * @param[in] hdu Response table HDU pointer. | 921 | + * @param[in] hdu Response table HDU. |
| 927 | * | 922 | * |
| 928 | * @exception GCTAException::bad_rsp_table_format | 923 | * @exception GCTAException::bad_rsp_table_format |
| 929 | * Bad response table format encountered in FITS HDU. | 924 | * Bad response table format encountered in FITS HDU. |
| @@ -949,7 +944,7 @@ void GCTAResponseTable::free_members(void) | @@ -949,7 +944,7 @@ void GCTAResponseTable::free_members(void) | ||
| 949 | * | 944 | * |
| 950 | * @todo Implement exceptions for invalid HDU format | 945 | * @todo Implement exceptions for invalid HDU format |
| 951 | ***************************************************************************/ | 946 | ***************************************************************************/ |
| 952 | -void GCTAResponseTable::read_colnames(const GFitsTable* hdu) | 947 | +void GCTAResponseTable::read_colnames(const GFitsTable& hdu) |
| 953 | { | 948 | { |
| 954 | // Clear column name arrays | 949 | // Clear column name arrays |
| 955 | m_naxes = 0; | 950 | m_naxes = 0; |
| @@ -958,103 +953,98 @@ void GCTAResponseTable::read_colnames(const GFitsTable* hdu) | @@ -958,103 +953,98 @@ void GCTAResponseTable::read_colnames(const GFitsTable* hdu) | ||
| 958 | m_colname_hi.clear(); | 953 | m_colname_hi.clear(); |
| 959 | m_colname_par.clear(); | 954 | m_colname_par.clear(); |
| 960 | 955 | ||
| 961 | - // Continue only if HDU is valid | ||
| 962 | - if (hdu != NULL) { | ||
| 963 | - | ||
| 964 | - // Initialise search mode. There are three search modes: | ||
| 965 | - // 0 - we're looking for the next axis by searching for a column | ||
| 966 | - // terminating with "_LO" | ||
| 967 | - // 1 - we're looking for the upper boundary of an axis, terminating | ||
| 968 | - // with "_HI" | ||
| 969 | - // 2 - we're looking for a parameter column | ||
| 970 | - int mode = 0; | ||
| 971 | - std::string lo_column; | ||
| 972 | - std::string next_column; | ||
| 973 | - | ||
| 974 | - // Extract column names for all axes | ||
| 975 | - for (int i = 0; i < hdu->ncols(); ++i) { | ||
| 976 | - | ||
| 977 | - // Get column name | ||
| 978 | - std::string colname = (*hdu)[i]->name(); | ||
| 979 | - | ||
| 980 | - // If we search for a "_LO" column, check if we have one. If one | ||
| 981 | - // is found, change the search mode to 1 and set the expected name | ||
| 982 | - // for the "_HI" column. If none is found, change the search | ||
| 983 | - // mode to 2 since from now on we should only have parameter | ||
| 984 | - // columns. | ||
| 985 | - if (mode == 0) { | ||
| 986 | - size_t pos = colname.rfind("_LO"); | ||
| 987 | - if (pos != std::string::npos) { | ||
| 988 | - mode = 1; | ||
| 989 | - lo_column = colname; | ||
| 990 | - next_column = colname.substr(0, pos) + "_HI"; | ||
| 991 | - } | ||
| 992 | - else { | ||
| 993 | - if (colname.rfind("_HI") != std::string::npos) { | ||
| 994 | - std::string message = "Column '" + | ||
| 995 | - colname + | ||
| 996 | - "' encountered without" | ||
| 997 | - " preceeding '_LO' column."; | ||
| 998 | - throw GCTAException::bad_rsp_table_format(G_READ_COLNAMES, | ||
| 999 | - message); | ||
| 1000 | - } | ||
| 1001 | - else { | ||
| 1002 | - mode = 2; | ||
| 1003 | - m_colname_par.push_back(colname); | ||
| 1004 | - } | ||
| 1005 | - } | ||
| 1006 | - } | ||
| 1007 | - | ||
| 1008 | - // If we search for a "_HI" column, check if we have the | ||
| 1009 | - // expected column name. If this is the case, switch back to | ||
| 1010 | - // search mode 0 to get the next "_LO" column. Otherwise | ||
| 1011 | - // throw an exception. | ||
| 1012 | - else if (mode == 1) { | ||
| 1013 | - if (colname == next_column) { | ||
| 1014 | - mode = 0; | ||
| 1015 | - m_colname_lo.push_back(lo_column); | ||
| 1016 | - m_colname_hi.push_back(next_column); | ||
| 1017 | - } | ||
| 1018 | - else { | ||
| 1019 | - std::string message = "Expected column '" + | ||
| 1020 | - next_column + | ||
| 1021 | - "' not found. '_HI' columns have" | ||
| 1022 | - " to be placed immediately after" | ||
| 1023 | - " corresponding '_LO' columns."; | ||
| 1024 | - throw GCTAException::bad_rsp_table_format(G_READ_COLNAMES, | ||
| 1025 | - message); | ||
| 1026 | - } | 956 | + // Initialise search mode. There are three search modes: |
| 957 | + // 0 - we're looking for the next axis by searching for a column | ||
| 958 | + // terminating with "_LO" | ||
| 959 | + // 1 - we're looking for the upper boundary of an axis, terminating | ||
| 960 | + // with "_HI" | ||
| 961 | + // 2 - we're looking for a parameter column | ||
| 962 | + int mode = 0; | ||
| 963 | + std::string lo_column; | ||
| 964 | + std::string next_column; | ||
| 965 | + | ||
| 966 | + // Extract column names for all axes | ||
| 967 | + for (int i = 0; i < hdu.ncols(); ++i) { | ||
| 968 | + | ||
| 969 | + // Get column name | ||
| 970 | + std::string colname = hdu[i]->name(); | ||
| 971 | + | ||
| 972 | + // If we search for a "_LO" column, check if we have one. If one | ||
| 973 | + // is found, change the search mode to 1 and set the expected name | ||
| 974 | + // for the "_HI" column. If none is found, change the search | ||
| 975 | + // mode to 2 since from now on we should only have parameter | ||
| 976 | + // columns. | ||
| 977 | + if (mode == 0) { | ||
| 978 | + size_t pos = colname.rfind("_LO"); | ||
| 979 | + if (pos != std::string::npos) { | ||
| 980 | + mode = 1; | ||
| 981 | + lo_column = colname; | ||
| 982 | + next_column = colname.substr(0, pos) + "_HI"; | ||
| 1027 | } | 983 | } |
| 1028 | - | ||
| 1029 | - // If we search for a parameter column, make sure that we have | ||
| 1030 | - // neither a "_LO" nor a "_HI" column. | ||
| 1031 | else { | 984 | else { |
| 1032 | - if (colname.rfind("_LO") != std::string::npos) { | 985 | + if (colname.rfind("_HI") != std::string::npos) { |
| 1033 | std::string message = "Column '" + | 986 | std::string message = "Column '" + |
| 1034 | colname + | 987 | colname + |
| 1035 | - "' found. All '_LO' columns have to" | ||
| 1036 | - " be placed before the parameter" | ||
| 1037 | - " columns."; | ||
| 1038 | - throw GCTAException::bad_rsp_table_format(G_READ_COLNAMES, | ||
| 1039 | - message); | ||
| 1040 | - } | ||
| 1041 | - else if (colname.rfind("_HI") != std::string::npos) { | ||
| 1042 | - std::string message = "Column '" + | ||
| 1043 | - colname + | ||
| 1044 | - "' found. All '_HI' columns have to" | ||
| 1045 | - " be placed before the parameter" | ||
| 1046 | - " columns."; | 988 | + "' encountered without" |
| 989 | + " preceeding '_LO' column."; | ||
| 1047 | throw GCTAException::bad_rsp_table_format(G_READ_COLNAMES, | 990 | throw GCTAException::bad_rsp_table_format(G_READ_COLNAMES, |
| 1048 | message); | 991 | message); |
| 1049 | } | 992 | } |
| 1050 | else { | 993 | else { |
| 994 | + mode = 2; | ||
| 1051 | m_colname_par.push_back(colname); | 995 | m_colname_par.push_back(colname); |
| 1052 | } | 996 | } |
| 1053 | } | 997 | } |
| 998 | + } | ||
| 1054 | 999 | ||
| 1055 | - } // endfor: looped over all column names | 1000 | + // If we search for a "_HI" column, check if we have the |
| 1001 | + // expected column name. If this is the case, switch back to | ||
| 1002 | + // search mode 0 to get the next "_LO" column. Otherwise | ||
| 1003 | + // throw an exception. | ||
| 1004 | + else if (mode == 1) { | ||
| 1005 | + if (colname == next_column) { | ||
| 1006 | + mode = 0; | ||
| 1007 | + m_colname_lo.push_back(lo_column); | ||
| 1008 | + m_colname_hi.push_back(next_column); | ||
| 1009 | + } | ||
| 1010 | + else { | ||
| 1011 | + std::string message = "Expected column '" + | ||
| 1012 | + next_column + | ||
| 1013 | + "' not found. '_HI' columns have" | ||
| 1014 | + " to be placed immediately after" | ||
| 1015 | + " corresponding '_LO' columns."; | ||
| 1016 | + throw GCTAException::bad_rsp_table_format(G_READ_COLNAMES, | ||
| 1017 | + message); | ||
| 1018 | + } | ||
| 1019 | + } | ||
| 1056 | 1020 | ||
| 1057 | - } // endif: HDU was valid | 1021 | + // If we search for a parameter column, make sure that we have |
| 1022 | + // neither a "_LO" nor a "_HI" column. | ||
| 1023 | + else { | ||
| 1024 | + if (colname.rfind("_LO") != std::string::npos) { | ||
| 1025 | + std::string message = "Column '" + | ||
| 1026 | + colname + | ||
| 1027 | + "' found. All '_LO' columns have to" | ||
| 1028 | + " be placed before the parameter" | ||
| 1029 | + " columns."; | ||
| 1030 | + throw GCTAException::bad_rsp_table_format(G_READ_COLNAMES, | ||
| 1031 | + message); | ||
| 1032 | + } | ||
| 1033 | + else if (colname.rfind("_HI") != std::string::npos) { | ||
| 1034 | + std::string message = "Column '" + | ||
| 1035 | + colname + | ||
| 1036 | + "' found. All '_HI' columns have to" | ||
| 1037 | + " be placed before the parameter" | ||
| 1038 | + " columns."; | ||
| 1039 | + throw GCTAException::bad_rsp_table_format(G_READ_COLNAMES, | ||
| 1040 | + message); | ||
| 1041 | + } | ||
| 1042 | + else { | ||
| 1043 | + m_colname_par.push_back(colname); | ||
| 1044 | + } | ||
| 1045 | + } | ||
| 1046 | + | ||
| 1047 | + } // endfor: looped over all column names | ||
| 1058 | 1048 | ||
| 1059 | // Store number of axes | 1049 | // Store number of axes |
| 1060 | m_naxes = m_colname_lo.size(); | 1050 | m_naxes = m_colname_lo.size(); |
| @@ -1070,7 +1060,7 @@ void GCTAResponseTable::read_colnames(const GFitsTable* hdu) | @@ -1070,7 +1060,7 @@ void GCTAResponseTable::read_colnames(const GFitsTable* hdu) | ||
| 1070 | /***********************************************************************//** | 1060 | /***********************************************************************//** |
| 1071 | * @brief Read axes definitions from FITS HDU | 1061 | * @brief Read axes definitions from FITS HDU |
| 1072 | * | 1062 | * |
| 1073 | - * @param[in] hdu Response table HDU pointer. | 1063 | + * @param[in] hdu Response table HDU. |
| 1074 | * | 1064 | * |
| 1075 | * @exception GCTAException::bad_rsp_table_format | 1065 | * @exception GCTAException::bad_rsp_table_format |
| 1076 | * Incompatible axes columns found. | 1066 | * Incompatible axes columns found. |
| @@ -1094,58 +1084,53 @@ void GCTAResponseTable::read_colnames(const GFitsTable* hdu) | @@ -1094,58 +1084,53 @@ void GCTAResponseTable::read_colnames(const GFitsTable* hdu) | ||
| 1094 | * In case that the HDU pointer is not valid (NULL), this method clears the | 1084 | * In case that the HDU pointer is not valid (NULL), this method clears the |
| 1095 | * axes boundaries and does nothing else. | 1085 | * axes boundaries and does nothing else. |
| 1096 | ***************************************************************************/ | 1086 | ***************************************************************************/ |
| 1097 | -void GCTAResponseTable::read_axes(const GFitsTable* hdu) | 1087 | +void GCTAResponseTable::read_axes(const GFitsTable& hdu) |
| 1098 | { | 1088 | { |
| 1099 | // Clear axes arrays | 1089 | // Clear axes arrays |
| 1100 | m_axis_lo.clear(); | 1090 | m_axis_lo.clear(); |
| 1101 | m_axis_hi.clear(); | 1091 | m_axis_hi.clear(); |
| 1102 | m_axis_nodes.clear(); | 1092 | m_axis_nodes.clear(); |
| 1103 | 1093 | ||
| 1104 | - // Continue only if HDU is valid | ||
| 1105 | - if (hdu != NULL) { | ||
| 1106 | - | ||
| 1107 | - // Loop over all dimensions | ||
| 1108 | - for (int i = 0; i < axes(); ++i) { | ||
| 1109 | - | ||
| 1110 | - // Get pointers to table columns | ||
| 1111 | - const GFitsTableCol* col_lo = (*hdu)[m_colname_lo[i]]; | ||
| 1112 | - const GFitsTableCol* col_hi = (*hdu)[m_colname_hi[i]]; | ||
| 1113 | - | ||
| 1114 | - // Extract number of bins. Make sure that both columns have the | ||
| 1115 | - // same number of bins | ||
| 1116 | - int num = col_lo->number(); | ||
| 1117 | - if (num != col_hi->number()) { | ||
| 1118 | - std::string message = "Incompatible number of bins found" | ||
| 1119 | - " for columns '"+m_colname_lo[i]+"'"+ | ||
| 1120 | - " ("+gammalib::str(num)+") and '"+ | ||
| 1121 | - m_colname_hi[i]+"' ("+ | ||
| 1122 | - gammalib::str(col_hi->number())+"."; | ||
| 1123 | - throw GCTAException::bad_rsp_table_format(G_READ_AXES, | ||
| 1124 | - message); | ||
| 1125 | - } | ||
| 1126 | - | ||
| 1127 | - // Initialise axis and node arrays | ||
| 1128 | - std::vector<double> axis_lo(num); | ||
| 1129 | - std::vector<double> axis_hi(num); | ||
| 1130 | - std::vector<double> axis_nodes(num); | 1094 | + // Loop over all dimensions |
| 1095 | + for (int i = 0; i < axes(); ++i) { | ||
| 1096 | + | ||
| 1097 | + // Get pointers to table columns | ||
| 1098 | + const GFitsTableCol* col_lo = hdu[m_colname_lo[i]]; | ||
| 1099 | + const GFitsTableCol* col_hi = hdu[m_colname_hi[i]]; | ||
| 1100 | + | ||
| 1101 | + // Extract number of bins. Make sure that both columns have the | ||
| 1102 | + // same number of bins | ||
| 1103 | + int num = col_lo->number(); | ||
| 1104 | + if (num != col_hi->number()) { | ||
| 1105 | + std::string message = "Incompatible number of bins found" | ||
| 1106 | + " for columns '"+m_colname_lo[i]+"'"+ | ||
| 1107 | + " ("+gammalib::str(num)+") and '"+ | ||
| 1108 | + m_colname_hi[i]+"' ("+ | ||
| 1109 | + gammalib::str(col_hi->number())+"."; | ||
| 1110 | + throw GCTAException::bad_rsp_table_format(G_READ_AXES, | ||
| 1111 | + message); | ||
| 1112 | + } | ||
| 1131 | 1113 | ||
| 1132 | - // Copy axis information into arrays | ||
| 1133 | - for (int k = 0; k < num; ++k) { | ||
| 1134 | - axis_lo[k] = col_lo->real(0,k); | ||
| 1135 | - axis_hi[k] = col_hi->real(0,k); | ||
| 1136 | - axis_nodes[k] = 0.5*(axis_lo[k] + axis_hi[k]); | ||
| 1137 | - } | 1114 | + // Initialise axis and node arrays |
| 1115 | + std::vector<double> axis_lo(num); | ||
| 1116 | + std::vector<double> axis_hi(num); | ||
| 1117 | + std::vector<double> axis_nodes(num); | ||
| 1138 | 1118 | ||
| 1139 | - // Push axis array on storage | ||
| 1140 | - m_axis_lo.push_back(axis_lo); | ||
| 1141 | - m_axis_hi.push_back(axis_hi); | 1119 | + // Copy axis information into arrays |
| 1120 | + for (int k = 0; k < num; ++k) { | ||
| 1121 | + axis_lo[k] = col_lo->real(0,k); | ||
| 1122 | + axis_hi[k] = col_hi->real(0,k); | ||
| 1123 | + axis_nodes[k] = 0.5*(axis_lo[k] + axis_hi[k]); | ||
| 1124 | + } | ||
| 1142 | 1125 | ||
| 1143 | - // Create node array | ||
| 1144 | - m_axis_nodes.push_back(GNodeArray(axis_nodes)); | 1126 | + // Push axis array on storage |
| 1127 | + m_axis_lo.push_back(axis_lo); | ||
| 1128 | + m_axis_hi.push_back(axis_hi); | ||
| 1145 | 1129 | ||
| 1146 | - } // endfor: looped over all dimensions | 1130 | + // Create node array |
| 1131 | + m_axis_nodes.push_back(GNodeArray(axis_nodes)); | ||
| 1147 | 1132 | ||
| 1148 | - } // endif: HDU was valid | 1133 | + } // endfor: looped over all dimensions |
| 1149 | 1134 | ||
| 1150 | // Return | 1135 | // Return |
| 1151 | return; | 1136 | return; |
| @@ -1155,7 +1140,7 @@ void GCTAResponseTable::read_axes(const GFitsTable* hdu) | @@ -1155,7 +1140,7 @@ void GCTAResponseTable::read_axes(const GFitsTable* hdu) | ||
| 1155 | /***********************************************************************//** | 1140 | /***********************************************************************//** |
| 1156 | * @brief Read parameter cubes | 1141 | * @brief Read parameter cubes |
| 1157 | * | 1142 | * |
| 1158 | - * @param[in] hdu Response table HDU pointer. | 1143 | + * @param[in] hdu Response table HDU. |
| 1159 | * | 1144 | * |
| 1160 | * @exception GCTAException::bad_rsp_table_format | 1145 | * @exception GCTAException::bad_rsp_table_format |
| 1161 | * Parameter vector of bad size encountered. | 1146 | * Parameter vector of bad size encountered. |
| @@ -1171,52 +1156,47 @@ void GCTAResponseTable::read_axes(const GFitsTable* hdu) | @@ -1171,52 +1156,47 @@ void GCTAResponseTable::read_axes(const GFitsTable* hdu) | ||
| 1171 | * In case that the HDU pointer is not valid (NULL), this method clears the | 1156 | * In case that the HDU pointer is not valid (NULL), this method clears the |
| 1172 | * axes boundaries and does nothing else. | 1157 | * axes boundaries and does nothing else. |
| 1173 | ***************************************************************************/ | 1158 | ***************************************************************************/ |
| 1174 | -void GCTAResponseTable::read_pars(const GFitsTable* hdu) | 1159 | +void GCTAResponseTable::read_pars(const GFitsTable& hdu) |
| 1175 | { | 1160 | { |
| 1176 | // Clear parameter cubes | 1161 | // Clear parameter cubes |
| 1177 | m_pars.clear(); | 1162 | m_pars.clear(); |
| 1178 | 1163 | ||
| 1179 | - // Continue only if HDU is valid | ||
| 1180 | - if (hdu != NULL) { | ||
| 1181 | - | ||
| 1182 | - // Compute expected cube size | ||
| 1183 | - m_nelements = axis(0); | ||
| 1184 | - for (int i = 1; i < axes(); ++i) { | ||
| 1185 | - m_nelements *= axis(i); | ||
| 1186 | - } | 1164 | + // Compute expected cube size |
| 1165 | + m_nelements = axis(0); | ||
| 1166 | + for (int i = 1; i < axes(); ++i) { | ||
| 1167 | + m_nelements *= axis(i); | ||
| 1168 | + } | ||
| 1187 | 1169 | ||
| 1188 | - // Loop over all parameter cubes | ||
| 1189 | - for (int i = 0; i < size(); ++i) { | ||
| 1190 | - | ||
| 1191 | - // Get pointer to table column | ||
| 1192 | - const GFitsTableCol* col = (*hdu)[m_colname_par[i]]; | ||
| 1193 | - | ||
| 1194 | - // Extract number of bins. Verify that the number of bins | ||
| 1195 | - // corresponds to the expectation. | ||
| 1196 | - int num = col->number(); | ||
| 1197 | - if (num != m_nelements) { | ||
| 1198 | - std::string message = "Parameter vector '"+m_colname_par[i]+ | ||
| 1199 | - "' has wrong size "+gammalib::str(num)+ | ||
| 1200 | - " (expected"+ | ||
| 1201 | - gammalib::str(m_nelements)+")."; | ||
| 1202 | - throw GCTAException::bad_rsp_table_format(G_READ_PARS, | ||
| 1203 | - message); | ||
| 1204 | - } | ||
| 1205 | - | ||
| 1206 | - // Initialise parameter cube | ||
| 1207 | - std::vector<double> pars(num); | 1170 | + // Loop over all parameter cubes |
| 1171 | + for (int i = 0; i < size(); ++i) { | ||
| 1172 | + | ||
| 1173 | + // Get pointer to table column | ||
| 1174 | + const GFitsTableCol* col = hdu[m_colname_par[i]]; | ||
| 1175 | + | ||
| 1176 | + // Extract number of bins. Verify that the number of bins | ||
| 1177 | + // corresponds to the expectation. | ||
| 1178 | + int num = col->number(); | ||
| 1179 | + if (num != m_nelements) { | ||
| 1180 | + std::string message = "Parameter vector '"+m_colname_par[i]+ | ||
| 1181 | + "' has wrong size "+gammalib::str(num)+ | ||
| 1182 | + " (expected"+ | ||
| 1183 | + gammalib::str(m_nelements)+")."; | ||
| 1184 | + throw GCTAException::bad_rsp_table_format(G_READ_PARS, | ||
| 1185 | + message); | ||
| 1186 | + } | ||
| 1208 | 1187 | ||
| 1209 | - // Copy parameter values | ||
| 1210 | - for (int k = 0; k < num; ++k) { | ||
| 1211 | - pars[k] = col->real(0,k); | ||
| 1212 | - } | 1188 | + // Initialise parameter cube |
| 1189 | + std::vector<double> pars(num); | ||
| 1213 | 1190 | ||
| 1214 | - // Push cube into storage | ||
| 1215 | - m_pars.push_back(pars); | 1191 | + // Copy parameter values |
| 1192 | + for (int k = 0; k < num; ++k) { | ||
| 1193 | + pars[k] = col->real(0,k); | ||
| 1194 | + } | ||
| 1216 | 1195 | ||
| 1217 | - } // endfor: looped over all parameter cubes | 1196 | + // Push cube into storage |
| 1197 | + m_pars.push_back(pars); | ||
| 1218 | 1198 | ||
| 1219 | - } // endif: HDU was valid | 1199 | + } // endfor: looped over all parameter cubes |
| 1220 | 1200 | ||
| 1221 | // Return | 1201 | // Return |
| 1222 | return; | 1202 | return; |