Commit 3e38d75b0b5c92eb23db9d9326d4fec49e5e2677
1 parent
685a47ad
Review GTime, GTimeReference, GGti, GEbounds and GPhoton classes.
GTime The secs() method now returns a const reference. GTimeReference The load constructor and the read() and write() methods take a const reference instead of a pointer. GGti The read() and write() methods now use references instead of pointers. The clobber argument in the save() method is passed as const reference. GEbounds The read() and write() methods now use FITS references instead of pointers. The clobber argument in the save() method is passed as const reference. GPhoton Add mcid argument to Photon constructor (defaults to -1).
Showing
25 changed files
with
602 additions
and
321 deletions
NEWS
| ... | ... | @@ -2,7 +2,7 @@ New Features and Important Changes in GammaLib 00-08-00 |
| 2 | 2 | |
| 3 | 3 | Author(s) : Juergen Knoedlseder |
| 4 | 4 | |
| 5 | -5 December 2013 | |
| 5 | +6 December 2013 | |
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | 1. Introduction |
| ... | ... | @@ -31,7 +31,9 @@ GEbounds |
| 31 | 31 | The number argument in the setlin() and setlon() methods has been moved |
| 32 | 32 | from the last position to the first position in the argument list. |
| 33 | 33 | The emin(), emax(), emean() and elogmean() methods now take a const |
| 34 | - integer reference as argument instead of an integer value. | |
| 34 | + integer reference as argument instead of an integer value. The read() | |
| 35 | + and write() methods now use FITS references instead of pointers. The | |
| 36 | + clobber argument in the save() method is passed as const reference. | |
| 35 | 37 | |
| 36 | 38 | GFits |
| 37 | 39 | The GFits class now derives from GContainer and implements all generic |
| ... | ... | @@ -86,6 +88,11 @@ GFunction |
| 86 | 88 | The eval() method now takes a const reference to a double precisio |
| 87 | 89 | value as argument. |
| 88 | 90 | |
| 91 | +GGti | |
| 92 | + The read() and write() methods now use references instead of | |
| 93 | + pointers. The clobber argument in the save() method is passed | |
| 94 | + as const reference. | |
| 95 | + | |
| 89 | 96 | GMatrixBase |
| 90 | 97 | GMatrix |
| 91 | 98 | GMatrixSparse (formerly GSparseMatrix) |
| ... | ... | @@ -170,6 +177,9 @@ GPars |
| 170 | 177 | reserve() and extent() methods. The haspar() method has been |
| 171 | 178 | renamed to contains() for consistency. |
| 172 | 179 | |
| 180 | +GPhoton | |
| 181 | + Add mcid argument to Photon constructor (defaults to -1). | |
| 182 | + | |
| 173 | 183 | GSkyPixel |
| 174 | 184 | The class now supports 1D and 2D pixels. Type conversion methods |
| 175 | 185 | have been added that allow assigning integer and double precision |
| ... | ... | @@ -200,6 +210,13 @@ GTestSuites |
| 200 | 210 | The operator[] now returns pointers to GTestSuite. The name() |
| 201 | 211 | and timestamp() methods now return const references. |
| 202 | 212 | |
| 213 | +GTime | |
| 214 | + The secs() method now returns a const reference. | |
| 215 | + | |
| 216 | +GTimeReference | |
| 217 | + The load constructor and the read() and write() methods take | |
| 218 | + a const reference instead of a pointer. | |
| 219 | + | |
| 203 | 220 | GWcs => GSkyProjection |
| 204 | 221 | The GWcs class has been renamed to GSkyProjection as it is more |
| 205 | 222 | general than the World Coordinate Systems. A size() method has | ... | ... |
include/GEbounds.hpp
| ... | ... | @@ -63,35 +63,36 @@ public: |
| 63 | 63 | GEbounds& operator=(const GEbounds& ebds); |
| 64 | 64 | |
| 65 | 65 | // Methods |
| 66 | - void clear(void); | |
| 67 | - GEbounds* clone(void) const; | |
| 68 | - int size(void) const { return m_num; } | |
| 69 | - bool isempty(void) const { return (m_num == 0); } | |
| 70 | - void append(const GEnergy& emin, const GEnergy& emax); | |
| 71 | - void insert(const GEnergy& emin, const GEnergy& emax); | |
| 72 | - void merge(void); | |
| 73 | - void merge(const GEnergy& emin, const GEnergy& emax); | |
| 74 | - void remove(const int& index); | |
| 75 | - void reserve(const int& num); | |
| 76 | - void extend(const GEbounds& ebds); | |
| 77 | - void setlin(const int& num, const GEnergy& emin, const GEnergy& emax); | |
| 78 | - void setlog(const int& num, const GEnergy& emin, const GEnergy& emax); | |
| 79 | - void load(const std::string& filename, | |
| 80 | - const std::string& extname = "EBOUNDS"); | |
| 81 | - void save(const std::string& filename, bool clobber, | |
| 82 | - const std::string& extname = "EBOUNDS") const; | |
| 83 | - void read(GFitsTable* hdu); | |
| 84 | - void write(GFits* file, const std::string& extname = "EBOUNDS") const; | |
| 85 | - int index(const GEnergy& eng) const; | |
| 86 | - GEnergy emin(void) const { return m_emin; } //!< @brief Returns minimum energy of all intervals | |
| 87 | - GEnergy emax(void) const { return m_emax; } //!< @brief Returns maximum energy of all intervals | |
| 88 | - GEnergy emin(const int& index) const; | |
| 89 | - GEnergy emax(const int& index) const; | |
| 90 | - GEnergy emean(const int& index) const; | |
| 91 | - GEnergy elogmean(const int& index) const; | |
| 92 | - GEnergy ewidth(const int& index) const; | |
| 93 | - bool contains(const GEnergy& eng) const; | |
| 94 | - std::string print(const GChatter& chatter = NORMAL) const; | |
| 66 | + void clear(void); | |
| 67 | + GEbounds* clone(void) const; | |
| 68 | + int size(void) const; | |
| 69 | + bool isempty(void) const; | |
| 70 | + void append(const GEnergy& emin, const GEnergy& emax); | |
| 71 | + void insert(const GEnergy& emin, const GEnergy& emax); | |
| 72 | + void merge(void); | |
| 73 | + void merge(const GEnergy& emin, const GEnergy& emax); | |
| 74 | + void remove(const int& index); | |
| 75 | + void reserve(const int& num); | |
| 76 | + void extend(const GEbounds& ebds); | |
| 77 | + void setlin(const int& num, const GEnergy& emin, const GEnergy& emax); | |
| 78 | + void setlog(const int& num, const GEnergy& emin, const GEnergy& emax); | |
| 79 | + void load(const std::string& filename, | |
| 80 | + const std::string& extname = "EBOUNDS"); | |
| 81 | + void save(const std::string& filename, | |
| 82 | + const bool& clobber = false, | |
| 83 | + const std::string& extname = "EBOUNDS") const; | |
| 84 | + void read(const GFitsTable& table); | |
| 85 | + void write(GFits& file, const std::string& extname = "EBOUNDS") const; | |
| 86 | + int index(const GEnergy& eng) const; | |
| 87 | + const GEnergy& emin(void) const; | |
| 88 | + const GEnergy& emax(void) const; | |
| 89 | + GEnergy emin(const int& index) const; | |
| 90 | + GEnergy emax(const int& index) const; | |
| 91 | + GEnergy emean(const int& index) const; | |
| 92 | + GEnergy elogmean(const int& index) const; | |
| 93 | + GEnergy ewidth(const int& index) const; | |
| 94 | + bool contains(const GEnergy& eng) const; | |
| 95 | + std::string print(const GChatter& chatter = NORMAL) const; | |
| 95 | 96 | |
| 96 | 97 | |
| 97 | 98 | protected: |
| ... | ... | @@ -110,4 +111,52 @@ protected: |
| 110 | 111 | GEnergy* m_max; //!< Array of interval maximum energies |
| 111 | 112 | }; |
| 112 | 113 | |
| 114 | + | |
| 115 | +/***********************************************************************//** | |
| 116 | + * @brief Return number of energy boundaries | |
| 117 | + * | |
| 118 | + * @return Number of energy boundaries. | |
| 119 | + ***************************************************************************/ | |
| 120 | +inline | |
| 121 | +int GEbounds::size(void) const | |
| 122 | +{ | |
| 123 | + return m_num; | |
| 124 | +} | |
| 125 | + | |
| 126 | + | |
| 127 | +/***********************************************************************//** | |
| 128 | + * @brief Signal if there are no energy boundaries | |
| 129 | + * | |
| 130 | + * @return True if there are no energy boundaries. | |
| 131 | + ***************************************************************************/ | |
| 132 | +inline | |
| 133 | +bool GEbounds::isempty(void) const | |
| 134 | +{ | |
| 135 | + return (m_num == 0); | |
| 136 | +} | |
| 137 | + | |
| 138 | + | |
| 139 | +/***********************************************************************//** | |
| 140 | + * @brief Return minimum energy of all intervals | |
| 141 | + * | |
| 142 | + * @return Minimum energy of all intervals. | |
| 143 | + ***************************************************************************/ | |
| 144 | +inline | |
| 145 | +const GEnergy& GEbounds::emin(void) const | |
| 146 | +{ | |
| 147 | + return m_emin; | |
| 148 | +} | |
| 149 | + | |
| 150 | + | |
| 151 | +/***********************************************************************//** | |
| 152 | + * @brief Return maximum energy of all intervals | |
| 153 | + * | |
| 154 | + * @return Maximum energy of all intervals. | |
| 155 | + ***************************************************************************/ | |
| 156 | +inline | |
| 157 | +const GEnergy& GEbounds::emax(void) const | |
| 158 | +{ | |
| 159 | + return m_emax; | |
| 160 | +} | |
| 161 | + | |
| 113 | 162 | #endif /* GEBOUNDS_HPP */ | ... | ... |
include/GGti.hpp
| ... | ... | @@ -65,8 +65,8 @@ public: |
| 65 | 65 | // Methods |
| 66 | 66 | void clear(void); |
| 67 | 67 | GGti* clone(void) const; |
| 68 | - int size(void) const { return m_num; } | |
| 69 | - bool isempty(void) const { return (m_num == 0); } | |
| 68 | + int size(void) const; | |
| 69 | + bool isempty(void) const; | |
| 70 | 70 | void append(const GTime& tstart, const GTime& tstop); |
| 71 | 71 | void insert(const GTime& tstart, const GTime& tstop); |
| 72 | 72 | void merge(void); |
| ... | ... | @@ -77,10 +77,11 @@ public: |
| 77 | 77 | void extend(const GGti& gti); |
| 78 | 78 | void load(const std::string& filename, |
| 79 | 79 | const std::string& extname = "GTI"); |
| 80 | - void save(const std::string& filename, bool clobber, | |
| 80 | + void save(const std::string& filename, | |
| 81 | + const bool& clobber = false, | |
| 81 | 82 | const std::string& extname = "GTI") const; |
| 82 | - void read(const GFitsTable* hdu); | |
| 83 | - void write(GFits* file, | |
| 83 | + void read(const GFitsTable& table); | |
| 84 | + void write(GFits& file, | |
| 84 | 85 | const std::string& extname = "GTI") const; |
| 85 | 86 | const GTime& tstart(void) const; |
| 86 | 87 | const GTime& tstop(void) const; |
| ... | ... | @@ -112,4 +113,28 @@ protected: |
| 112 | 113 | GTimeReference m_reference; //!< Time reference |
| 113 | 114 | }; |
| 114 | 115 | |
| 116 | + | |
| 117 | +/***********************************************************************//** | |
| 118 | + * @brief Return number of Good Time Intervals | |
| 119 | + * | |
| 120 | + * @return Number of Good Time Intervals. | |
| 121 | + ***************************************************************************/ | |
| 122 | +inline | |
| 123 | +int GGti::size(void) const | |
| 124 | +{ | |
| 125 | + return m_num; | |
| 126 | +} | |
| 127 | + | |
| 128 | + | |
| 129 | +/***********************************************************************//** | |
| 130 | + * @brief Signal if there are no Good Time Intervals | |
| 131 | + * | |
| 132 | + * @return True if there are no Good Time Intervals. | |
| 133 | + ***************************************************************************/ | |
| 134 | +inline | |
| 135 | +bool GGti::isempty(void) const | |
| 136 | +{ | |
| 137 | + return (m_num == 0); | |
| 138 | +} | |
| 139 | + | |
| 115 | 140 | #endif /* GGTI_HPP */ | ... | ... |
include/GPhoton.hpp
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GPhoton.hpp |
| 23 | - * @brief Photon class definition. | |
| 23 | + * @brief Photon class definition | |
| 24 | 24 | * @author Juergen Knoedlseder |
| 25 | 25 | */ |
| 26 | 26 | |
| ... | ... | @@ -53,30 +53,31 @@ class GPhoton : public GBase { |
| 53 | 53 | public: |
| 54 | 54 | // Constructors and destructors |
| 55 | 55 | GPhoton(void); |
| 56 | - explicit GPhoton(const GSkyDir& dir, const GEnergy& energy, const GTime& time); | |
| 57 | - GPhoton(const GPhoton& ph); | |
| 56 | + GPhoton(const GSkyDir& dir, const GEnergy& energy, const GTime& time, | |
| 57 | + const int& mcid = -1); | |
| 58 | + GPhoton(const GPhoton& photon); | |
| 58 | 59 | virtual ~GPhoton(void); |
| 59 | 60 | |
| 60 | 61 | // Operators |
| 61 | - GPhoton& operator=(const GPhoton& ph); | |
| 62 | + GPhoton& operator=(const GPhoton& photon); | |
| 62 | 63 | |
| 63 | 64 | // Methods |
| 64 | 65 | void clear(void); |
| 65 | 66 | GPhoton* clone(void) const; |
| 66 | - const GSkyDir& dir(void) const { return m_dir; } | |
| 67 | - const GEnergy& energy(void) const { return m_energy; } | |
| 68 | - const GTime& time(void) const { return m_time; } | |
| 69 | - const int& mcid(void) const { return m_mc_id; } | |
| 70 | - void dir(const GSkyDir& dir) { m_dir=dir; } | |
| 71 | - void energy(const GEnergy& energy) { m_energy=energy; } | |
| 72 | - void time(const GTime& time) { m_time=time; } | |
| 73 | - void mcid(const int& mcid) { m_mc_id=mcid; } | |
| 67 | + const GSkyDir& dir(void) const; | |
| 68 | + const GEnergy& energy(void) const; | |
| 69 | + const GTime& time(void) const; | |
| 70 | + const int& mcid(void) const; | |
| 71 | + void dir(const GSkyDir& dir); | |
| 72 | + void energy(const GEnergy& energy); | |
| 73 | + void time(const GTime& time); | |
| 74 | + void mcid(const int& mcid); | |
| 74 | 75 | std::string print(const GChatter& chatter = NORMAL) const; |
| 75 | 76 | |
| 76 | 77 | protected: |
| 77 | 78 | // Protected methods |
| 78 | 79 | void init_members(void); |
| 79 | - void copy_members(const GPhoton& ph); | |
| 80 | + void copy_members(const GPhoton& photon); | |
| 80 | 81 | void free_members(void); |
| 81 | 82 | |
| 82 | 83 | // Protected data members |
| ... | ... | @@ -87,17 +88,130 @@ protected: |
| 87 | 88 | }; |
| 88 | 89 | |
| 89 | 90 | |
| 90 | -/*************************************************************************** | |
| 91 | - * Inline friends * | |
| 91 | +/***********************************************************************//** | |
| 92 | + * @brief Return photon sky direction | |
| 93 | + * | |
| 94 | + * @return Sky direction of photon. | |
| 95 | + ***************************************************************************/ | |
| 96 | +inline | |
| 97 | +const GSkyDir& GPhoton::dir(void) const | |
| 98 | +{ | |
| 99 | + return m_dir; | |
| 100 | +} | |
| 101 | + | |
| 102 | + | |
| 103 | +/***********************************************************************//** | |
| 104 | + * @brief Return photon energy | |
| 105 | + * | |
| 106 | + * @return Energy of photon. | |
| 107 | + ***************************************************************************/ | |
| 108 | +inline | |
| 109 | +const GEnergy& GPhoton::energy(void) const | |
| 110 | +{ | |
| 111 | + return m_energy; | |
| 112 | +} | |
| 113 | + | |
| 114 | + | |
| 115 | +/***********************************************************************//** | |
| 116 | + * @brief Return photon time | |
| 117 | + * | |
| 118 | + * @return Time of photon. | |
| 119 | + ***************************************************************************/ | |
| 120 | +inline | |
| 121 | +const GTime& GPhoton::time(void) const | |
| 122 | +{ | |
| 123 | + return m_time; | |
| 124 | +} | |
| 125 | + | |
| 126 | + | |
| 127 | +/***********************************************************************//** | |
| 128 | + * @brief Return photon Monte-Carlo identifier | |
| 129 | + * | |
| 130 | + * @return Photon Monte-Carlo identifier. | |
| 131 | + ***************************************************************************/ | |
| 132 | +inline | |
| 133 | +const int& GPhoton::mcid(void) const | |
| 134 | +{ | |
| 135 | + return m_mc_id; | |
| 136 | +} | |
| 137 | + | |
| 138 | + | |
| 139 | +/***********************************************************************//** | |
| 140 | + * @brief Set photon sky direction | |
| 141 | + * | |
| 142 | + * @param[in] dir Sky direction of photon. | |
| 143 | + ***************************************************************************/ | |
| 144 | +inline | |
| 145 | +void GPhoton::dir(const GSkyDir& dir) | |
| 146 | +{ | |
| 147 | + m_dir = dir; | |
| 148 | + return; | |
| 149 | +} | |
| 150 | + | |
| 151 | + | |
| 152 | +/***********************************************************************//** | |
| 153 | + * @brief Set photon energy | |
| 154 | + * | |
| 155 | + * @param[in] energy Photon energy. | |
| 156 | + ***************************************************************************/ | |
| 157 | +inline | |
| 158 | +void GPhoton::energy(const GEnergy& energy) | |
| 159 | +{ | |
| 160 | + m_energy = energy; | |
| 161 | + return; | |
| 162 | +} | |
| 163 | + | |
| 164 | + | |
| 165 | +/***********************************************************************//** | |
| 166 | + * @brief Set photon time | |
| 167 | + * | |
| 168 | + * @param[in] time Photon time. | |
| 169 | + ***************************************************************************/ | |
| 170 | +inline | |
| 171 | +void GPhoton::time(const GTime& time) | |
| 172 | +{ | |
| 173 | + m_time = time; | |
| 174 | + return; | |
| 175 | +} | |
| 176 | + | |
| 177 | + | |
| 178 | +/***********************************************************************//** | |
| 179 | + * @brief Set photon Monte-Carlo identifier | |
| 180 | + * | |
| 181 | + * @param[in] mcid Photon Monte-Carlo identifier. | |
| 182 | + ***************************************************************************/ | |
| 183 | +inline | |
| 184 | +void GPhoton::mcid(const int& mcid) | |
| 185 | +{ | |
| 186 | + m_mc_id = mcid; | |
| 187 | + return; | |
| 188 | +} | |
| 189 | + | |
| 190 | + | |
| 191 | +/***********************************************************************//** | |
| 192 | + * @brief Equality friend operator | |
| 193 | + * | |
| 194 | + * @param[in] a First photon. | |
| 195 | + * @param[in] b Second photon. | |
| 196 | + * @return True is first photon is identical to second photon | |
| 92 | 197 | ***************************************************************************/ |
| 93 | 198 | inline |
| 94 | -bool operator== (const GPhoton &a, const GPhoton &b) | |
| 199 | +bool operator==(const GPhoton &a, const GPhoton &b) | |
| 95 | 200 | { |
| 96 | 201 | return (a.m_energy == b.m_energy && a.m_time == b.m_time && |
| 97 | 202 | a.m_dir.dist(b.m_dir) == 0.0); |
| 98 | 203 | } |
| 204 | + | |
| 205 | + | |
| 206 | +/***********************************************************************//** | |
| 207 | + * @brief Non-equality friend operator | |
| 208 | + * | |
| 209 | + * @param[in] a First photon. | |
| 210 | + * @param[in] b Second photon. | |
| 211 | + * @return True is first photon is not identical to second photon | |
| 212 | + ***************************************************************************/ | |
| 99 | 213 | inline |
| 100 | -bool operator!= (const GPhoton &a, const GPhoton &b) | |
| 214 | +bool operator!=(const GPhoton &a, const GPhoton &b) | |
| 101 | 215 | { |
| 102 | 216 | return (a.m_energy != b.m_energy || a.m_time != b.m_time || |
| 103 | 217 | a.m_dir.dist(b.m_dir) > 0.0); | ... | ... |
include/GTime.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GTime.hpp - Time class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -52,17 +52,17 @@ |
| 52 | 52 | class GTime : public GBase { |
| 53 | 53 | |
| 54 | 54 | // Operator friends |
| 55 | - friend GTime operator+ (const GTime &a, const GTime &b); | |
| 56 | - friend GTime operator- (const GTime &a, const GTime &b); | |
| 57 | - friend GTime operator* (const double &a, const GTime &b); | |
| 58 | - friend GTime operator* (const GTime &a, const double &b); | |
| 59 | - friend GTime operator/ (const GTime &a, const double &b); | |
| 60 | - friend bool operator== (const GTime &a, const GTime &b); | |
| 61 | - friend bool operator!= (const GTime &a, const GTime &b); | |
| 62 | - friend bool operator< (const GTime &a, const GTime &b); | |
| 63 | - friend bool operator<= (const GTime &a, const GTime &b); | |
| 64 | - friend bool operator> (const GTime &a, const GTime &b); | |
| 65 | - friend bool operator>= (const GTime &a, const GTime &b); | |
| 55 | + friend GTime operator+(const GTime &a, const GTime &b); | |
| 56 | + friend GTime operator-(const GTime &a, const GTime &b); | |
| 57 | + friend GTime operator*(const double &s, const GTime &time); | |
| 58 | + friend GTime operator* (const GTime &time, const double &s); | |
| 59 | + friend GTime operator/(const GTime &time, const double &s); | |
| 60 | + friend bool operator==(const GTime &a, const GTime &b); | |
| 61 | + friend bool operator!=(const GTime &a, const GTime &b); | |
| 62 | + friend bool operator<(const GTime &a, const GTime &b); | |
| 63 | + friend bool operator<=(const GTime &a, const GTime &b); | |
| 64 | + friend bool operator>(const GTime &a, const GTime &b); | |
| 65 | + friend bool operator>=(const GTime &a, const GTime &b); | |
| 66 | 66 | |
| 67 | 67 | public: |
| 68 | 68 | // Constructors and destructors |
| ... | ... | @@ -80,7 +80,7 @@ public: |
| 80 | 80 | GTime* clone(void) const; |
| 81 | 81 | double jd(void) const; |
| 82 | 82 | double mjd(void) const; |
| 83 | - double secs(void) const; | |
| 83 | + const double& secs(void) const; | |
| 84 | 84 | double days(void) const; |
| 85 | 85 | double convert(const GTimeReference& ref) const; |
| 86 | 86 | void jd(const double& time); |
| ... | ... | @@ -102,71 +102,190 @@ protected: |
| 102 | 102 | }; |
| 103 | 103 | |
| 104 | 104 | |
| 105 | -/*************************************************************************** | |
| 106 | - * Inline friends * | |
| 105 | +/***********************************************************************//** | |
| 106 | + * @brief Return time in native reference (TT) (unit: seconds) | |
| 107 | + * | |
| 108 | + * @return Time in native reference [seconds]. | |
| 109 | + ***************************************************************************/ | |
| 110 | +inline | |
| 111 | +const double& GTime::secs(void) const | |
| 112 | +{ | |
| 113 | + return m_time; | |
| 114 | +} | |
| 115 | + | |
| 116 | + | |
| 117 | +/***********************************************************************//** | |
| 118 | + * @brief Set time in native reference in seconds (TT) | |
| 119 | + * | |
| 120 | + * @param[in] seconds Time (TT) [seconds]. | |
| 107 | 121 | ***************************************************************************/ |
| 108 | 122 | inline |
| 109 | -GTime operator+ (const GTime& a, const GTime& b) | |
| 123 | +void GTime::secs(const double& seconds) | |
| 124 | +{ | |
| 125 | + m_time = seconds; | |
| 126 | + return; | |
| 127 | +} | |
| 128 | + | |
| 129 | + | |
| 130 | +/***********************************************************************//** | |
| 131 | + * @brief Time addition operator friend | |
| 132 | + * | |
| 133 | + * @param[in] a First time. | |
| 134 | + * @param[in] b Second time. | |
| 135 | + * @return Added time. | |
| 136 | + ***************************************************************************/ | |
| 137 | +inline | |
| 138 | +GTime operator+(const GTime& a, const GTime& b) | |
| 110 | 139 | { |
| 111 | 140 | GTime result; |
| 112 | 141 | result.m_time = a.m_time + b.m_time; |
| 113 | 142 | return result; |
| 114 | 143 | } |
| 144 | + | |
| 145 | + | |
| 146 | +/***********************************************************************//** | |
| 147 | + * @brief Time subtraction operator friend | |
| 148 | + * | |
| 149 | + * @param[in] a First time. | |
| 150 | + * @param[in] b Second time. | |
| 151 | + * @return Subtracted time. | |
| 152 | + ***************************************************************************/ | |
| 115 | 153 | inline |
| 116 | -GTime operator- (const GTime& a, const GTime& b) | |
| 154 | +GTime operator-(const GTime& a, const GTime& b) | |
| 117 | 155 | { |
| 118 | 156 | GTime result; |
| 119 | 157 | result.m_time = a.m_time - b.m_time; |
| 120 | 158 | return result; |
| 121 | 159 | } |
| 160 | + | |
| 161 | + | |
| 162 | +/***********************************************************************//** | |
| 163 | + * @brief Time multiplication operator friend | |
| 164 | + * | |
| 165 | + * @param[in] s Multiplier. | |
| 166 | + * @param[in] time Time. | |
| 167 | + * @return Multiplied time. | |
| 168 | + ***************************************************************************/ | |
| 122 | 169 | inline |
| 123 | -GTime operator* (const double& a, const GTime& b) | |
| 170 | +GTime operator*(const double& s, const GTime& time) | |
| 124 | 171 | { |
| 125 | 172 | GTime result; |
| 126 | - result.m_time = a * b.m_time; | |
| 173 | + result.m_time = s * time.m_time; | |
| 127 | 174 | return result; |
| 128 | 175 | } |
| 176 | + | |
| 177 | + | |
| 178 | +/***********************************************************************//** | |
| 179 | + * @brief Time multiplication operator friend | |
| 180 | + * | |
| 181 | + * @param[in] time Time. | |
| 182 | + * @param[in] s Multiplier. | |
| 183 | + * @return Multiplied time. | |
| 184 | + ***************************************************************************/ | |
| 129 | 185 | inline |
| 130 | -GTime operator* (const GTime& a, const double& b) | |
| 186 | +GTime operator* (const GTime& time, const double& s) | |
| 131 | 187 | { |
| 132 | 188 | GTime result; |
| 133 | - result.m_time = b * a.m_time; | |
| 189 | + result.m_time = s * time.m_time; | |
| 134 | 190 | return result; |
| 135 | 191 | } |
| 192 | + | |
| 193 | + | |
| 194 | +/***********************************************************************//** | |
| 195 | + * @brief Time division operator friend | |
| 196 | + * | |
| 197 | + * @param[in] time Time. | |
| 198 | + * @param[in] s Divider. | |
| 199 | + * @return Divided time. | |
| 200 | + ***************************************************************************/ | |
| 136 | 201 | inline |
| 137 | -GTime operator/ (const GTime& a, const double& b) | |
| 202 | +GTime operator/(const GTime& time, const double& s) | |
| 138 | 203 | { |
| 139 | 204 | GTime result; |
| 140 | - result.m_time = a.m_time / b; | |
| 205 | + result.m_time = time.m_time / s; | |
| 141 | 206 | return result; |
| 142 | 207 | } |
| 208 | + | |
| 209 | + | |
| 210 | +/***********************************************************************//** | |
| 211 | + * @brief Time equality operator friend | |
| 212 | + * | |
| 213 | + * @param[in] a First time. | |
| 214 | + * @param[in] b Second time. | |
| 215 | + * @return True if @p a equals @p b. | |
| 216 | + ***************************************************************************/ | |
| 143 | 217 | inline |
| 144 | -bool operator== (const GTime &a, const GTime &b) | |
| 218 | +bool operator==(const GTime &a, const GTime &b) | |
| 145 | 219 | { |
| 146 | 220 | return (a.m_time == b.m_time); |
| 147 | 221 | } |
| 222 | + | |
| 223 | + | |
| 224 | +/***********************************************************************//** | |
| 225 | + * @brief Time non-equality operator friend | |
| 226 | + * | |
| 227 | + * @param[in] a First time. | |
| 228 | + * @param[in] b Second time. | |
| 229 | + * @return True if @p a is not equal to @p b. | |
| 230 | + ***************************************************************************/ | |
| 148 | 231 | inline |
| 149 | -bool operator!= (const GTime &a, const GTime &b) | |
| 232 | +bool operator!=(const GTime &a, const GTime &b) | |
| 150 | 233 | { |
| 151 | 234 | return (a.m_time != b.m_time); |
| 152 | 235 | } |
| 236 | + | |
| 237 | + | |
| 238 | +/***********************************************************************//** | |
| 239 | + * @brief Time smaller than operator friend | |
| 240 | + * | |
| 241 | + * @param[in] a First time. | |
| 242 | + * @param[in] b Second time. | |
| 243 | + * @return True if @p a is smaller than @p b. | |
| 244 | + ***************************************************************************/ | |
| 153 | 245 | inline |
| 154 | -bool operator< (const GTime &a, const GTime &b) | |
| 246 | +bool operator<(const GTime &a, const GTime &b) | |
| 155 | 247 | { |
| 156 | 248 | return (a.m_time < b.m_time); |
| 157 | 249 | } |
| 250 | + | |
| 251 | + | |
| 252 | +/***********************************************************************//** | |
| 253 | + * @brief Time smaller than or equal operator friend | |
| 254 | + * | |
| 255 | + * @param[in] a First time. | |
| 256 | + * @param[in] b Second time. | |
| 257 | + * @return True if @p a is smaller than or equal to @p b. | |
| 258 | + ***************************************************************************/ | |
| 158 | 259 | inline |
| 159 | -bool operator<= (const GTime &a, const GTime &b) | |
| 260 | +bool operator<=(const GTime &a, const GTime &b) | |
| 160 | 261 | { |
| 161 | 262 | return (a.m_time <= b.m_time); |
| 162 | 263 | } |
| 264 | + | |
| 265 | + | |
| 266 | +/***********************************************************************//** | |
| 267 | + * @brief Time larger than operator friend | |
| 268 | + * | |
| 269 | + * @param[in] a First time. | |
| 270 | + * @param[in] b Second time. | |
| 271 | + * @return True if @p a is larger than @p b. | |
| 272 | + ***************************************************************************/ | |
| 163 | 273 | inline |
| 164 | -bool operator> (const GTime &a, const GTime &b) | |
| 274 | +bool operator>(const GTime &a, const GTime &b) | |
| 165 | 275 | { |
| 166 | 276 | return (a.m_time > b.m_time); |
| 167 | 277 | } |
| 278 | + | |
| 279 | + | |
| 280 | +/***********************************************************************//** | |
| 281 | + * @brief Time larger than or equal operator friend | |
| 282 | + * | |
| 283 | + * @param[in] a First time. | |
| 284 | + * @param[in] b Second time. | |
| 285 | + * @return True if @p a is larger than or equal to @p b. | |
| 286 | + ***************************************************************************/ | |
| 168 | 287 | inline |
| 169 | -bool operator>= (const GTime &a, const GTime &b) | |
| 288 | +bool operator>=(const GTime &a, const GTime &b) | |
| 170 | 289 | { |
| 171 | 290 | return (a.m_time >= b.m_time); |
| 172 | 291 | } | ... | ... |
include/GTimeReference.hpp
| ... | ... | @@ -65,7 +65,7 @@ public: |
| 65 | 65 | const std::string& timeunit, |
| 66 | 66 | const std::string& timesys = "TT", |
| 67 | 67 | const std::string& timeref = "LOCAL"); |
| 68 | - explicit GTimeReference(const GFitsHDU* hdu); | |
| 68 | + explicit GTimeReference(const GFitsHDU& hdu); | |
| 69 | 69 | virtual ~GTimeReference(void); |
| 70 | 70 | |
| 71 | 71 | // Operators |
| ... | ... | @@ -74,8 +74,8 @@ public: |
| 74 | 74 | // Methods |
| 75 | 75 | void clear(void); |
| 76 | 76 | GTimeReference* clone(void) const; |
| 77 | - void read(const GFitsHDU* hdu); | |
| 78 | - void write(GFitsHDU* hdu) const; | |
| 77 | + void read(const GFitsHDU& hdu); | |
| 78 | + void write(GFitsHDU& hdu) const; | |
| 79 | 79 | void set(const double& mrdref, |
| 80 | 80 | const std::string& timeunit, |
| 81 | 81 | const std::string& timesys = "TT", | ... | ... |
inst/cta/src/GCTAEventCube.cpp
| ... | ... | @@ -399,10 +399,10 @@ void GCTAEventCube::write(GFits& fits) const |
| 399 | 399 | m_map.write(&fits); |
| 400 | 400 | |
| 401 | 401 | // Write energy boundaries |
| 402 | - ebounds().write(&fits); | |
| 402 | + ebounds().write(fits); | |
| 403 | 403 | |
| 404 | 404 | // Write Good Time intervals |
| 405 | - gti().write(&fits); | |
| 405 | + gti().write(fits); | |
| 406 | 406 | |
| 407 | 407 | // Return |
| 408 | 408 | return; |
| ... | ... | @@ -601,7 +601,7 @@ void GCTAEventCube::read_ebds(const GFitsTable* hdu) |
| 601 | 601 | if (hdu != NULL) { |
| 602 | 602 | |
| 603 | 603 | // Read energy boundaries |
| 604 | - m_ebounds.read(const_cast<GFitsTable*>(hdu)); | |
| 604 | + m_ebounds.read(*hdu); | |
| 605 | 605 | |
| 606 | 606 | // Set log mean energies and energy widths |
| 607 | 607 | set_energies(); |
| ... | ... | @@ -619,8 +619,6 @@ void GCTAEventCube::read_ebds(const GFitsTable* hdu) |
| 619 | 619 | * @param[in] hdu Pointer to GTI table. |
| 620 | 620 | * |
| 621 | 621 | * Reads the Good Time Intervals from the GTI extension. |
| 622 | - * | |
| 623 | - * @todo GTI read method should take const GFitsTable* as argument | |
| 624 | 622 | ***************************************************************************/ |
| 625 | 623 | void GCTAEventCube::read_gti(const GFitsTable* hdu) |
| 626 | 624 | { |
| ... | ... | @@ -628,7 +626,7 @@ void GCTAEventCube::read_gti(const GFitsTable* hdu) |
| 628 | 626 | if (hdu != NULL) { |
| 629 | 627 | |
| 630 | 628 | // Read Good Time Intervals |
| 631 | - m_gti.read(const_cast<GFitsTable*>(hdu)); | |
| 629 | + m_gti.read(*hdu); | |
| 632 | 630 | |
| 633 | 631 | // Set times |
| 634 | 632 | set_times(); | ... | ... |
inst/cta/src/GCTAEventList.cpp
| ... | ... | @@ -309,12 +309,12 @@ void GCTAEventList::read(const GFits& fits) |
| 309 | 309 | clear(); |
| 310 | 310 | |
| 311 | 311 | // Get event list HDU |
| 312 | - const GFitsTable* events = fits.table("EVENTS"); | |
| 312 | + const GFitsTable& events = *fits.table("EVENTS"); | |
| 313 | 313 | |
| 314 | 314 | // If we have a GTI extension, then read Good Time Intervals from that |
| 315 | 315 | // extension |
| 316 | 316 | if (fits.contains("GTI")) { |
| 317 | - const GFitsTable* gti = fits.table("GTI"); | |
| 317 | + const GFitsTable& gti = *fits.table("GTI"); | |
| 318 | 318 | m_gti.read(gti); |
| 319 | 319 | } |
| 320 | 320 | |
| ... | ... | @@ -322,8 +322,8 @@ void GCTAEventList::read(const GFits& fits) |
| 322 | 322 | else { |
| 323 | 323 | |
| 324 | 324 | // Read start and stop time |
| 325 | - double tstart = events->real("TSTART"); | |
| 326 | - double tstop = events->real("TSTOP"); | |
| 325 | + double tstart = events.real("TSTART"); | |
| 326 | + double tstop = events.real("TSTOP"); | |
| 327 | 327 | |
| 328 | 328 | // Create time reference from header information |
| 329 | 329 | GTimeReference timeref(events); |
| ... | ... | @@ -341,13 +341,13 @@ void GCTAEventList::read(const GFits& fits) |
| 341 | 341 | } // endelse: GTI built from TSTART and TSTOP |
| 342 | 342 | |
| 343 | 343 | // Load event data |
| 344 | - read_events(events); | |
| 344 | + read_events(&events); | |
| 345 | 345 | |
| 346 | 346 | // Read region of interest from data selection keyword |
| 347 | - read_ds_roi(events); | |
| 347 | + read_ds_roi(&events); | |
| 348 | 348 | |
| 349 | 349 | // Read energy boundaries from data selection keyword |
| 350 | - read_ds_ebounds(events); | |
| 350 | + read_ds_ebounds(&events); | |
| 351 | 351 | |
| 352 | 352 | // Return |
| 353 | 353 | return; |
| ... | ... | @@ -382,7 +382,7 @@ void GCTAEventList::write(GFits& file) const |
| 382 | 382 | delete events; |
| 383 | 383 | |
| 384 | 384 | // Append GTI to FITS file |
| 385 | - gti().write(&file); | |
| 385 | + gti().write(file); | |
| 386 | 386 | |
| 387 | 387 | // Return |
| 388 | 388 | return; | ... | ... |
inst/cta/src/GCTAObservation.cpp
| ... | ... | @@ -1052,7 +1052,7 @@ void GCTAObservation::write_attributes(GFitsHDU* hdu) const |
| 1052 | 1052 | // Set observation time information |
| 1053 | 1053 | hdu->card("TSTART", tstart, "[s] Mission time of start of observation"); |
| 1054 | 1054 | hdu->card("TSTOP", tstop, "[s] Mission time of end of observation"); |
| 1055 | - timeref.write(hdu); | |
| 1055 | + timeref.write(*hdu); | |
| 1056 | 1056 | hdu->card("TELAPSE", telapse, "[s] Mission elapsed time"); |
| 1057 | 1057 | hdu->card("ONTIME", ontime, "[s] Total good time including deadtime"); |
| 1058 | 1058 | hdu->card("LIVETIME", livetime(), "[s] Total livetime"); | ... | ... |
inst/lat/src/GLATEventCube.cpp
| ... | ... | @@ -773,7 +773,7 @@ void GLATEventCube::read_ebds(const GFitsTable* hdu) |
| 773 | 773 | if (hdu != NULL) { |
| 774 | 774 | |
| 775 | 775 | // Read energy boundaries |
| 776 | - m_ebounds.read(const_cast<GFitsTable*>(hdu)); | |
| 776 | + m_ebounds.read(*hdu); | |
| 777 | 777 | |
| 778 | 778 | // Set log mean energies and energy widths |
| 779 | 779 | set_energies(); |
| ... | ... | @@ -800,7 +800,7 @@ void GLATEventCube::read_gti(const GFitsTable* hdu) |
| 800 | 800 | if (hdu != NULL) { |
| 801 | 801 | |
| 802 | 802 | // Read Good Time Intervals |
| 803 | - m_gti.read(const_cast<GFitsTable*>(hdu)); | |
| 803 | + m_gti.read(*hdu); | |
| 804 | 804 | |
| 805 | 805 | // Set time |
| 806 | 806 | set_times(); | ... | ... |
inst/lat/src/GLATEventList.cpp
| ... | ... | @@ -276,33 +276,28 @@ void GLATEventList::read(const GFits& file) |
| 276 | 276 | // Clear object |
| 277 | 277 | clear(); |
| 278 | 278 | |
| 279 | - // Get HDU | |
| 280 | - const GFitsTable* hdu = file.table("EVENTS"); | |
| 279 | + // Get HDU (pointer is always valid) | |
| 280 | + const GFitsTable& hdu = *file.table("EVENTS"); | |
| 281 | 281 | |
| 282 | - // Continue only if event HDU is valid | |
| 283 | - if (hdu != NULL) { | |
| 282 | + // Read event data | |
| 283 | + read_events(hdu); | |
| 284 | 284 | |
| 285 | - // Read event data | |
| 286 | - read_events(*hdu); | |
| 287 | - | |
| 288 | - // Read data selection keywords | |
| 289 | - read_ds_keys(*hdu); | |
| 290 | - | |
| 291 | - } // endif: HDU was valid | |
| 285 | + // Read data selection keywords | |
| 286 | + read_ds_keys(hdu); | |
| 292 | 287 | |
| 293 | 288 | // If we have a GTI extension, then read Good Time Intervals from that |
| 294 | 289 | // extension |
| 295 | 290 | if (file.contains("GTI")) { |
| 296 | - const GFitsTable* gti = file.table("GTI"); | |
| 291 | + const GFitsTable& gti = *file.table("GTI"); | |
| 297 | 292 | m_gti.read(gti); |
| 298 | 293 | } |
| 299 | 294 | |
| 300 | 295 | // ... otherwise build GTI from TSTART and TSTOP |
| 301 | - else if (hdu != NULL) { | |
| 296 | + else { | |
| 302 | 297 | |
| 303 | 298 | // Read start and stop time |
| 304 | - double tstart = hdu->real("TSTART"); | |
| 305 | - double tstop = hdu->real("TSTOP"); | |
| 299 | + double tstart = hdu.real("TSTART"); | |
| 300 | + double tstop = hdu.real("TSTOP"); | |
| 306 | 301 | |
| 307 | 302 | // Create time reference from header information |
| 308 | 303 | GTimeReference timeref(hdu); | ... | ... |
inst/lat/src/GLATLtCube.cpp
pyext/GEbounds.i
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | * |
| 36 | 36 | * @brief Energy boundaries container class |
| 37 | 37 | ***************************************************************************/ |
| 38 | -class GEbounds : public GBase { | |
| 38 | +class GEbounds : public GContainer { | |
| 39 | 39 | public: |
| 40 | 40 | // Constructors and destructors |
| 41 | 41 | GEbounds(void); |
| ... | ... | @@ -46,34 +46,35 @@ public: |
| 46 | 46 | virtual ~GEbounds(void); |
| 47 | 47 | |
| 48 | 48 | // Methods |
| 49 | - void clear(void); | |
| 50 | - GEbounds* clone(void) const; | |
| 51 | - int size(void) const; | |
| 52 | - bool isempty(void) const; | |
| 53 | - void append(const GEnergy& emin, const GEnergy& emax); | |
| 54 | - void insert(const GEnergy& emin, const GEnergy& emax); | |
| 55 | - void merge(void); | |
| 56 | - void merge(const GEnergy& emin, const GEnergy& emax); | |
| 57 | - void remove(const int& index); | |
| 58 | - void reserve(const int& num); | |
| 59 | - void extend(const GEbounds& ebds); | |
| 60 | - void setlin(const int& num, const GEnergy& emin, const GEnergy& emax); | |
| 61 | - void setlog(const int& num, const GEnergy& emin, const GEnergy& emax); | |
| 62 | - void load(const std::string& filename, | |
| 63 | - const std::string& extname = "EBOUNDS"); | |
| 64 | - void save(const std::string& filename, bool clobber, | |
| 65 | - const std::string& extname = "EBOUNDS") const; | |
| 66 | - void read(GFitsTable* hdu); | |
| 67 | - void write(GFits* file, const std::string& extname = "EBOUNDS") const; | |
| 68 | - int index(const GEnergy& eng) const; | |
| 69 | - GEnergy emin(void) const; | |
| 70 | - GEnergy emax(void) const; | |
| 71 | - GEnergy emin(const int& index) const; | |
| 72 | - GEnergy emax(const int& index) const; | |
| 73 | - GEnergy emean(const int& index) const; | |
| 74 | - GEnergy elogmean(const int& index) const; | |
| 75 | - GEnergy ewidth(const int& index) const; | |
| 76 | - bool contains(const GEnergy& eng) const; | |
| 49 | + void clear(void); | |
| 50 | + GEbounds* clone(void) const; | |
| 51 | + int size(void) const; | |
| 52 | + bool isempty(void) const; | |
| 53 | + void append(const GEnergy& emin, const GEnergy& emax); | |
| 54 | + void insert(const GEnergy& emin, const GEnergy& emax); | |
| 55 | + void merge(void); | |
| 56 | + void merge(const GEnergy& emin, const GEnergy& emax); | |
| 57 | + void remove(const int& index); | |
| 58 | + void reserve(const int& num); | |
| 59 | + void extend(const GEbounds& ebds); | |
| 60 | + void setlin(const int& num, const GEnergy& emin, const GEnergy& emax); | |
| 61 | + void setlog(const int& num, const GEnergy& emin, const GEnergy& emax); | |
| 62 | + void load(const std::string& filename, | |
| 63 | + const std::string& extname = "EBOUNDS"); | |
| 64 | + void save(const std::string& filename, | |
| 65 | + const bool& clobber = false, | |
| 66 | + const std::string& extname = "EBOUNDS") const; | |
| 67 | + void read(const GFitsTable& table); | |
| 68 | + void write(GFits& file, const std::string& extname = "EBOUNDS") const; | |
| 69 | + int index(const GEnergy& eng) const; | |
| 70 | + const GEnergy& emin(void) const; | |
| 71 | + const GEnergy& emax(void) const; | |
| 72 | + GEnergy emin(const int& index) const; | |
| 73 | + GEnergy emax(const int& index) const; | |
| 74 | + GEnergy emean(const int& index) const; | |
| 75 | + GEnergy elogmean(const int& index) const; | |
| 76 | + GEnergy ewidth(const int& index) const; | |
| 77 | + bool contains(const GEnergy& eng) const; | |
| 77 | 78 | }; |
| 78 | 79 | |
| 79 | 80 | |
| ... | ... | @@ -81,9 +82,6 @@ public: |
| 81 | 82 | * @brief GEbounds class extension |
| 82 | 83 | ***************************************************************************/ |
| 83 | 84 | %extend GEbounds { |
| 84 | - int __len__() { | |
| 85 | - return (self->size()); | |
| 86 | - } | |
| 87 | 85 | GEbounds copy() { |
| 88 | 86 | return (*self); |
| 89 | 87 | } | ... | ... |
pyext/GGti.i
| ... | ... | @@ -58,10 +58,11 @@ public: |
| 58 | 58 | void extend(const GGti& gti); |
| 59 | 59 | void load(const std::string& filename, |
| 60 | 60 | const std::string& extname = "GTI"); |
| 61 | - void save(const std::string& filename, bool clobber, | |
| 61 | + void save(const std::string& filename, | |
| 62 | + const bool& clobber = false, | |
| 62 | 63 | const std::string& extname = "GTI") const; |
| 63 | - void read(const GFitsTable* hdu); | |
| 64 | - void write(GFits* file, | |
| 64 | + void read(const GFitsTable& table); | |
| 65 | + void write(GFits& file, | |
| 65 | 66 | const std::string& extname = "GTI") const; |
| 66 | 67 | const GTime& tstart(void) const; |
| 67 | 68 | const GTime& tstop(void) const; | ... | ... |
pyext/GPhoton.i
| ... | ... | @@ -20,13 +20,12 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GPhoton.i |
| 23 | - * @brief GPhoton class python interface | |
| 23 | + * @brief Photon class definition | |
| 24 | 24 | * @author Juergen Knoedlseder |
| 25 | 25 | */ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| 28 | 28 | #include "GPhoton.hpp" |
| 29 | -#include "GTools.hpp" | |
| 30 | 29 | %} |
| 31 | 30 | |
| 32 | 31 | |
| ... | ... | @@ -43,8 +42,9 @@ class GPhoton : public GBase { |
| 43 | 42 | public: |
| 44 | 43 | // Constructors and destructors |
| 45 | 44 | GPhoton(void); |
| 46 | - explicit GPhoton(const GSkyDir& dir, const GEnergy& energy, const GTime& time); | |
| 47 | - GPhoton(const GPhoton& ph); | |
| 45 | + GPhoton(const GSkyDir& dir, const GEnergy& energy, const GTime& time, | |
| 46 | + const int& mcid = -1); | |
| 47 | + GPhoton(const GPhoton& photon); | |
| 48 | 48 | virtual ~GPhoton(void); |
| 49 | 49 | |
| 50 | 50 | // Methods |
| ... | ... | @@ -65,11 +65,11 @@ public: |
| 65 | 65 | * @brief GPhoton class extension |
| 66 | 66 | ***************************************************************************/ |
| 67 | 67 | %extend GPhoton { |
| 68 | - bool __eq__(const GPhoton& ph) const { | |
| 69 | - return ((*self) == ph); | |
| 68 | + bool __eq__(const GPhoton& photon) const { | |
| 69 | + return ((*self) == photon); | |
| 70 | 70 | } |
| 71 | - bool __ne__(const GPhoton& ph) const { | |
| 72 | - return ((*self) != ph); | |
| 71 | + bool __ne__(const GPhoton& photon) const { | |
| 72 | + return ((*self) != photon); | |
| 73 | 73 | } |
| 74 | 74 | GPhoton copy() { |
| 75 | 75 | return (*self); | ... | ... |
pyext/GTime.i
| ... | ... | @@ -26,7 +26,6 @@ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| 28 | 28 | #include "GTime.hpp" |
| 29 | -#include "GTools.hpp" | |
| 30 | 29 | %} |
| 31 | 30 | |
| 32 | 31 | |
| ... | ... | @@ -53,7 +52,7 @@ public: |
| 53 | 52 | GTime* clone(void) const; |
| 54 | 53 | double jd(void) const; |
| 55 | 54 | double mjd(void) const; |
| 56 | - double secs(void) const; | |
| 55 | + const double& secs(void) const; | |
| 57 | 56 | double days(void) const; |
| 58 | 57 | double convert(const GTimeReference& ref) const; |
| 59 | 58 | void jd(const double& time); | ... | ... |
pyext/GTimeReference.i
| ... | ... | @@ -49,14 +49,14 @@ public: |
| 49 | 49 | const std::string& timeunit, |
| 50 | 50 | const std::string& timesys = "TT", |
| 51 | 51 | const std::string& timeref = "local"); |
| 52 | - explicit GTimeReference(const GFitsHDU* hdu); | |
| 52 | + explicit GTimeReference(const GFitsHDU& hdu); | |
| 53 | 53 | virtual ~GTimeReference(void); |
| 54 | 54 | |
| 55 | 55 | // Methods |
| 56 | 56 | void clear(void); |
| 57 | 57 | GTimeReference* clone(void) const; |
| 58 | - void read(const GFitsHDU* hdu); | |
| 59 | - void write(GFitsHDU* hdu) const; | |
| 58 | + void read(const GFitsHDU& hdu); | |
| 59 | + void write(GFitsHDU& hdu) const; | |
| 60 | 60 | void set(const double& mrdref, |
| 61 | 61 | const std::string& timeunit, |
| 62 | 62 | const std::string& timesys = "TT", | ... | ... |
src/obs/GEbounds.cpp
| ... | ... | @@ -560,11 +560,11 @@ void GEbounds::load(const std::string& filename, const std::string& extname) |
| 560 | 560 | // Open FITS file |
| 561 | 561 | file.open(filename); |
| 562 | 562 | |
| 563 | - // Get energy boundary HDU | |
| 564 | - GFitsTable* hdu = file.table(extname); | |
| 563 | + // Get energy boundary table | |
| 564 | + const GFitsTable& table = *file.table(extname); | |
| 565 | 565 | |
| 566 | - // Read energy boundaries from HDU | |
| 567 | - read(hdu); | |
| 566 | + // Read energy boundaries from table | |
| 567 | + read(table); | |
| 568 | 568 | |
| 569 | 569 | // Close FITS file |
| 570 | 570 | file.close(); |
| ... | ... | @@ -578,19 +578,19 @@ void GEbounds::load(const std::string& filename, const std::string& extname) |
| 578 | 578 | * @brief Save energy boundaries into FITS file |
| 579 | 579 | * |
| 580 | 580 | * @param[in] filename FITS filename. |
| 581 | - * @param[in] clobber Overwrite any existing file? | |
| 581 | + * @param[in] clobber Overwrite any existing file (defaults to false)? | |
| 582 | 582 | * @param[in] extname Energy boundary extension name (defaults to "EBOUNDS"). |
| 583 | 583 | * |
| 584 | 584 | * Saves the energy boundaries into extension @p extname of a FITS file. |
| 585 | 585 | ***************************************************************************/ |
| 586 | -void GEbounds::save(const std::string& filename, bool clobber, | |
| 586 | +void GEbounds::save(const std::string& filename, const bool& clobber, | |
| 587 | 587 | const std::string& extname) const |
| 588 | 588 | { |
| 589 | 589 | // Allocate FITS file |
| 590 | 590 | GFits file; |
| 591 | 591 | |
| 592 | 592 | // Write energy boundaries to FITS file |
| 593 | - write(&file, extname); | |
| 593 | + write(file, extname); | |
| 594 | 594 | |
| 595 | 595 | // Save to file |
| 596 | 596 | file.saveto(filename, clobber); |
| ... | ... | @@ -603,7 +603,7 @@ void GEbounds::save(const std::string& filename, bool clobber, |
| 603 | 603 | /***********************************************************************//** |
| 604 | 604 | * @brief Read energy boundaries from FITS table |
| 605 | 605 | * |
| 606 | - * @param[in] hdu Pointer to FITS table. | |
| 606 | + * @param[in] table FITS table. | |
| 607 | 607 | * |
| 608 | 608 | * Reads the energy boundaries from a FITS table. It is assumed that the |
| 609 | 609 | * energies are stored in units of keV. |
| ... | ... | @@ -612,7 +612,7 @@ void GEbounds::save(const std::string& filename, bool clobber, |
| 612 | 612 | * string parameter that allows external specification about how |
| 613 | 613 | * the energies should be interpreted. |
| 614 | 614 | ***************************************************************************/ |
| 615 | -void GEbounds::read(GFitsTable* hdu) | |
| 615 | +void GEbounds::read(const GFitsTable& table) | |
| 616 | 616 | { |
| 617 | 617 | // Free members |
| 618 | 618 | free_members(); |
| ... | ... | @@ -620,29 +620,24 @@ void GEbounds::read(GFitsTable* hdu) |
| 620 | 620 | // Initialise attributes |
| 621 | 621 | init_members(); |
| 622 | 622 | |
| 623 | - // Continue only if HDU is valid | |
| 624 | - if (hdu != NULL) { | |
| 625 | - | |
| 626 | - // Extract energy boundary information from FITS file | |
| 627 | - m_num = hdu->integer("NAXIS2"); | |
| 628 | - if (m_num > 0) { | |
| 629 | - | |
| 630 | - // Allocate memory | |
| 631 | - m_min = new GEnergy[m_num]; | |
| 632 | - m_max = new GEnergy[m_num]; | |
| 623 | + // Extract energy boundary information from FITS table | |
| 624 | + m_num = table.integer("NAXIS2"); | |
| 625 | + if (m_num > 0) { | |
| 633 | 626 | |
| 634 | - // Copy information | |
| 635 | - for (int i = 0; i < m_num; ++i) { | |
| 636 | - m_min[i].keV((*hdu)["E_MIN"]->real(i)); | |
| 637 | - m_max[i].keV((*hdu)["E_MAX"]->real(i)); | |
| 638 | - } | |
| 627 | + // Allocate memory | |
| 628 | + m_min = new GEnergy[m_num]; | |
| 629 | + m_max = new GEnergy[m_num]; | |
| 639 | 630 | |
| 640 | - } // endif: there were channels to read | |
| 631 | + // Copy information | |
| 632 | + for (int i = 0; i < m_num; ++i) { | |
| 633 | + m_min[i].keV(table["E_MIN"]->real(i)); | |
| 634 | + m_max[i].keV(table["E_MAX"]->real(i)); | |
| 635 | + } | |
| 641 | 636 | |
| 642 | 637 | // Set attributes |
| 643 | 638 | set_attributes(); |
| 644 | 639 | |
| 645 | - } // endif: HDU was valid | |
| 640 | + } // endif: there were channels to read | |
| 646 | 641 | |
| 647 | 642 | // Return |
| 648 | 643 | return; |
| ... | ... | @@ -652,7 +647,7 @@ void GEbounds::read(GFitsTable* hdu) |
| 652 | 647 | /***********************************************************************//** |
| 653 | 648 | * @brief Write energy boundaries into FITS object |
| 654 | 649 | * |
| 655 | - * @param[in] file Pointer to FITS file. | |
| 650 | + * @param[in] file FITS file. | |
| 656 | 651 | * @param[in] extname Energy boundary extension name (defaults to "EBOUNDS") |
| 657 | 652 | * |
| 658 | 653 | * Writes the energy boundaries into a FITS object. Energies are written in |
| ... | ... | @@ -661,7 +656,7 @@ void GEbounds::read(GFitsTable* hdu) |
| 661 | 656 | * @todo Write header keywords. |
| 662 | 657 | * @todo Should we allow for the possibility to specify the energy units? |
| 663 | 658 | ***************************************************************************/ |
| 664 | -void GEbounds::write(GFits* file, const std::string& extname) const | |
| 659 | +void GEbounds::write(GFits& file, const std::string& extname) const | |
| 665 | 660 | { |
| 666 | 661 | // Create energy boundary columns |
| 667 | 662 | GFitsTableDoubleCol cemin = GFitsTableDoubleCol("E_MIN", m_num); |
| ... | ... | @@ -684,7 +679,7 @@ void GEbounds::write(GFits* file, const std::string& extname) const |
| 684 | 679 | table->extname(extname); |
| 685 | 680 | |
| 686 | 681 | // Write to FITS file |
| 687 | - file->append(*table); | |
| 682 | + file.append(*table); | |
| 688 | 683 | |
| 689 | 684 | // Free table |
| 690 | 685 | delete table; | ... | ... |
src/obs/GGti.cpp
| ... | ... | @@ -537,11 +537,11 @@ void GGti::load(const std::string& filename, const std::string& extname) |
| 537 | 537 | // Open FITS file |
| 538 | 538 | file.open(filename); |
| 539 | 539 | |
| 540 | - // Get GTI HDU | |
| 541 | - GFitsTable* hdu = file.table(extname); | |
| 540 | + // Get GTI table | |
| 541 | + const GFitsTable& table = *file.table(extname); | |
| 542 | 542 | |
| 543 | - // Read GTI from HDU | |
| 544 | - read(hdu); | |
| 543 | + // Read GTI from table | |
| 544 | + read(table); | |
| 545 | 545 | |
| 546 | 546 | // Close FITS file |
| 547 | 547 | file.close(); |
| ... | ... | @@ -563,14 +563,14 @@ void GGti::load(const std::string& filename, const std::string& extname) |
| 563 | 563 | * as extension. If another GTI exists already it is overwritten if |
| 564 | 564 | * @p clobber=true. |
| 565 | 565 | ***************************************************************************/ |
| 566 | -void GGti::save(const std::string& filename, bool clobber, | |
| 566 | +void GGti::save(const std::string& filename, const bool& clobber, | |
| 567 | 567 | const std::string& extname) const |
| 568 | 568 | { |
| 569 | 569 | // Allocate FITS file |
| 570 | 570 | GFits file; |
| 571 | 571 | |
| 572 | 572 | // Write GTI to FITS file |
| 573 | - write(&file, extname); | |
| 573 | + write(file, extname); | |
| 574 | 574 | |
| 575 | 575 | // Save to file |
| 576 | 576 | file.saveto(filename, clobber); |
| ... | ... | @@ -583,11 +583,11 @@ void GGti::save(const std::string& filename, bool clobber, |
| 583 | 583 | /***********************************************************************//** |
| 584 | 584 | * @brief Read Good Time Intervals and time reference from FITS table |
| 585 | 585 | * |
| 586 | - * @param[in] hdu Pointer to FITS table. | |
| 586 | + * @param[in] table FITS table. | |
| 587 | 587 | * |
| 588 | 588 | * Reads the Good Time Intervals and time reference from a FITS table. |
| 589 | 589 | ***************************************************************************/ |
| 590 | -void GGti::read(const GFitsTable* hdu) | |
| 590 | +void GGti::read(const GFitsTable& table) | |
| 591 | 591 | { |
| 592 | 592 | // Free members |
| 593 | 593 | free_members(); |
| ... | ... | @@ -596,18 +596,18 @@ void GGti::read(const GFitsTable* hdu) |
| 596 | 596 | init_members(); |
| 597 | 597 | |
| 598 | 598 | // Read time reference |
| 599 | - m_reference.read(hdu); | |
| 599 | + m_reference.read(table); | |
| 600 | 600 | |
| 601 | - // Extract GTI information from FITS file | |
| 602 | - m_num = hdu->integer("NAXIS2"); | |
| 601 | + // Extract GTI information from FITS table | |
| 602 | + m_num = table.integer("NAXIS2"); | |
| 603 | 603 | if (m_num > 0) { |
| 604 | 604 | |
| 605 | 605 | // Set GTIs |
| 606 | 606 | m_start = new GTime[m_num]; |
| 607 | 607 | m_stop = new GTime[m_num]; |
| 608 | 608 | for (int i = 0; i < m_num; ++i) { |
| 609 | - m_start[i].set((*hdu)["START"]->real(i), m_reference); | |
| 610 | - m_stop[i].set((*hdu)["STOP"]->real(i), m_reference); | |
| 609 | + m_start[i].set(table["START"]->real(i), m_reference); | |
| 610 | + m_stop[i].set(table["STOP"]->real(i), m_reference); | |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | // Set attributes |
| ... | ... | @@ -623,7 +623,7 @@ void GGti::read(const GFitsTable* hdu) |
| 623 | 623 | /***********************************************************************//** |
| 624 | 624 | * @brief Write Good Time Intervals and time reference into FITS object |
| 625 | 625 | * |
| 626 | - * @param[in] file Pointer to FITS file. | |
| 626 | + * @param[in] file FITS file. | |
| 627 | 627 | * @param[in] extname GTI extension name (defaults to "GTI") |
| 628 | 628 | * |
| 629 | 629 | * Saves Good Time Intervals and time reference into a FITS object. If the |
| ... | ... | @@ -633,7 +633,7 @@ void GGti::read(const GFitsTable* hdu) |
| 633 | 633 | * |
| 634 | 634 | * @todo Implement clobber method for overwriting of existing GTIs. |
| 635 | 635 | ***************************************************************************/ |
| 636 | -void GGti::write(GFits* file, const std::string& extname) const | |
| 636 | +void GGti::write(GFits& file, const std::string& extname) const | |
| 637 | 637 | { |
| 638 | 638 | // Create GTI columns |
| 639 | 639 | GFitsTableDoubleCol cstart = GFitsTableDoubleCol("START", m_num); |
| ... | ... | @@ -652,10 +652,10 @@ void GGti::write(GFits* file, const std::string& extname) const |
| 652 | 652 | table->extname(extname); |
| 653 | 653 | |
| 654 | 654 | // Write time reference |
| 655 | - m_reference.write(table); | |
| 655 | + m_reference.write(*table); | |
| 656 | 656 | |
| 657 | 657 | // Write to FITS file |
| 658 | - file->append(*table); | |
| 658 | + file.append(*table); | |
| 659 | 659 | |
| 660 | 660 | // Free table |
| 661 | 661 | delete table; | ... | ... |
src/obs/GPhoton.cpp
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GPhoton.cpp |
| 23 | - * @brief Photon class implementation. | |
| 23 | + * @brief Photon class implementation | |
| 24 | 24 | * @author Juergen Knodlseder |
| 25 | 25 | */ |
| 26 | 26 | |
| ... | ... | @@ -67,8 +67,10 @@ GPhoton::GPhoton(void) |
| 67 | 67 | * @param[in] dir Sky direction. |
| 68 | 68 | * @param[in] energy Energy. |
| 69 | 69 | * @param[in] time Time. |
| 70 | + * @param[in] mcid Monte-Carlo identifier. | |
| 70 | 71 | ***************************************************************************/ |
| 71 | -GPhoton::GPhoton(const GSkyDir& dir, const GEnergy& energy, const GTime& time) | |
| 72 | +GPhoton::GPhoton(const GSkyDir& dir, const GEnergy& energy, | |
| 73 | + const GTime& time, const int& mcid) | |
| 72 | 74 | { |
| 73 | 75 | // Initialise private members |
| 74 | 76 | init_members(); |
| ... | ... | @@ -77,6 +79,7 @@ GPhoton::GPhoton(const GSkyDir& dir, const GEnergy& energy, const GTime& time) |
| 77 | 79 | m_dir = dir; |
| 78 | 80 | m_energy = energy; |
| 79 | 81 | m_time = time; |
| 82 | + m_mc_id = mcid; | |
| 80 | 83 | |
| 81 | 84 | // Return |
| 82 | 85 | return; |
| ... | ... | @@ -86,15 +89,15 @@ GPhoton::GPhoton(const GSkyDir& dir, const GEnergy& energy, const GTime& time) |
| 86 | 89 | /***********************************************************************//** |
| 87 | 90 | * @brief Copy constructor |
| 88 | 91 | * |
| 89 | - * @param[in] ph Photon. | |
| 92 | + * @param[in] photon Photon. | |
| 90 | 93 | ***************************************************************************/ |
| 91 | -GPhoton::GPhoton(const GPhoton& ph) | |
| 94 | +GPhoton::GPhoton(const GPhoton& photon) | |
| 92 | 95 | { |
| 93 | 96 | // Initialise private members |
| 94 | 97 | init_members(); |
| 95 | 98 | |
| 96 | 99 | // Copy members |
| 97 | - copy_members(ph); | |
| 100 | + copy_members(photon); | |
| 98 | 101 | |
| 99 | 102 | // Return |
| 100 | 103 | return; |
| ... | ... | @@ -123,12 +126,13 @@ GPhoton::~GPhoton(void) |
| 123 | 126 | /***********************************************************************//** |
| 124 | 127 | * @brief Assignment operator |
| 125 | 128 | * |
| 126 | - * @param[in] ph Photon. | |
| 129 | + * @param[in] photon Photon. | |
| 130 | + * @return Photon. | |
| 127 | 131 | ***************************************************************************/ |
| 128 | -GPhoton& GPhoton::operator= (const GPhoton& ph) | |
| 132 | +GPhoton& GPhoton::operator=(const GPhoton& photon) | |
| 129 | 133 | { |
| 130 | 134 | // Execute only if object is not identical |
| 131 | - if (this != &ph) { | |
| 135 | + if (this != &photon) { | |
| 132 | 136 | |
| 133 | 137 | // Free members |
| 134 | 138 | free_members(); |
| ... | ... | @@ -137,7 +141,7 @@ GPhoton& GPhoton::operator= (const GPhoton& ph) |
| 137 | 141 | init_members(); |
| 138 | 142 | |
| 139 | 143 | // Copy members |
| 140 | - copy_members(ph); | |
| 144 | + copy_members(photon); | |
| 141 | 145 | |
| 142 | 146 | } // endif: object was not identical |
| 143 | 147 | |
| ... | ... | @@ -153,7 +157,7 @@ GPhoton& GPhoton::operator= (const GPhoton& ph) |
| 153 | 157 | ==========================================================================*/ |
| 154 | 158 | |
| 155 | 159 | /***********************************************************************//** |
| 156 | - * @brief Clear instance | |
| 160 | + * @brief Clear photon | |
| 157 | 161 | ***************************************************************************/ |
| 158 | 162 | void GPhoton::clear(void) |
| 159 | 163 | { |
| ... | ... | @@ -169,7 +173,9 @@ void GPhoton::clear(void) |
| 169 | 173 | |
| 170 | 174 | |
| 171 | 175 | /***********************************************************************//** |
| 172 | - * @brief Clone object | |
| 176 | + * @brief Clone photon | |
| 177 | + * | |
| 178 | + * @return Pointer to deep copy of photon. | |
| 173 | 179 | ***************************************************************************/ |
| 174 | 180 | GPhoton* GPhoton::clone(void) const |
| 175 | 181 | { |
| ... | ... | @@ -235,15 +241,15 @@ void GPhoton::init_members(void) |
| 235 | 241 | /***********************************************************************//** |
| 236 | 242 | * @brief Copy class members |
| 237 | 243 | * |
| 238 | - * @param[in] ph Photon. | |
| 244 | + * @param[in] photon Photon. | |
| 239 | 245 | ***************************************************************************/ |
| 240 | -void GPhoton::copy_members(const GPhoton& ph) | |
| 246 | +void GPhoton::copy_members(const GPhoton& photon) | |
| 241 | 247 | { |
| 242 | 248 | // Copy time |
| 243 | - m_dir = ph.m_dir; | |
| 244 | - m_energy = ph.m_energy; | |
| 245 | - m_time = ph.m_time; | |
| 246 | - m_mc_id = ph.m_mc_id; | |
| 249 | + m_dir = photon.m_dir; | |
| 250 | + m_energy = photon.m_energy; | |
| 251 | + m_time = photon.m_time; | |
| 252 | + m_mc_id = photon.m_mc_id; | |
| 247 | 253 | |
| 248 | 254 | // Return |
| 249 | 255 | return; | ... | ... |
src/obs/GTime.cpp
| ... | ... | @@ -259,18 +259,6 @@ double GTime::mjd(void) const |
| 259 | 259 | |
| 260 | 260 | |
| 261 | 261 | /***********************************************************************//** |
| 262 | - * @brief Return time in native reference (TT) (unit: seconds) | |
| 263 | - * | |
| 264 | - * @return Time in native reference [seconds]. | |
| 265 | - ***************************************************************************/ | |
| 266 | -double GTime::secs(void) const | |
| 267 | -{ | |
| 268 | - // Return time | |
| 269 | - return m_time; | |
| 270 | -} | |
| 271 | - | |
| 272 | - | |
| 273 | -/***********************************************************************//** | |
| 274 | 262 | * @brief Return time in native reference (TT) (unit: days) |
| 275 | 263 | * |
| 276 | 264 | * @return Time in native reference [days]. |
| ... | ... | @@ -346,21 +334,6 @@ void GTime::mjd(const double& time) |
| 346 | 334 | |
| 347 | 335 | |
| 348 | 336 | /***********************************************************************//** |
| 349 | - * @brief Set time in native reference in seconds (TT) | |
| 350 | - * | |
| 351 | - * @param[in] seconds Time (TT) [seconds]. | |
| 352 | - ***************************************************************************/ | |
| 353 | -void GTime::secs(const double& seconds) | |
| 354 | -{ | |
| 355 | - // Set time | |
| 356 | - m_time = seconds; | |
| 357 | - | |
| 358 | - // Return | |
| 359 | - return; | |
| 360 | -} | |
| 361 | - | |
| 362 | - | |
| 363 | -/***********************************************************************//** | |
| 364 | 337 | * @brief Set time in native reference in days (TT) |
| 365 | 338 | * |
| 366 | 339 | * @param[in] days Time (TT) [days]. | ... | ... |
src/obs/GTimeReference.cpp
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | /* __ Constants __________________________________________________________ */ |
| 36 | 36 | |
| 37 | 37 | /* __ Method name definitions ____________________________________________ */ |
| 38 | -#define G_READ "GTimeReference::read(GFitsHDU*)" | |
| 38 | +#define G_READ "GTimeReference::read(GFitsHDU&)" | |
| 39 | 39 | #define G_SET "GTimeReference::set(double&, std::string&, std::string&, "\ |
| 40 | 40 | "std::string&)" |
| 41 | 41 | |
| ... | ... | @@ -147,7 +147,7 @@ GTimeReference::GTimeReference(const int& mjdrefi, |
| 147 | 147 | * Constructs time reference from the information found in the FITS header. |
| 148 | 148 | * See GTimeReference::read for more information on the expected format. |
| 149 | 149 | ***************************************************************************/ |
| 150 | -GTimeReference::GTimeReference(const GFitsHDU* hdu) | |
| 150 | +GTimeReference::GTimeReference(const GFitsHDU& hdu) | |
| 151 | 151 | { |
| 152 | 152 | // Initialise private members |
| 153 | 153 | init_members(); |
| ... | ... | @@ -256,38 +256,32 @@ GTimeReference* GTimeReference::clone(void) const |
| 256 | 256 | * TIMESYS ("TT") |
| 257 | 257 | * TIMEREF ("LOCAL") |
| 258 | 258 | * |
| 259 | - * Nothing is done if the HDU pointer is NULL. | |
| 260 | 259 | ***************************************************************************/ |
| 261 | -void GTimeReference::read(const GFitsHDU* hdu) | |
| 260 | +void GTimeReference::read(const GFitsHDU& hdu) | |
| 262 | 261 | { |
| 263 | - // Continue only if HDU is valid | |
| 264 | - if (hdu != NULL) { | |
| 265 | - | |
| 266 | - // Get reference MJD | |
| 267 | - double mjdref = (hdu->hascard("MJDREF")) ? hdu->real("MJDREF") : 0.0; | |
| 268 | - int mjdrefi = (hdu->hascard("MJDREFI")) ? hdu->integer("MJDREFI") : 0; | |
| 269 | - double mjdreff = (hdu->hascard("MJDREFF")) ? hdu->real("MJDREFF") : 0.0; | |
| 270 | - | |
| 271 | - // Get remaining keywords. To accept a large variety of FITS headers, | |
| 272 | - // all keywords are optionally. | |
| 273 | - std::string timeunit = (hdu->hascard("TIMEUNIT")) ? hdu->string("TIMEUNIT") : "s"; | |
| 274 | - std::string timesys = (hdu->hascard("TIMESYS")) ? hdu->string("TIMESYS") : "TT"; | |
| 275 | - std::string timeref = (hdu->hascard("TIMEREF")) ? hdu->string("TIMEREF") : "LOCAL"; | |
| 276 | - | |
| 277 | - // Set time reference | |
| 278 | - if (hdu->hascard("MJDREF")) { | |
| 279 | - set(mjdref, timeunit, timesys, timeref); | |
| 280 | - } | |
| 281 | - else if (hdu->hascard("MJDREFI") && hdu->hascard("MJDREFF")) { | |
| 282 | - set(mjdrefi, mjdreff, timeunit, timesys, timeref); | |
| 283 | - } | |
| 284 | - else { | |
| 285 | - throw GException::no_valid_time_ref(G_READ, | |
| 286 | - "Require either keyword \"MJDREF\" or keyword pair" | |
| 287 | - " \"MJDREFI\" and \"MJDREFF\"."); | |
| 288 | - } | |
| 289 | - | |
| 290 | - } // endif: HDU was valid | |
| 262 | + // Get reference MJD | |
| 263 | + double mjdref = (hdu.hascard("MJDREF")) ? hdu.real("MJDREF") : 0.0; | |
| 264 | + int mjdrefi = (hdu.hascard("MJDREFI")) ? hdu.integer("MJDREFI") : 0; | |
| 265 | + double mjdreff = (hdu.hascard("MJDREFF")) ? hdu.real("MJDREFF") : 0.0; | |
| 266 | + | |
| 267 | + // Get remaining keywords. To accept a large variety of FITS headers, | |
| 268 | + // all keywords are optionally. | |
| 269 | + std::string timeunit = (hdu.hascard("TIMEUNIT")) ? hdu.string("TIMEUNIT") : "s"; | |
| 270 | + std::string timesys = (hdu.hascard("TIMESYS")) ? hdu.string("TIMESYS") : "TT"; | |
| 271 | + std::string timeref = (hdu.hascard("TIMEREF")) ? hdu.string("TIMEREF") : "LOCAL"; | |
| 272 | + | |
| 273 | + // Set time reference | |
| 274 | + if (hdu.hascard("MJDREF")) { | |
| 275 | + set(mjdref, timeunit, timesys, timeref); | |
| 276 | + } | |
| 277 | + else if (hdu.hascard("MJDREFI") && hdu.hascard("MJDREFF")) { | |
| 278 | + set(mjdrefi, mjdreff, timeunit, timesys, timeref); | |
| 279 | + } | |
| 280 | + else { | |
| 281 | + throw GException::no_valid_time_ref(G_READ, | |
| 282 | + "Require either keyword \"MJDREF\" or keyword pair" | |
| 283 | + " \"MJDREFI\" and \"MJDREFF\"."); | |
| 284 | + } | |
| 291 | 285 | |
| 292 | 286 | // Return |
| 293 | 287 | return; |
| ... | ... | @@ -312,32 +306,25 @@ void GTimeReference::read(const GFitsHDU* hdu) |
| 312 | 306 | * TIMESYS |
| 313 | 307 | * TIMEREF |
| 314 | 308 | * |
| 315 | - * Nothing is done if the HDU pointer is NULL. | |
| 316 | 309 | ***************************************************************************/ |
| 317 | -void GTimeReference::write(GFitsHDU* hdu) const | |
| 310 | +void GTimeReference::write(GFitsHDU& hdu) const | |
| 318 | 311 | { |
| 319 | - // Continue only if HDU is valid | |
| 320 | - if (hdu != NULL) { | |
| 321 | - | |
| 322 | - // Case A: use floating point reference MJD | |
| 323 | - if (hdu->hascard("MJDREF")) { | |
| 324 | - hdu->card("MJDREF", mjdref(), "[days] Time reference MJD"); | |
| 325 | - hdu->card("TIMEUNIT", timeunit(), "Time unit"); | |
| 326 | - hdu->card("TIMESYS", timesys(), "Time system"); | |
| 327 | - hdu->card("TIMEREF", timeref(), "Time reference"); | |
| 328 | - } | |
| 329 | - | |
| 330 | - // Case B: use fractional reference MJD | |
| 331 | - else { | |
| 332 | - hdu->card("MJDREFI", mjdrefi(), "[days] Integer part of time reference MJD"); | |
| 333 | - hdu->card("MJDREFF", mjdreff(), "[days] Fractional part of time reference MJD"); | |
| 334 | - hdu->card("TIMEUNIT", timeunit(), "Time unit"); | |
| 335 | - hdu->card("TIMESYS", timesys(), "Time system"); | |
| 336 | - hdu->card("TIMEREF", timeref(), "Time reference"); | |
| 337 | - } | |
| 338 | - | |
| 339 | - | |
| 340 | - } // endif: HDU was valid | |
| 312 | + // Case A: use floating point reference MJD | |
| 313 | + if (hdu.hascard("MJDREF")) { | |
| 314 | + hdu.card("MJDREF", mjdref(), "[days] Time reference MJD"); | |
| 315 | + hdu.card("TIMEUNIT", timeunit(), "Time unit"); | |
| 316 | + hdu.card("TIMESYS", timesys(), "Time system"); | |
| 317 | + hdu.card("TIMEREF", timeref(), "Time reference"); | |
| 318 | + } | |
| 319 | + | |
| 320 | + // Case B: use fractional reference MJD | |
| 321 | + else { | |
| 322 | + hdu.card("MJDREFI", mjdrefi(), "[days] Integer part of time reference MJD"); | |
| 323 | + hdu.card("MJDREFF", mjdreff(), "[days] Fractional part of time reference MJD"); | |
| 324 | + hdu.card("TIMEUNIT", timeunit(), "Time unit"); | |
| 325 | + hdu.card("TIMESYS", timesys(), "Time system"); | |
| 326 | + hdu.card("TIMEREF", timeref(), "Time reference"); | |
| 327 | + } | |
| 341 | 328 | |
| 342 | 329 | // Return |
| 343 | 330 | return; | ... | ... |
src/xspec/GPha.cpp
| ... | ... | @@ -341,14 +341,19 @@ void GPha::load(const std::string& filename) |
| 341 | 341 | // Get PHA table |
| 342 | 342 | GFitsTable* pha = fits.table("SPECTRUM"); |
| 343 | 343 | |
| 344 | - // Get EBOUNDS table (NULL if the table does not exist) | |
| 345 | - GFitsTable* ebounds = (fits.contains("EBOUNDS")) ? fits.table("EBOUNDS") : NULL; | |
| 346 | - | |
| 347 | 344 | // Read PHA data |
| 348 | 345 | read(pha); |
| 349 | 346 | |
| 350 | - // Read EBOUNDS data (will do nothing if table has not been found) | |
| 351 | - m_ebounds.read(ebounds); | |
| 347 | + // Optionally read EBOUNDS data | |
| 348 | + if (fits.contains("EBOUNDS")) { | |
| 349 | + | |
| 350 | + // Get EBOUNDS table | |
| 351 | + const GFitsTable& ebounds = *fits.table("EBOUNDS"); | |
| 352 | + | |
| 353 | + // Read EBOUNDS data | |
| 354 | + m_ebounds.read(ebounds); | |
| 355 | + | |
| 356 | + } // endif: has EBOUNDS table | |
| 352 | 357 | |
| 353 | 358 | // Close FITS file |
| 354 | 359 | fits.close(); |
| ... | ... | @@ -486,7 +491,7 @@ void GPha::write(GFits& fits) const |
| 486 | 491 | |
| 487 | 492 | // Optionally append energy boundaries |
| 488 | 493 | if (m_ebounds.size() > 0) { |
| 489 | - m_ebounds.write(&fits); | |
| 494 | + m_ebounds.write(fits); | |
| 490 | 495 | } |
| 491 | 496 | |
| 492 | 497 | } // endif: there were data to write | ... | ... |
src/xspec/GRmf.cpp
test/test_GObservation.cpp
| ... | ... | @@ -416,14 +416,14 @@ void TestGObservation::test_time_reference(void) |
| 416 | 416 | GTimeReference reference(55197.000766018518519, "s", "TT", "LOCAL"); |
| 417 | 417 | GFits fits; |
| 418 | 418 | GFitsBinTable table; |
| 419 | - reference.write(&table); | |
| 419 | + reference.write(table); | |
| 420 | 420 | fits.append(table); |
| 421 | 421 | fits.saveto("test_time_reference.fits", true); |
| 422 | 422 | fits.close(); |
| 423 | 423 | |
| 424 | 424 | // Read back from FITS file and check values |
| 425 | 425 | fits.open("test_time_reference.fits"); |
| 426 | - GFitsTable* hdu = fits.table(1); | |
| 426 | + const GFitsTable& hdu = *fits.table(1); | |
| 427 | 427 | GTimeReference value(hdu); |
| 428 | 428 | fits.close(); |
| 429 | 429 | test_value(value.mjdref(), reference.mjdref()); | ... | ... |