Commit 035f022c63820e60f5af7584cd0354090794c6cd
1 parent
24f4336c
Support pickling of COMPTEL classes (#1938)
Showing
51 changed files
with
1035 additions
and
195 deletions
NEWS
| ... | ... | @@ -92,6 +92,16 @@ The following methods have been added: |
| 92 | 92 | - GCTAModelRadialAcceptance::temporal(GModelTemporal*) |
| 93 | 93 | - GCTAModelIrfBackground::spectral(GModelSpectral*) |
| 94 | 94 | - GCTAModelIrfBackground::temporal(GModelTemporal*) |
| 95 | +- GCOMD1Response::write(GFitsBinTable&) | |
| 96 | +- GCOMD2Response::write(GFitsBinTable&) | |
| 97 | +- GCOMEventBin::index(int&) | |
| 98 | +- GCOMEventBin::dir(GCOMInstDir&) | |
| 99 | +- GCOMEventBin::energy(GEnergy&) | |
| 100 | +- GCOMEventBin::time(GTime&) | |
| 101 | +- GCOMEventBin::counts(double&) | |
| 102 | +- GCOMEventBin::solidangle(double&) | |
| 103 | +- GCOMEventBin::ewidth(GEnergy&) | |
| 104 | +- GCOMEventBin::ontime(double&) | |
| 95 | 105 | |
| 96 | 106 | The following methods have been removed: |
| 97 | 107 | - GSkyRegionMap::filename() | ... | ... |
inst/com/include/GCOMD1Response.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMD1Response.hpp - COMPTEL D1 module response class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -37,6 +37,7 @@ |
| 37 | 37 | |
| 38 | 38 | /* __ Forward declarations _______________________________________________ */ |
| 39 | 39 | class GFitsTable; |
| 40 | +class GFitsBinTable; | |
| 40 | 41 | |
| 41 | 42 | |
| 42 | 43 | /***********************************************************************//** |
| ... | ... | @@ -65,6 +66,7 @@ public: |
| 65 | 66 | const GCaldb& caldb(void) const; |
| 66 | 67 | void load(const std::string& sdaname); |
| 67 | 68 | void read(const GFitsTable& table); |
| 69 | + void write(GFitsBinTable& table); | |
| 68 | 70 | double position(const double& etrue) const; |
| 69 | 71 | double sigma(const double& etrue) const; |
| 70 | 72 | double amplitude(const double& etrue) const; | ... | ... |
inst/com/include/GCOMD2Response.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMD2Response.hpp - COMPTEL D2 module response class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -38,6 +38,7 @@ |
| 38 | 38 | |
| 39 | 39 | /* __ Forward declarations _______________________________________________ */ |
| 40 | 40 | class GFitsTable; |
| 41 | +class GFitsBinTable; | |
| 41 | 42 | |
| 42 | 43 | |
| 43 | 44 | /***********************************************************************//** |
| ... | ... | @@ -66,6 +67,7 @@ public: |
| 66 | 67 | const GCaldb& caldb(void) const; |
| 67 | 68 | void load(const std::string& sdbname); |
| 68 | 69 | void read(const GFitsTable& table); |
| 70 | + void write(GFitsBinTable& table); | |
| 69 | 71 | double position(const double& etrue) const; |
| 70 | 72 | double sigma(const double& etrue) const; |
| 71 | 73 | double amplitude(const double& etrue) const; | ... | ... |
inst/com/include/GCOMEventBin.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMEventBin.hpp - COMPTEL event bin class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -78,6 +78,13 @@ public: |
| 78 | 78 | const double& solidangle(void) const; |
| 79 | 79 | const GEnergy& ewidth(void) const; |
| 80 | 80 | const double& ontime(void) const; |
| 81 | + void index(const int& index); | |
| 82 | + void dir(const GCOMInstDir& dir); | |
| 83 | + void energy(const GEnergy& energy); | |
| 84 | + void time(const GTime& time); | |
| 85 | + void solidangle(const double& solidangle); | |
| 86 | + void ewidth(const GEnergy& ewidth); | |
| 87 | + void ontime(const double& ontime); | |
| 81 | 88 | |
| 82 | 89 | protected: |
| 83 | 90 | // Protected methods |
| ... | ... | @@ -111,77 +118,6 @@ std::string GCOMEventBin::classname(void) const |
| 111 | 118 | |
| 112 | 119 | |
| 113 | 120 | /***********************************************************************//** |
| 114 | - * @brief Return instrument direction | |
| 115 | - * | |
| 116 | - * @return Instrument direction. | |
| 117 | - * | |
| 118 | - * Returns the instrument direction of the event bin. | |
| 119 | - ***************************************************************************/ | |
| 120 | -inline | |
| 121 | -const GCOMInstDir& GCOMEventBin::dir(void) const | |
| 122 | -{ | |
| 123 | - return (*m_dir); | |
| 124 | -} | |
| 125 | - | |
| 126 | - | |
| 127 | -/***********************************************************************//** | |
| 128 | - * @brief Return energy | |
| 129 | - * | |
| 130 | - * @return Energy. | |
| 131 | - * | |
| 132 | - * Returns the energy of the event bin. | |
| 133 | - ***************************************************************************/ | |
| 134 | -inline | |
| 135 | -const GEnergy& GCOMEventBin::energy(void) const | |
| 136 | -{ | |
| 137 | - return (*m_energy); | |
| 138 | -} | |
| 139 | - | |
| 140 | - | |
| 141 | -/***********************************************************************//** | |
| 142 | - * @brief Return time | |
| 143 | - * | |
| 144 | - * @return Time. | |
| 145 | - * | |
| 146 | - * Returns the time of the event bin. | |
| 147 | - ***************************************************************************/ | |
| 148 | -inline | |
| 149 | -const GTime& GCOMEventBin::time(void) const | |
| 150 | -{ | |
| 151 | - return (*m_time); | |
| 152 | -} | |
| 153 | - | |
| 154 | - | |
| 155 | -/***********************************************************************//** | |
| 156 | - * @brief Return number of counts | |
| 157 | - * | |
| 158 | - * @return Number of counts. | |
| 159 | - * | |
| 160 | - * Returns the number of counts in the event bin. | |
| 161 | - ***************************************************************************/ | |
| 162 | -inline | |
| 163 | -double GCOMEventBin::counts(void) const | |
| 164 | -{ | |
| 165 | - return (*m_counts); | |
| 166 | -} | |
| 167 | - | |
| 168 | - | |
| 169 | -/***********************************************************************//** | |
| 170 | - * @brief Set number of counts | |
| 171 | - * | |
| 172 | - * @param[in] counts Number of counts. | |
| 173 | - * | |
| 174 | - * Set the number of counts in the event bin. | |
| 175 | - ***************************************************************************/ | |
| 176 | -inline | |
| 177 | -void GCOMEventBin::counts(const double& counts) | |
| 178 | -{ | |
| 179 | - *m_counts = counts; | |
| 180 | - return; | |
| 181 | -} | |
| 182 | - | |
| 183 | - | |
| 184 | -/***********************************************************************//** | |
| 185 | 121 | * @brief Return bin index |
| 186 | 122 | * |
| 187 | 123 | * @return Bin index. |
| ... | ... | @@ -197,44 +133,18 @@ const int& GCOMEventBin::index(void) const |
| 197 | 133 | |
| 198 | 134 | |
| 199 | 135 | /***********************************************************************//** |
| 200 | - * @brief Return solid angle | |
| 136 | + * @brief Set bin index | |
| 201 | 137 | * |
| 202 | - * @return Solid angle. | |
| 203 | - * | |
| 204 | - * Returns the solid angle of the event bin. | |
| 205 | - ***************************************************************************/ | |
| 206 | -inline | |
| 207 | -const double& GCOMEventBin::solidangle(void) const | |
| 208 | -{ | |
| 209 | - return (*m_solidangle); | |
| 210 | -} | |
| 211 | - | |
| 212 | - | |
| 213 | -/***********************************************************************//** | |
| 214 | - * @brief Return energy width | |
| 215 | - * | |
| 216 | - * @return Energy width. | |
| 217 | - * | |
| 218 | - * Returns the energy width of the event bin. | |
| 219 | - ***************************************************************************/ | |
| 220 | -inline | |
| 221 | -const GEnergy& GCOMEventBin::ewidth(void) const | |
| 222 | -{ | |
| 223 | - return (*m_ewidth); | |
| 224 | -} | |
| 225 | - | |
| 226 | - | |
| 227 | -/***********************************************************************//** | |
| 228 | - * @brief Return ontime | |
| 229 | - * | |
| 230 | - * @return Ontime. | |
| 138 | + * @return Bin index. | |
| 231 | 139 | * |
| 232 | - * Returns the ontime of the event bin. | |
| 140 | + * Set the index of the event bin if the bin is part of an event cube. If | |
| 141 | + * the event is not part of an event cube the index should be set to -1. | |
| 233 | 142 | ***************************************************************************/ |
| 234 | 143 | inline |
| 235 | -const double& GCOMEventBin::ontime(void) const | |
| 144 | +void GCOMEventBin::index(const int& index) | |
| 236 | 145 | { |
| 237 | - return (*m_ontime); | |
| 146 | + m_index = index; | |
| 147 | + return; | |
| 238 | 148 | } |
| 239 | 149 | |
| 240 | 150 | #endif /* GCOMEVENTBIN_HPP */ | ... | ... |
inst/com/include/GCOMIaq.hpp
| ... | ... | @@ -55,8 +55,8 @@ public: |
| 55 | 55 | // Constructors and destructors |
| 56 | 56 | GCOMIaq(void); |
| 57 | 57 | GCOMIaq(const GCOMIaq& iaq); |
| 58 | - GCOMIaq(const double& phigeo_max, const double& phigeo_bin_size, | |
| 59 | - const double& phibar_max, const double& phibar_bin_size); | |
| 58 | + GCOMIaq(const double& phigeo_max, const double& phigeo_bin_size, | |
| 59 | + const double& phibar_max, const double& phibar_bin_size); | |
| 60 | 60 | ~GCOMIaq(void); |
| 61 | 61 | |
| 62 | 62 | // Operators | ... | ... |
inst/com/include/GCOMObservation.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMObservation.hpp - COMPTEL observation class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -66,6 +66,7 @@ class GCOMObservation : public GObservation { |
| 66 | 66 | public: |
| 67 | 67 | // Constructors and destructors |
| 68 | 68 | GCOMObservation(void); |
| 69 | + explicit GCOMObservation(const GXmlElement& xml); | |
| 69 | 70 | GCOMObservation(const GFilename& drename, |
| 70 | 71 | const GFilename& drbname, |
| 71 | 72 | const GFilename& drgname, | ... | ... |
inst/com/include/GCOMResponse.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMResponse.hpp - COMPTEL Response class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -42,6 +42,7 @@ class GEnergy; |
| 42 | 42 | class GTime; |
| 43 | 43 | class GObservation; |
| 44 | 44 | class GFitsImage; |
| 45 | +class GFitsImageFloat; | |
| 45 | 46 | |
| 46 | 47 | |
| 47 | 48 | /***********************************************************************//** |
| ... | ... | @@ -89,6 +90,7 @@ public: |
| 89 | 90 | const std::string& rspname(void) const; |
| 90 | 91 | void load(const std::string& rspname); |
| 91 | 92 | void read(const GFitsImage& hdu); |
| 93 | + void write(GFitsImageFloat& image) const; | |
| 92 | 94 | |
| 93 | 95 | private: |
| 94 | 96 | // Private methods | ... | ... |
inst/com/include/GCOMTim.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMTim.hpp - COMPTEL Good Time Intervals class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knodlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knodlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -51,6 +51,7 @@ class GCOMTim : public GBase { |
| 51 | 51 | public: |
| 52 | 52 | // Constructors and destructors |
| 53 | 53 | GCOMTim(void); |
| 54 | + explicit GCOMTim(const GGti& gti); | |
| 54 | 55 | GCOMTim(const GCOMTim& tim); |
| 55 | 56 | GCOMTim(const GFilename& filename, const std::string& usage = "", |
| 56 | 57 | const std::string& mode = ""); | ... | ... |
inst/com/pyext/GCOMD1Response.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMD1Response.i - COMPTEL D1 module response class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -54,6 +54,7 @@ public: |
| 54 | 54 | const GCaldb& caldb(void) const; |
| 55 | 55 | void load(const std::string& sdaname); |
| 56 | 56 | void read(const GFitsTable& hdu); |
| 57 | + void write(GFitsBinTable& table); | |
| 57 | 58 | double position(const double& etrue) const; |
| 58 | 59 | double sigma(const double& etrue) const; |
| 59 | 60 | double amplitude(const double& etrue) const; |
| ... | ... | @@ -72,4 +73,14 @@ public: |
| 72 | 73 | GCOMD1Response copy() { |
| 73 | 74 | return (*self); |
| 74 | 75 | } |
| 76 | +%pythoncode { | |
| 77 | + def __getstate__(self): | |
| 78 | + table = gammalib.GFitsBinTable() | |
| 79 | + self.write(table) | |
| 80 | + state = (table,) | |
| 81 | + return state | |
| 82 | + def __setstate__(self, state): | |
| 83 | + self.__init__() | |
| 84 | + self.read(state[0]) | |
| 85 | +} | |
| 75 | 86 | }; | ... | ... |
inst/com/pyext/GCOMD2Response.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMD2Response.i - COMPTEL D2 module response class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -54,6 +54,7 @@ public: |
| 54 | 54 | const GCaldb& caldb(void) const; |
| 55 | 55 | void load(const std::string& sdaname); |
| 56 | 56 | void read(const GFitsTable& hdu); |
| 57 | + void write(GFitsBinTable& table); | |
| 57 | 58 | double position(const double& etrue) const; |
| 58 | 59 | double sigma(const double& etrue) const; |
| 59 | 60 | double amplitude(const double& etrue) const; |
| ... | ... | @@ -76,4 +77,14 @@ public: |
| 76 | 77 | GCOMD2Response copy() { |
| 77 | 78 | return (*self); |
| 78 | 79 | } |
| 80 | +%pythoncode { | |
| 81 | + def __getstate__(self): | |
| 82 | + table = gammalib.GFitsBinTable() | |
| 83 | + self.write(table) | |
| 84 | + state = (table,) | |
| 85 | + return state | |
| 86 | + def __setstate__(self, state): | |
| 87 | + self.__init__() | |
| 88 | + self.read(state[0]) | |
| 89 | +} | |
| 79 | 90 | }; | ... | ... |
inst/com/pyext/GCOMDri.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMDri.i - COMPTEL Data Space class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -116,4 +116,15 @@ public: |
| 116 | 116 | GCOMDri copy() { |
| 117 | 117 | return (*self); |
| 118 | 118 | } |
| 119 | +%pythoncode { | |
| 120 | + def __getstate__(self): | |
| 121 | + fits = gammalib.GFits() | |
| 122 | + self.write(fits) | |
| 123 | + state = (fits,) | |
| 124 | + return state | |
| 125 | + def __setstate__(self, state): | |
| 126 | + self.__init__() | |
| 127 | + if not state[0].is_empty(): | |
| 128 | + self.read(state[0][0]) | |
| 129 | +} | |
| 119 | 130 | }; | ... | ... |
inst/com/pyext/GCOMEventAtom.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMEventAtom.i - COMPTEL event atom class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -87,4 +87,28 @@ public: |
| 87 | 87 | GCOMEventAtom copy() { |
| 88 | 88 | return (*self); |
| 89 | 89 | } |
| 90 | +%pythoncode { | |
| 91 | + def __getstate__(self): | |
| 92 | + state = (self.dir(), self.energy(), self.time(), | |
| 93 | + self.e1(), self.e2(), self.phibar(), self.theta(), | |
| 94 | + self.phi(), self.eha(), self.psd(), self.tof(), | |
| 95 | + self.modcom(), self.reflag(), self.veto()) | |
| 96 | + return state | |
| 97 | + def __setstate__(self, state): | |
| 98 | + self.__init__() | |
| 99 | + self.dir(state[0]) | |
| 100 | + self.energy(state[1]) | |
| 101 | + self.time(state[2]) | |
| 102 | + self.e1(state[3]) | |
| 103 | + self.e2(state[4]) | |
| 104 | + self.phibar(state[5]) | |
| 105 | + self.theta(state[6]) | |
| 106 | + self.phi(state[7]) | |
| 107 | + self.eha(state[8]) | |
| 108 | + self.psd(state[9]) | |
| 109 | + self.tof(state[10]) | |
| 110 | + self.modcom(state[11]) | |
| 111 | + self.reflag(state[12]) | |
| 112 | + self.veto(state[13]) | |
| 113 | +} | |
| 90 | 114 | }; | ... | ... |
inst/com/pyext/GCOMEventBin.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMEventBin.i - COMPTEL event bin class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -58,6 +58,13 @@ public: |
| 58 | 58 | const double& solidangle(void) const; |
| 59 | 59 | const GEnergy& ewidth(void) const; |
| 60 | 60 | const double& ontime(void) const; |
| 61 | + void index(const int& index); | |
| 62 | + void dir(const GCOMInstDir& dir); | |
| 63 | + void energy(const GEnergy& energy); | |
| 64 | + void time(const GTime& time); | |
| 65 | + void solidangle(const double& solidangle); | |
| 66 | + void ewidth(const GEnergy& ewidth); | |
| 67 | + void ontime(const double& ontime); | |
| 61 | 68 | }; |
| 62 | 69 | |
| 63 | 70 | |
| ... | ... | @@ -68,4 +75,21 @@ public: |
| 68 | 75 | GCOMEventBin copy() { |
| 69 | 76 | return (*self); |
| 70 | 77 | } |
| 78 | +%pythoncode { | |
| 79 | + def __getstate__(self): | |
| 80 | + state = (self.index(), self.dir(), self.energy(), self.time(), | |
| 81 | + self.counts(), self.solidangle(), self.ewidth(), | |
| 82 | + self.ontime()) | |
| 83 | + return state | |
| 84 | + def __setstate__(self, state): | |
| 85 | + self.__init__() | |
| 86 | + if state[0] == -1: | |
| 87 | + self.dir(state[1]) | |
| 88 | + self.energy(state[2]) | |
| 89 | + self.time(state[3]) | |
| 90 | + self.counts(state[4]) | |
| 91 | + self.solidangle(state[5]) | |
| 92 | + self.ewidth(state[6]) | |
| 93 | + self.ontime(state[7]) | |
| 94 | +} | |
| 71 | 95 | }; | ... | ... |
inst/com/pyext/GCOMEventCube.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMEventCube.i - COMPTEL event bin container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -66,9 +66,6 @@ public: |
| 66 | 66 | * @brief GCOMEventCube class extension |
| 67 | 67 | ***************************************************************************/ |
| 68 | 68 | %extend GCOMEventCube { |
| 69 | - GCOMEventCube copy() { | |
| 70 | - return (*self); | |
| 71 | - } | |
| 72 | 69 | GCOMEventBin* __getitem__(int index) { |
| 73 | 70 | if (index >= 0 && index < self->size()) { |
| 74 | 71 | return (*self)[index]; |
| ... | ... | @@ -85,4 +82,18 @@ public: |
| 85 | 82 | throw GException::out_of_range("__setitem__(int)", index, self->size()); |
| 86 | 83 | } |
| 87 | 84 | } |
| 85 | + GCOMEventCube copy() { | |
| 86 | + return (*self); | |
| 87 | + } | |
| 88 | +%pythoncode { | |
| 89 | + def __getstate__(self): | |
| 90 | + fits = gammalib.GFits() | |
| 91 | + self.write(fits) | |
| 92 | + state = (fits,) | |
| 93 | + return state | |
| 94 | + def __setstate__(self, state): | |
| 95 | + self.__init__() | |
| 96 | + if not state[0].is_empty(): | |
| 97 | + self.read(state[0]) | |
| 98 | +} | |
| 88 | 99 | }; | ... | ... |
inst/com/pyext/GCOMEventList.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMEventList.i - COMPTEL event list class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -26,7 +26,6 @@ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| 28 | 28 | #include "GCOMEventList.hpp" |
| 29 | -#include "GTools.hpp" | |
| 30 | 29 | %} |
| 31 | 30 | |
| 32 | 31 | |
| ... | ... | @@ -129,4 +128,15 @@ public: |
| 129 | 128 | GCOMEventList copy() { |
| 130 | 129 | return (*self); |
| 131 | 130 | } |
| 131 | +%pythoncode { | |
| 132 | + def __getstate__(self): | |
| 133 | + fits = gammalib.GFits() | |
| 134 | + self.write(fits) | |
| 135 | + state = (fits,) | |
| 136 | + return state | |
| 137 | + def __setstate__(self, state): | |
| 138 | + self.__init__() | |
| 139 | + if not state[0].is_empty(): | |
| 140 | + self.read(state[0]) | |
| 141 | +} | |
| 132 | 142 | }; | ... | ... |
inst/com/pyext/GCOMIaq.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMIaq.i - COMPTEL instrument response representation * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -40,8 +40,8 @@ public: |
| 40 | 40 | // Constructors and destructors |
| 41 | 41 | GCOMIaq(void); |
| 42 | 42 | GCOMIaq(const GCOMIaq& iaq); |
| 43 | - GCOMIaq(const double& phigeo_max, const double& phigeo_bin_size, | |
| 44 | - const double& phibar_max, const double& phibar_bin_size); | |
| 43 | + GCOMIaq(const double& phigeo_max, const double& phigeo_bin_size, | |
| 44 | + const double& phibar_max, const double& phibar_bin_size); | |
| 45 | 45 | ~GCOMIaq(void); |
| 46 | 46 | |
| 47 | 47 | // Methods | ... | ... |
inst/com/pyext/GCOMInstDir.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMInstDir.i - COMPTEL instrument direction class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -62,4 +62,11 @@ public: |
| 62 | 62 | GCOMInstDir copy() { |
| 63 | 63 | return (*self); |
| 64 | 64 | } |
| 65 | +%pythoncode { | |
| 66 | + def __getstate__(self): | |
| 67 | + state = (self.dir(), self.phibar()) | |
| 68 | + return state | |
| 69 | + def __setstate__(self, state): | |
| 70 | + self.__init__(state[0], state[1]) | |
| 71 | +} | |
| 65 | 72 | }; | ... | ... |
inst/com/pyext/GCOMModelDRBFitting.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMModelDRBFitting.i - COMPTEL DRB model fitting class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -66,4 +66,16 @@ public: |
| 66 | 66 | GCOMModelDRBFitting copy() { |
| 67 | 67 | return (*self); |
| 68 | 68 | } |
| 69 | +%pythoncode { | |
| 70 | + def __getstate__(self): | |
| 71 | + xml = gammalib.GXmlElement() | |
| 72 | + self.write(xml) | |
| 73 | + state = (xml,) | |
| 74 | + return state | |
| 75 | + def __setstate__(self, state): | |
| 76 | + if state[0][0].elements('node') == 0: | |
| 77 | + self.__init__() | |
| 78 | + else: | |
| 79 | + self.__init__(state[0][0]) | |
| 80 | +} | |
| 69 | 81 | }; | ... | ... |
inst/com/pyext/GCOMOad.i
| ... | ... | @@ -78,4 +78,22 @@ public: |
| 78 | 78 | GCOMOad copy() { |
| 79 | 79 | return (*self); |
| 80 | 80 | } |
| 81 | +%pythoncode { | |
| 82 | + def __getstate__(self): | |
| 83 | + state = (self.tstart(), self.tstop(), self.zaxis(), self.xaxis(), | |
| 84 | + self.tjd(), self.tics(), self.gcaz(), self.gcel(), | |
| 85 | + self.georad()) | |
| 86 | + return state | |
| 87 | + def __setstate__(self, state): | |
| 88 | + self.__init__() | |
| 89 | + self.tstart(state[0]) | |
| 90 | + self.tstop(state[1]) | |
| 91 | + self.zaxis(state[2]) | |
| 92 | + self.xaxis(state[3]) | |
| 93 | + self.tjd(state[4]) | |
| 94 | + self.tics(state[5]) | |
| 95 | + self.gcaz(state[6]) | |
| 96 | + self.gcel(state[7]) | |
| 97 | + self.georad(state[8]) | |
| 98 | +} | |
| 81 | 99 | }; | ... | ... |
inst/com/pyext/GCOMOads.i
| ... | ... | @@ -121,4 +121,15 @@ public: |
| 121 | 121 | GCOMOads copy() { |
| 122 | 122 | return (*self); |
| 123 | 123 | } |
| 124 | +%pythoncode { | |
| 125 | + def __getstate__(self): | |
| 126 | + state = tuple([x for x in self]), | |
| 127 | + return state | |
| 128 | + def __setstate__(self, state): | |
| 129 | + self.__init__() | |
| 130 | + size = len(state[0]) | |
| 131 | + self.reserve(size) | |
| 132 | + for x in state[0]: | |
| 133 | + self.append(x) | |
| 134 | +} | |
| 124 | 135 | }; | ... | ... |
inst/com/pyext/GCOMObservation.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMObservation.i - COMPTEL observation class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -38,10 +38,14 @@ class GCOMObservation : public GObservation { |
| 38 | 38 | public: |
| 39 | 39 | // Constructors and destructors |
| 40 | 40 | GCOMObservation(void); |
| 41 | + explicit GCOMObservation(const GXmlElement& xml); | |
| 41 | 42 | GCOMObservation(const GFilename& drename, |
| 42 | 43 | const GFilename& drbname, |
| 43 | 44 | const GFilename& drgname, |
| 44 | 45 | const GFilename& drxname); |
| 46 | + GCOMObservation(const GFilename& evpname, | |
| 47 | + const GFilename& timname, | |
| 48 | + const std::vector<GFilename>& oadnames); | |
| 45 | 49 | GCOMObservation(const GCOMObservation& obs); |
| 46 | 50 | virtual ~GCOMObservation(void); |
| 47 | 51 | |
| ... | ... | @@ -92,4 +96,16 @@ public: |
| 92 | 96 | GCOMObservation copy() { |
| 93 | 97 | return (*self); |
| 94 | 98 | } |
| 99 | +%pythoncode { | |
| 100 | + def __getstate__(self): | |
| 101 | + xml = gammalib.GXmlElement() | |
| 102 | + self.write(xml) | |
| 103 | + state = (xml,) | |
| 104 | + return state | |
| 105 | + def __setstate__(self, state): | |
| 106 | + if state[0].elements() > 0: | |
| 107 | + self.__init__(state[0]) | |
| 108 | + else: | |
| 109 | + self.__init__() | |
| 110 | +} | |
| 95 | 111 | }; | ... | ... |
inst/com/pyext/GCOMResponse.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMResponse.i - COMPTEL Response class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -66,6 +66,7 @@ public: |
| 66 | 66 | const std::string& rspname(void) const; |
| 67 | 67 | void load(const std::string& rspname); |
| 68 | 68 | void read(const GFitsImage& hdu); |
| 69 | + void write(GFitsImageFloat& image) const; | |
| 69 | 70 | }; |
| 70 | 71 | |
| 71 | 72 | |
| ... | ... | @@ -76,4 +77,14 @@ public: |
| 76 | 77 | GCOMResponse copy() { |
| 77 | 78 | return (*self); |
| 78 | 79 | } |
| 80 | +%pythoncode { | |
| 81 | + def __getstate__(self): | |
| 82 | + image = gammalib.GFitsImageFloat() | |
| 83 | + self.write(image) | |
| 84 | + state = (image,) | |
| 85 | + return state | |
| 86 | + def __setstate__(self, state): | |
| 87 | + self.__init__() | |
| 88 | + self.read(state[0]) | |
| 89 | +} | |
| 79 | 90 | }; | ... | ... |
inst/com/pyext/GCOMRoi.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMRoi.i - COMPTEL region of interest class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -69,4 +69,11 @@ public: |
| 69 | 69 | GCOMRoi copy() { |
| 70 | 70 | return (*self); |
| 71 | 71 | } |
| 72 | +%pythoncode { | |
| 73 | + def __getstate__(self): | |
| 74 | + state = (self.centre(), self.radius(), self.phibar_min(), self.phibar_max()) | |
| 75 | + return state | |
| 76 | + def __setstate__(self, state): | |
| 77 | + self.__init__(state[0], state[1], state[2], state[3]) | |
| 78 | +} | |
| 72 | 79 | }; | ... | ... |
inst/com/pyext/GCOMTim.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMTim.i - COMPTEL Good Time Intervals class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knodlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knodlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,7 @@ class GCOMTim : public GBase { |
| 39 | 39 | public: |
| 40 | 40 | // Constructors and destructors |
| 41 | 41 | GCOMTim(void); |
| 42 | + explicit GCOMTim(const GGti& gti); | |
| 42 | 43 | GCOMTim(const GCOMTim& tim); |
| 43 | 44 | GCOMTim(const GFilename& filename, const std::string& usage = "", |
| 44 | 45 | const std::string& mode = ""); |
| ... | ... | @@ -67,4 +68,11 @@ public: |
| 67 | 68 | GCOMTim copy() { |
| 68 | 69 | return (*self); |
| 69 | 70 | } |
| 71 | +%pythoncode { | |
| 72 | + def __getstate__(self): | |
| 73 | + state = (self.gti(),) | |
| 74 | + return state | |
| 75 | + def __setstate__(self, state): | |
| 76 | + self.__init__(state[0]) | |
| 77 | +} | |
| 70 | 78 | }; | ... | ... |
inst/com/src/GCOMD1Response.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMD1Response.cpp - COMPTEL D1 module response class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -30,6 +30,10 @@ |
| 30 | 30 | #endif |
| 31 | 31 | #include "GMath.hpp" |
| 32 | 32 | #include "GCOMD1Response.hpp" |
| 33 | +#include "GFitsTable.hpp" | |
| 34 | +#include "GFitsBinTable.hpp" | |
| 35 | +#include "GFitsTableFloatCol.hpp" | |
| 36 | +#include "GFitsTableDoubleCol.hpp" | |
| 33 | 37 | |
| 34 | 38 | /* __ Method name definitions ____________________________________________ */ |
| 35 | 39 | |
| ... | ... | @@ -359,6 +363,63 @@ void GCOMD1Response::read(const GFitsTable& table) |
| 359 | 363 | |
| 360 | 364 | |
| 361 | 365 | /***********************************************************************//** |
| 366 | + * @brief Write COMPTEL D1 module response. | |
| 367 | + * | |
| 368 | + * @param[in] table FITS table. | |
| 369 | + * | |
| 370 | + * Write the COMPTEL D1 module response into a SDA FITS table. | |
| 371 | + ***************************************************************************/ | |
| 372 | +void GCOMD1Response::write(GFitsBinTable& table) | |
| 373 | +{ | |
| 374 | + // Set extension name | |
| 375 | + table.extname("SDA"); | |
| 376 | + | |
| 377 | + // Set number of entries | |
| 378 | + int num = m_energies.size(); | |
| 379 | + | |
| 380 | + // Allocate columns | |
| 381 | + GFitsTableFloatCol col_energy("ENERGY", num); | |
| 382 | + GFitsTableDoubleCol col_position("POSITION", num); | |
| 383 | + GFitsTableDoubleCol col_width("WIDTH", num); | |
| 384 | + GFitsTableDoubleCol col_amplitude("AMPLITUDE", num); | |
| 385 | + GFitsTableDoubleCol col_emin("EMIN", num); | |
| 386 | + GFitsTableDoubleCol col_ewidth("EWIDTH", num); | |
| 387 | + GFitsTableDoubleCol col_emax("EMAX", num); | |
| 388 | + | |
| 389 | + // Set column units | |
| 390 | + col_energy.unit("MeV"); | |
| 391 | + col_position.unit("MeV"); | |
| 392 | + col_width.unit("MeV"); | |
| 393 | + col_emin.unit("MeV"); | |
| 394 | + col_ewidth.unit("MeV"); | |
| 395 | + col_emax.unit("MeV"); | |
| 396 | + | |
| 397 | + // Copy data from vectors into table | |
| 398 | + for (int i = 0; i < num; ++i) { | |
| 399 | + col_energy(i) = m_energies[i]; | |
| 400 | + col_position(i) = m_positions[i]; | |
| 401 | + col_width(i) = m_sigmas[i]; | |
| 402 | + col_amplitude(i) = m_amplitudes[i]; | |
| 403 | + col_emin(i) = m_emins[i]; | |
| 404 | + col_ewidth(i) = m_ewidths[i]; | |
| 405 | + col_emax(i) = m_emaxs[i]; | |
| 406 | + } | |
| 407 | + | |
| 408 | + // Append columns to table | |
| 409 | + table.append(col_energy); | |
| 410 | + table.append(col_position); | |
| 411 | + table.append(col_width); | |
| 412 | + table.append(col_amplitude); | |
| 413 | + table.append(col_emin); | |
| 414 | + table.append(col_ewidth); | |
| 415 | + table.append(col_emax); | |
| 416 | + | |
| 417 | + // Return | |
| 418 | + return; | |
| 419 | +} | |
| 420 | + | |
| 421 | + | |
| 422 | +/***********************************************************************//** | |
| 362 | 423 | * @brief Print COMPTEL D1 module response information |
| 363 | 424 | * |
| 364 | 425 | * @param[in] chatter Chattiness. | ... | ... |
inst/com/src/GCOMD2Response.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMD2Response.cpp - COMPTEL D2 module response class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -31,6 +31,10 @@ |
| 31 | 31 | #include "GMath.hpp" |
| 32 | 32 | #include "GIntegral.hpp" |
| 33 | 33 | #include "GCOMD2Response.hpp" |
| 34 | +#include "GFitsTable.hpp" | |
| 35 | +#include "GFitsBinTable.hpp" | |
| 36 | +#include "GFitsTableFloatCol.hpp" | |
| 37 | +#include "GFitsTableDoubleCol.hpp" | |
| 34 | 38 | |
| 35 | 39 | /* __ Method name definitions ____________________________________________ */ |
| 36 | 40 | |
| ... | ... | @@ -352,6 +356,75 @@ void GCOMD2Response::read(const GFitsTable& table) |
| 352 | 356 | |
| 353 | 357 | |
| 354 | 358 | /***********************************************************************//** |
| 359 | + * @brief Write COMPTEL D2 module response. | |
| 360 | + * | |
| 361 | + * @param[in] table FITS table. | |
| 362 | + * | |
| 363 | + * Write the COMPTEL D2 module response into a SDB FITS table. | |
| 364 | + ***************************************************************************/ | |
| 365 | +void GCOMD2Response::write(GFitsBinTable& table) | |
| 366 | +{ | |
| 367 | + // Set extension name | |
| 368 | + table.extname("SDB"); | |
| 369 | + | |
| 370 | + // Set number of entries | |
| 371 | + int num = m_energies.size(); | |
| 372 | + | |
| 373 | + // Allocate columns | |
| 374 | + GFitsTableFloatCol col_energy("ENERGY", num); | |
| 375 | + GFitsTableDoubleCol col_position("POSITION", num); | |
| 376 | + GFitsTableDoubleCol col_width("WIDTH", num); | |
| 377 | + GFitsTableDoubleCol col_amplitude("AMPLITUDE", num); | |
| 378 | + GFitsTableDoubleCol col_escape1("ESCAPE1", num); | |
| 379 | + GFitsTableDoubleCol col_escape2("ESCAPE2", num); | |
| 380 | + GFitsTableDoubleCol col_tail("TAIL", num); | |
| 381 | + GFitsTableDoubleCol col_background("BACKGROUND", num); | |
| 382 | + GFitsTableDoubleCol col_emin("EMIN", num); | |
| 383 | + GFitsTableDoubleCol col_ewidth("EWIDTH", num); | |
| 384 | + GFitsTableDoubleCol col_emax("EMAX", num); | |
| 385 | + | |
| 386 | + // Set column units | |
| 387 | + col_energy.unit("MeV"); | |
| 388 | + col_position.unit("MeV"); | |
| 389 | + col_width.unit("MeV"); | |
| 390 | + col_emin.unit("MeV"); | |
| 391 | + col_ewidth.unit("MeV"); | |
| 392 | + col_emax.unit("MeV"); | |
| 393 | + | |
| 394 | + // Copy data from vectors into table | |
| 395 | + for (int i = 0; i < num; ++i) { | |
| 396 | + col_energy(i) = m_energies[i]; | |
| 397 | + col_position(i) = m_positions[i]; | |
| 398 | + col_width(i) = m_sigmas[i]; | |
| 399 | + col_amplitude(i) = m_amplitudes[i]; | |
| 400 | + col_escape1(i) = m_escapes1[i]; | |
| 401 | + col_escape2(i) = m_escapes2[i]; | |
| 402 | + col_tail(i) = m_tails[i]; | |
| 403 | + col_background(i) = m_backgrounds[i]; | |
| 404 | + col_emin(i) = m_emins[i]; | |
| 405 | + col_ewidth(i) = m_ewidths[i]; | |
| 406 | + col_emax(i) = m_emaxs[i]; | |
| 407 | + } | |
| 408 | + | |
| 409 | + // Append columns to table | |
| 410 | + table.append(col_energy); | |
| 411 | + table.append(col_position); | |
| 412 | + table.append(col_width); | |
| 413 | + table.append(col_amplitude); | |
| 414 | + table.append(col_escape1); | |
| 415 | + table.append(col_escape2); | |
| 416 | + table.append(col_tail); | |
| 417 | + table.append(col_background); | |
| 418 | + table.append(col_emin); | |
| 419 | + table.append(col_ewidth); | |
| 420 | + table.append(col_emax); | |
| 421 | + | |
| 422 | + // Return | |
| 423 | + return; | |
| 424 | +} | |
| 425 | + | |
| 426 | + | |
| 427 | +/***********************************************************************//** | |
| 355 | 428 | * @brief Print COMPTEL D2 module response information |
| 356 | 429 | * |
| 357 | 430 | * @param[in] chatter Chattiness. | ... | ... |
inst/com/src/GCOMDri.cpp
| ... | ... | @@ -861,7 +861,9 @@ void GCOMDri::write(GFits& fits, const std::string& extname) const |
| 861 | 861 | GFitsHDU *image = m_dri.write(fits, extname); |
| 862 | 862 | |
| 863 | 863 | // Write DRI attributes |
| 864 | - write_attributes(image); | |
| 864 | + if (image != NULL) { | |
| 865 | + write_attributes(image); | |
| 866 | + } | |
| 865 | 867 | |
| 866 | 868 | // Return |
| 867 | 869 | return; |
| ... | ... | @@ -1124,7 +1126,9 @@ void GCOMDri::read_attributes(const GFitsHDU* hdu) |
| 1124 | 1126 | GTime tstop = com_time(hdu->integer("VIEDAY"), hdu->integer("VIETIM")); |
| 1125 | 1127 | |
| 1126 | 1128 | // Set Good Time Intervals |
| 1127 | - m_gti = GGti(tstart, tstop); | |
| 1129 | + if (tstop > tstart) { | |
| 1130 | + m_gti = GGti(tstart, tstop); | |
| 1131 | + } | |
| 1128 | 1132 | |
| 1129 | 1133 | // Optionally read Phibar attributes |
| 1130 | 1134 | if (hdu->has_card("CDELT3") && | ... | ... |
inst/com/src/GCOMEventBin.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMEventBin.cpp - COMPTEL event bin class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -34,6 +34,20 @@ |
| 34 | 34 | #include "GTools.hpp" |
| 35 | 35 | |
| 36 | 36 | /* __ Method name definitions ____________________________________________ */ |
| 37 | +#define G_DIR_GET "GCOMEventBin::dir()" | |
| 38 | +#define G_ENERGY_GET "GCOMEventBin::energy()" | |
| 39 | +#define G_TIME_GET "GCOMEventBin::time()" | |
| 40 | +#define G_COUNTS_GET "GCOMEventBin::counts()" | |
| 41 | +#define G_SOLIDANGLE_GET "GCOMEventBin::solidangle()" | |
| 42 | +#define G_EWIDTH_GET "GCOMEventBin::ewidth()" | |
| 43 | +#define G_ONTIME_GET "GCOMEventBin::ontime()" | |
| 44 | +#define G_DIR_SET "GCOMEventBin::dir(GCOMInstDir&)" | |
| 45 | +#define G_ENERGY_SET "GCOMEventBin::energy(GEnergy&)" | |
| 46 | +#define G_TIME_SET "GCOMEventBin::time(GTime&)" | |
| 47 | +#define G_COUNTS_SET "GCOMEventBin::counts(double&)" | |
| 48 | +#define G_SOLIDANGLE_SET "GCOMEventBin::solidangle(double&)" | |
| 49 | +#define G_EWIDTH_SET "GCOMEventBin::ewidth(GEnergy&)" | |
| 50 | +#define G_ONTIME_SET "GCOMEventBin::ontime(double&)" | |
| 37 | 51 | |
| 38 | 52 | /* __ Macros _____________________________________________________________ */ |
| 39 | 53 | |
| ... | ... | @@ -190,6 +204,98 @@ double GCOMEventBin::size(void) const |
| 190 | 204 | |
| 191 | 205 | |
| 192 | 206 | /***********************************************************************//** |
| 207 | + * @brief Return instrument direction of event bin | |
| 208 | + * | |
| 209 | + * @return Instrument direction of event bin | |
| 210 | + * | |
| 211 | + * @exception GException::invalid_value | |
| 212 | + * Invalid instrument direction pointer. | |
| 213 | + * | |
| 214 | + * Returns reference to the instrument direction of the event bin. | |
| 215 | + ***************************************************************************/ | |
| 216 | +const GCOMInstDir& GCOMEventBin::dir(void) const | |
| 217 | +{ | |
| 218 | + // Throw an exception if instrument direction pointer is not valid | |
| 219 | + if (m_dir == NULL) { | |
| 220 | + std::string msg = "No valid instrument direction found in event bin"; | |
| 221 | + throw GException::invalid_value(G_DIR_GET, msg); | |
| 222 | + } | |
| 223 | + | |
| 224 | + // Return instrument direction | |
| 225 | + return *m_dir; | |
| 226 | +} | |
| 227 | + | |
| 228 | + | |
| 229 | +/***********************************************************************//** | |
| 230 | + * @brief Return energy of event bin | |
| 231 | + * | |
| 232 | + * @return Energy of event bin | |
| 233 | + * | |
| 234 | + * @exception GException::invalid_value | |
| 235 | + * Invalid energy pointer. | |
| 236 | + * | |
| 237 | + * Returns reference to the energy of the event bin. | |
| 238 | + ***************************************************************************/ | |
| 239 | +const GEnergy& GCOMEventBin::energy(void) const | |
| 240 | +{ | |
| 241 | + // Throw an exception if energy pointer is not valid | |
| 242 | + if (m_energy == NULL) { | |
| 243 | + std::string msg = "No valid energy found in event bin"; | |
| 244 | + throw GException::invalid_value(G_ENERGY_GET, msg); | |
| 245 | + } | |
| 246 | + | |
| 247 | + // Return energy | |
| 248 | + return *m_energy; | |
| 249 | +} | |
| 250 | + | |
| 251 | + | |
| 252 | +/***********************************************************************//** | |
| 253 | + * @brief Return time of event bin | |
| 254 | + * | |
| 255 | + * @return Time of event bin | |
| 256 | + * | |
| 257 | + * @exception GException::invalid_value | |
| 258 | + * Invalid time pointer. | |
| 259 | + * | |
| 260 | + * Returns reference to the time of the event bin. | |
| 261 | + ***************************************************************************/ | |
| 262 | +const GTime& GCOMEventBin::time(void) const | |
| 263 | +{ | |
| 264 | + // Throw an exception if time pointer is not valid | |
| 265 | + if (m_energy == NULL) { | |
| 266 | + std::string msg = "No valid time found in event bin"; | |
| 267 | + throw GException::invalid_value(G_TIME_GET, msg); | |
| 268 | + } | |
| 269 | + | |
| 270 | + // Return time | |
| 271 | + return *m_time; | |
| 272 | +} | |
| 273 | + | |
| 274 | + | |
| 275 | +/***********************************************************************//** | |
| 276 | + * @brief Return number of counts in event bin | |
| 277 | + * | |
| 278 | + * @return Number of counts in event bin | |
| 279 | + * | |
| 280 | + * @exception GCTAException::invalid_value | |
| 281 | + * Invalid counts pointer. | |
| 282 | + * | |
| 283 | + * Returns reference to the number of counts in the event bin. | |
| 284 | + ***************************************************************************/ | |
| 285 | +double GCOMEventBin::counts(void) const | |
| 286 | +{ | |
| 287 | + // Throw an exception if counts pointer is not valid | |
| 288 | + if (m_counts == NULL) { | |
| 289 | + std::string msg = "No valid counts found in event bin"; | |
| 290 | + throw GException::invalid_value(G_COUNTS_GET, msg); | |
| 291 | + } | |
| 292 | + | |
| 293 | + // Return counts | |
| 294 | + return *m_counts; | |
| 295 | +} | |
| 296 | + | |
| 297 | + | |
| 298 | +/***********************************************************************//** | |
| 193 | 299 | * @brief Return error in number of counts |
| 194 | 300 | * |
| 195 | 301 | * @return Error in number of counts in event bin. |
| ... | ... | @@ -213,6 +319,257 @@ double GCOMEventBin::error(void) const |
| 213 | 319 | |
| 214 | 320 | |
| 215 | 321 | /***********************************************************************//** |
| 322 | + * @brief Return solid angle of event bin | |
| 323 | + * | |
| 324 | + * @return Solid angle of event bin | |
| 325 | + * | |
| 326 | + * @exception GException::invalid_value | |
| 327 | + * Invalid solid angle pointer. | |
| 328 | + * | |
| 329 | + * Returns reference to the solid angle of the event bin. | |
| 330 | + ***************************************************************************/ | |
| 331 | +const double& GCOMEventBin::solidangle(void) const | |
| 332 | +{ | |
| 333 | + // Throw an exception if counts pointer is not valid | |
| 334 | + if (m_solidangle == NULL) { | |
| 335 | + std::string msg = "No valid solid angle found in event bin"; | |
| 336 | + throw GException::invalid_value(G_SOLIDANGLE_GET, msg); | |
| 337 | + } | |
| 338 | + | |
| 339 | + // Return solid angle | |
| 340 | + return *m_solidangle; | |
| 341 | +} | |
| 342 | + | |
| 343 | + | |
| 344 | +/***********************************************************************//** | |
| 345 | + * @brief Return energy width of event bin | |
| 346 | + * | |
| 347 | + * @return Energy width of event bin | |
| 348 | + * | |
| 349 | + * @exception GException::invalid_value | |
| 350 | + * Invalid energy width pointer. | |
| 351 | + * | |
| 352 | + * Returns reference to the energy width of the event bin. | |
| 353 | + ***************************************************************************/ | |
| 354 | +const GEnergy& GCOMEventBin::ewidth(void) const | |
| 355 | +{ | |
| 356 | + // Throw an exception if energy width pointer is not valid | |
| 357 | + if (m_ewidth == NULL) { | |
| 358 | + std::string msg = "No valid energy width found in event bin"; | |
| 359 | + throw GException::invalid_value(G_EWIDTH_GET, msg); | |
| 360 | + } | |
| 361 | + | |
| 362 | + // Return energy width | |
| 363 | + return *m_ewidth; | |
| 364 | +} | |
| 365 | + | |
| 366 | + | |
| 367 | +/***********************************************************************//** | |
| 368 | + * @brief Return ontime of event bin | |
| 369 | + * | |
| 370 | + * @return Ontime of event bin | |
| 371 | + * | |
| 372 | + * @exception GException::invalid_value | |
| 373 | + * Invalid ontime pointer. | |
| 374 | + * | |
| 375 | + * Returns reference to the ontime of the event bin. | |
| 376 | + ***************************************************************************/ | |
| 377 | +const double& GCOMEventBin::ontime(void) const | |
| 378 | +{ | |
| 379 | + // Throw an exception if energy width pointer is not valid | |
| 380 | + if (m_ontime == NULL) { | |
| 381 | + std::string msg = "No valid ontime found in event bin"; | |
| 382 | + throw GException::invalid_value(G_ONTIME_GET, msg); | |
| 383 | + } | |
| 384 | + | |
| 385 | + // Return ontime | |
| 386 | + return *m_ontime; | |
| 387 | +} | |
| 388 | + | |
| 389 | + | |
| 390 | +/***********************************************************************//** | |
| 391 | + * @brief Set instrument direction of event bin | |
| 392 | + * | |
| 393 | + * @param[in] dir Instrument direction of event bin | |
| 394 | + * | |
| 395 | + * @exception GException::invalid_value | |
| 396 | + * No memory available to hold instrument direction. | |
| 397 | + * | |
| 398 | + * Sets the instrument direction of the event bin. | |
| 399 | + ***************************************************************************/ | |
| 400 | +void GCOMEventBin::dir(const GCOMInstDir& dir) | |
| 401 | +{ | |
| 402 | + // Throw an exception if no memory has been allocated | |
| 403 | + if (m_dir == NULL) { | |
| 404 | + std::string msg = "No memory available to hold instrument direction."; | |
| 405 | + throw GException::invalid_value(G_DIR_SET, msg); | |
| 406 | + } | |
| 407 | + | |
| 408 | + // Set instrument direction | |
| 409 | + *m_dir = dir; | |
| 410 | + | |
| 411 | + // Return | |
| 412 | + return; | |
| 413 | +} | |
| 414 | + | |
| 415 | + | |
| 416 | +/***********************************************************************//** | |
| 417 | + * @brief Set energy of event bin | |
| 418 | + * | |
| 419 | + * @param[in] energy Energy of event bin | |
| 420 | + * | |
| 421 | + * @exception GException::invalid_value | |
| 422 | + * No memory available to hold energy. | |
| 423 | + * | |
| 424 | + * Sets the energy of the event bin. | |
| 425 | + ***************************************************************************/ | |
| 426 | +void GCOMEventBin::energy(const GEnergy& energy) | |
| 427 | +{ | |
| 428 | + // Throw an exception if no memory has been allocated | |
| 429 | + if (m_energy == NULL) { | |
| 430 | + std::string msg = "No memory available to hold energy."; | |
| 431 | + throw GException::invalid_value(G_ENERGY_SET, msg); | |
| 432 | + } | |
| 433 | + | |
| 434 | + // Set energy | |
| 435 | + *m_energy = energy; | |
| 436 | + | |
| 437 | + // Return | |
| 438 | + return; | |
| 439 | +} | |
| 440 | + | |
| 441 | + | |
| 442 | +/***********************************************************************//** | |
| 443 | + * @brief Set time of event bin | |
| 444 | + * | |
| 445 | + * @param[in] time Time of event bin | |
| 446 | + * | |
| 447 | + * @exception GException::invalid_value | |
| 448 | + * No memory available to hold instrument direction. | |
| 449 | + * | |
| 450 | + * Sets the time of the event bin. | |
| 451 | + ***************************************************************************/ | |
| 452 | +void GCOMEventBin::time(const GTime& time) | |
| 453 | +{ | |
| 454 | + // Throw an exception if no memory has been allocated | |
| 455 | + if (m_time == NULL) { | |
| 456 | + std::string msg = "No memory available to hold time."; | |
| 457 | + throw GException::invalid_value(G_TIME_SET, msg); | |
| 458 | + } | |
| 459 | + | |
| 460 | + // Set time | |
| 461 | + *m_time = time; | |
| 462 | + | |
| 463 | + // Return | |
| 464 | + return; | |
| 465 | +} | |
| 466 | + | |
| 467 | + | |
| 468 | +/***********************************************************************//** | |
| 469 | + * @brief Set number of counts in event bin | |
| 470 | + * | |
| 471 | + * @param[in] counts Number of counts. | |
| 472 | + * | |
| 473 | + * @exception GException::invalid_value | |
| 474 | + * No memory available to hold counts. | |
| 475 | + * | |
| 476 | + * Set the number of counts in the event bin. | |
| 477 | + ***************************************************************************/ | |
| 478 | +void GCOMEventBin::counts(const double& counts) | |
| 479 | +{ | |
| 480 | + // Throw an exception if counts pointer is not valid | |
| 481 | + if (m_counts == NULL) { | |
| 482 | + std::string msg = "No memory available to hold counts."; | |
| 483 | + throw GException::invalid_value(G_COUNTS_SET, msg); | |
| 484 | + } | |
| 485 | + | |
| 486 | + // Set number of counts in event bin | |
| 487 | + *m_counts = counts; | |
| 488 | + | |
| 489 | + // Return | |
| 490 | + return; | |
| 491 | +} | |
| 492 | + | |
| 493 | + | |
| 494 | +/***********************************************************************//** | |
| 495 | + * @brief Set solid angle of event bin | |
| 496 | + * | |
| 497 | + * @param[in] solidangle Solid angle of event bin | |
| 498 | + * | |
| 499 | + * @exception GException::invalid_value | |
| 500 | + * No memory available to hold solid angle. | |
| 501 | + * | |
| 502 | + * Sets the solid angle of the event bin. | |
| 503 | + ***************************************************************************/ | |
| 504 | +void GCOMEventBin::solidangle(const double& solidangle) | |
| 505 | +{ | |
| 506 | + // Throw an exception if no memory has been allocated | |
| 507 | + if (m_solidangle == NULL) { | |
| 508 | + std::string msg = "No memory available to hold solid angle."; | |
| 509 | + throw GException::invalid_value(G_SOLIDANGLE_SET, msg); | |
| 510 | + } | |
| 511 | + | |
| 512 | + // Set solid angle | |
| 513 | + *m_solidangle = solidangle; | |
| 514 | + | |
| 515 | + // Return | |
| 516 | + return; | |
| 517 | +} | |
| 518 | + | |
| 519 | + | |
| 520 | +/***********************************************************************//** | |
| 521 | + * @brief Set energy width of event bin | |
| 522 | + * | |
| 523 | + * @param[in] ewidth Energy width of event bin | |
| 524 | + * | |
| 525 | + * @exception GException::invalid_value | |
| 526 | + * No memory available to hold energy width. | |
| 527 | + * | |
| 528 | + * Sets the energy width of the event bin. | |
| 529 | + ***************************************************************************/ | |
| 530 | +void GCOMEventBin::ewidth(const GEnergy& ewidth) | |
| 531 | +{ | |
| 532 | + // Throw an exception if no memory has been allocated | |
| 533 | + if (m_ewidth == NULL) { | |
| 534 | + std::string msg = "No memory available to hold energy width."; | |
| 535 | + throw GException::invalid_value(G_EWIDTH_SET, msg); | |
| 536 | + } | |
| 537 | + | |
| 538 | + // Set energy width | |
| 539 | + *m_ewidth = ewidth; | |
| 540 | + | |
| 541 | + // Return | |
| 542 | + return; | |
| 543 | +} | |
| 544 | + | |
| 545 | + | |
| 546 | +/***********************************************************************//** | |
| 547 | + * @brief Set ontime of event bin | |
| 548 | + * | |
| 549 | + * @param[in] ontime Ontime of event bin (sec). | |
| 550 | + * | |
| 551 | + * @exception GException::invalid_value | |
| 552 | + * No memory available to hold ontime. | |
| 553 | + * | |
| 554 | + * Sets the ontime of the event bin. | |
| 555 | + ***************************************************************************/ | |
| 556 | +void GCOMEventBin::ontime(const double& ontime) | |
| 557 | +{ | |
| 558 | + // Throw an exception if no memory has been allocated | |
| 559 | + if (m_ontime == NULL) { | |
| 560 | + std::string msg = "No memory available to hold ontime."; | |
| 561 | + throw GException::invalid_value(G_ONTIME_SET, msg); | |
| 562 | + } | |
| 563 | + | |
| 564 | + // Set solid angle | |
| 565 | + *m_ontime = ontime; | |
| 566 | + | |
| 567 | + // Return | |
| 568 | + return; | |
| 569 | +} | |
| 570 | + | |
| 571 | + | |
| 572 | +/***********************************************************************//** | |
| 216 | 573 | * @brief Print event information |
| 217 | 574 | * |
| 218 | 575 | * @param[in] chatter Chattiness (defaults to NORMAL). | ... | ... |
inst/com/src/GCOMEventList.cpp
| ... | ... | @@ -333,7 +333,7 @@ void GCOMEventList::read(const GFits& file) |
| 333 | 333 | * |
| 334 | 334 | * @param[in] file FITS file. |
| 335 | 335 | * |
| 336 | - * Write the LCOMPTELAT event list into FITS file. | |
| 336 | + * Write the COMPTEL event list into FITS file. | |
| 337 | 337 | * |
| 338 | 338 | * @todo Implement method. |
| 339 | 339 | ***************************************************************************/ | ... | ... |
inst/com/src/GCOMModelDRBFitting.cpp
inst/com/src/GCOMObservation.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMObservation.cpp - COMPTEL Observation class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -85,6 +85,27 @@ GCOMObservation::GCOMObservation(void) : GObservation() |
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | /***********************************************************************//** |
| 88 | + * @brief XML constructor | |
| 89 | + * | |
| 90 | + * @param[in] xml XML element. | |
| 91 | + * | |
| 92 | + * Constructs a COMPTEL observation from the information that is found in an | |
| 93 | + * XML element. | |
| 94 | + ***************************************************************************/ | |
| 95 | +GCOMObservation::GCOMObservation(const GXmlElement& xml) : GObservation() | |
| 96 | +{ | |
| 97 | + // Initialise members | |
| 98 | + init_members(); | |
| 99 | + | |
| 100 | + // Read XML | |
| 101 | + read(xml); | |
| 102 | + | |
| 103 | + // Return | |
| 104 | + return; | |
| 105 | +} | |
| 106 | + | |
| 107 | + | |
| 108 | +/***********************************************************************//** | |
| 88 | 109 | * @brief Binned observation constructor |
| 89 | 110 | * |
| 90 | 111 | * @param[in] drename Event cube name. |
| ... | ... | @@ -487,7 +508,7 @@ void GCOMObservation::write(GXmlElement& xml) const |
| 487 | 508 | par->attribute("file", gammalib::xml_file_reduce(xml, m_drxname)); |
| 488 | 509 | |
| 489 | 510 | // Set IAQ parameter |
| 490 | - par = gammalib::xml_need_par(G_WRITE, xml, "DRX"); | |
| 511 | + par = gammalib::xml_need_par(G_WRITE, xml, "IAQ"); | |
| 491 | 512 | par->attribute("value", m_response.rspname()); |
| 492 | 513 | |
| 493 | 514 | } // endif: observation was binned | ... | ... |
inst/com/src/GCOMResponse.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMResponse.cpp - COMPTEL Response class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -41,6 +41,7 @@ |
| 41 | 41 | #include "GTime.hpp" |
| 42 | 42 | #include "GObservation.hpp" |
| 43 | 43 | #include "GFitsImage.hpp" |
| 44 | +#include "GFitsImageFloat.hpp" | |
| 44 | 45 | #include "GModelSky.hpp" |
| 45 | 46 | #include "GModelSpatialPointSource.hpp" |
| 46 | 47 | #include "GCOMResponse.hpp" |
| ... | ... | @@ -592,47 +593,107 @@ void GCOMResponse::load(const std::string& rspname) |
| 592 | 593 | ***************************************************************************/ |
| 593 | 594 | void GCOMResponse::read(const GFitsImage& image) |
| 594 | 595 | { |
| 595 | - // Store IAQ dimensions | |
| 596 | - m_phigeo_bins = image.naxes(0); | |
| 597 | - m_phibar_bins = image.naxes(1); | |
| 598 | - | |
| 599 | - // Store IAQ axes definitions | |
| 600 | - m_phigeo_ref_value = image.real("CRVAL1"); | |
| 601 | - m_phigeo_ref_pixel = image.real("CRPIX1"); | |
| 602 | - m_phigeo_bin_size = image.real("CDELT1"); | |
| 603 | - m_phibar_ref_value = image.real("CRVAL2"); | |
| 604 | - m_phibar_ref_pixel = image.real("CRPIX2"); | |
| 605 | - m_phibar_bin_size = image.real("CDELT2"); | |
| 606 | - | |
| 607 | - // Get axes minima (values of first bin) | |
| 608 | - m_phigeo_min = m_phigeo_ref_value + (1.0-m_phigeo_ref_pixel) * m_phigeo_bin_size; | |
| 609 | - m_phibar_min = m_phibar_ref_value + (1.0-m_phibar_ref_pixel) * m_phibar_bin_size; | |
| 610 | - | |
| 611 | - // Compute IAQ size. Continue only if size is positive | |
| 612 | - int size = m_phigeo_bins * m_phibar_bins; | |
| 613 | - if (size > 0) { | |
| 614 | - | |
| 615 | - // Allocate memory for IAQ | |
| 616 | - m_iaq.assign(size, 0.0); | |
| 617 | - | |
| 618 | - // Copy over IAQ values | |
| 619 | - for (int i = 0; i < size; ++i) { | |
| 620 | - m_iaq[i] = image.pixel(i); | |
| 596 | + // Continue only if there are two image axis | |
| 597 | + if (image.naxis() == 2) { | |
| 598 | + | |
| 599 | + // Store IAQ dimensions | |
| 600 | + m_phigeo_bins = image.naxes(0); | |
| 601 | + m_phibar_bins = image.naxes(1); | |
| 602 | + | |
| 603 | + // Store IAQ axes definitions | |
| 604 | + m_phigeo_ref_value = image.real("CRVAL1"); | |
| 605 | + m_phigeo_ref_pixel = image.real("CRPIX1"); | |
| 606 | + m_phigeo_bin_size = image.real("CDELT1"); | |
| 607 | + m_phibar_ref_value = image.real("CRVAL2"); | |
| 608 | + m_phibar_ref_pixel = image.real("CRPIX2"); | |
| 609 | + m_phibar_bin_size = image.real("CDELT2"); | |
| 610 | + | |
| 611 | + // Get axes minima (values of first bin) | |
| 612 | + m_phigeo_min = m_phigeo_ref_value + (1.0-m_phigeo_ref_pixel) * m_phigeo_bin_size; | |
| 613 | + m_phibar_min = m_phibar_ref_value + (1.0-m_phibar_ref_pixel) * m_phibar_bin_size; | |
| 614 | + | |
| 615 | + // Compute IAQ size. Continue only if size is positive | |
| 616 | + int size = m_phigeo_bins * m_phibar_bins; | |
| 617 | + if (size > 0) { | |
| 618 | + | |
| 619 | + // Allocate memory for IAQ | |
| 620 | + m_iaq.assign(size, 0.0); | |
| 621 | + | |
| 622 | + // Copy over IAQ values | |
| 623 | + for (int i = 0; i < size; ++i) { | |
| 624 | + m_iaq[i] = image.pixel(i); | |
| 625 | + } | |
| 626 | + | |
| 627 | + } // endif: size was positive | |
| 628 | + | |
| 629 | + // Convert IAQ matrix from probability per Phigeo bin into a | |
| 630 | + // probability per steradian | |
| 631 | + double omega0 = gammalib::fourpi * | |
| 632 | + std::sin(0.5 * m_phigeo_bin_size * gammalib::deg2rad); | |
| 633 | + for (int iphigeo = 0; iphigeo < m_phigeo_bins; ++iphigeo) { | |
| 634 | + double phigeo = iphigeo * m_phigeo_bin_size + m_phigeo_min; | |
| 635 | + double omega = omega0 * std::sin(phigeo * gammalib::deg2rad); | |
| 636 | + for (int iphibar = 0; iphibar < m_phibar_bins; ++iphibar) { | |
| 637 | + m_iaq[iphigeo+iphibar*m_phigeo_bins] /= omega; | |
| 638 | + } | |
| 621 | 639 | } |
| 622 | 640 | |
| 623 | - } // endif: size was positive | |
| 624 | - | |
| 625 | - // Convert IAQ matrix from probability per Phigeo bin into a | |
| 626 | - // probability per steradian | |
| 627 | - double omega0 = gammalib::fourpi * | |
| 628 | - std::sin(0.5 * m_phigeo_bin_size * gammalib::deg2rad); | |
| 629 | - for (int iphigeo = 0; iphigeo < m_phigeo_bins; ++iphigeo) { | |
| 630 | - double phigeo = iphigeo * m_phigeo_bin_size + m_phigeo_min; | |
| 631 | - double omega = omega0 * std::sin(phigeo * gammalib::deg2rad); | |
| 632 | - for (int iphibar = 0; iphibar < m_phibar_bins; ++iphibar) { | |
| 633 | - m_iaq[iphigeo+iphibar*m_phigeo_bins] /= omega; | |
| 641 | + } // endif: image had two axes | |
| 642 | + | |
| 643 | + // Return | |
| 644 | + return; | |
| 645 | +} | |
| 646 | + | |
| 647 | + | |
| 648 | +/***********************************************************************//** | |
| 649 | + * @brief Write COMPTEL response into FITS image. | |
| 650 | + * | |
| 651 | + * @param[in] image FITS image. | |
| 652 | + * | |
| 653 | + * Writes the COMPTEL response into an IAQ FITS file. | |
| 654 | + ***************************************************************************/ | |
| 655 | +void GCOMResponse::write(GFitsImageFloat& image) const | |
| 656 | +{ | |
| 657 | + // Continue only if response is not empty | |
| 658 | + if (m_phigeo_bins > 0 && m_phibar_bins > 0) { | |
| 659 | + | |
| 660 | + // Initialise image | |
| 661 | + image = GFitsImageFloat(m_phigeo_bins, m_phibar_bins); | |
| 662 | + | |
| 663 | + // Convert IAQ matrix from probability per steradian into | |
| 664 | + //probability per Phigeo bin | |
| 665 | + double omega0 = gammalib::fourpi * | |
| 666 | + std::sin(0.5 * m_phigeo_bin_size * gammalib::deg2rad); | |
| 667 | + for (int iphigeo = 0; iphigeo < m_phigeo_bins; ++iphigeo) { | |
| 668 | + double phigeo = iphigeo * m_phigeo_bin_size + m_phigeo_min; | |
| 669 | + double omega = omega0 * std::sin(phigeo * gammalib::deg2rad); | |
| 670 | + for (int iphibar = 0; iphibar < m_phibar_bins; ++iphibar) { | |
| 671 | + int i = iphigeo + iphibar*m_phigeo_bins; | |
| 672 | + image(iphigeo, iphibar) = m_iaq[i] * omega; | |
| 673 | + } | |
| 634 | 674 | } |
| 635 | - } | |
| 675 | + | |
| 676 | + // Set header keywords | |
| 677 | + image.card("CTYPE1", "Phigeo", "Geometrical scatter angle"); | |
| 678 | + image.card("CRVAL1", m_phigeo_ref_value, | |
| 679 | + "[deg] Geometrical scatter angle for reference bin"); | |
| 680 | + image.card("CDELT1", m_phigeo_bin_size, | |
| 681 | + "[deg] Geometrical scatter angle bin size"); | |
| 682 | + image.card("CRPIX1", m_phigeo_ref_pixel, | |
| 683 | + "Reference bin of geometrical scatter angle"); | |
| 684 | + image.card("CTYPE2", "Phibar", "Compton scatter angle"); | |
| 685 | + image.card("CRVAL2", m_phibar_ref_value, | |
| 686 | + "[deg] Compton scatter angle for reference bin"); | |
| 687 | + image.card("CDELT2", m_phibar_bin_size, "[deg] Compton scatter angle bin size"); | |
| 688 | + image.card("CRPIX2", m_phibar_ref_pixel, | |
| 689 | + "Reference bin of Compton scatter angle"); | |
| 690 | + image.card("BUNIT", "Probability per bin", "Unit of bins"); | |
| 691 | + image.card("TELESCOP", "GRO", "Name of telescope"); | |
| 692 | + image.card("INSTRUME", "COMPTEL", "Name of instrument"); | |
| 693 | + image.card("ORIGIN", "GammaLib", "Origin of FITS file"); | |
| 694 | + image.card("OBSERVER", "Unknown", "Observer that created FITS file"); | |
| 695 | + | |
| 696 | + } // endif: response was not empty | |
| 636 | 697 | |
| 637 | 698 | // Return |
| 638 | 699 | return; | ... | ... |
inst/com/src/GCOMTim.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCOMTim.cpp - COMPTEL Good Time Intervals class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2017 by Juergen Knodlseder * | |
| 4 | + * copyright (C) 2017-2018 by Juergen Knodlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -63,6 +63,24 @@ GCOMTim::GCOMTim(void) |
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | /***********************************************************************//** |
| 66 | + * @brief Good Time Interval constructor | |
| 67 | + * | |
| 68 | + * @param[in] gti Good Time Intervals. | |
| 69 | + ***************************************************************************/ | |
| 70 | +GCOMTim::GCOMTim(const GGti& gti) | |
| 71 | +{ | |
| 72 | + // Initialise class members | |
| 73 | + init_members(); | |
| 74 | + | |
| 75 | + // Set GTIs | |
| 76 | + m_gti = gti; | |
| 77 | + | |
| 78 | + // Return | |
| 79 | + return; | |
| 80 | +} | |
| 81 | + | |
| 82 | + | |
| 83 | +/***********************************************************************//** | |
| 66 | 84 | * @brief Copy constructor |
| 67 | 85 | * |
| 68 | 86 | * @param[in] tim COMPTEL Good Time Intervals. | ... | ... |
inst/com/test/caldb/data/cgro/comptel/bcf/m10371_sda.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/m10564_sdb.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/m16845_iaq.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/module_status.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/plaw2_0.75-1MeV_iaq.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/plaw2_1-3MeV_iaq.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/plaw2_10-30MeV_iaq.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/plaw2_3-10MeV_iaq.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/r00004_ict.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/u09517_iaq.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/u47512_iaq.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/u47569_iaq.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/u47741_iaq.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/bcf/u48091_iaq.fits.gz
0 → 100644
No preview for this file type
inst/com/test/caldb/data/cgro/comptel/caldb.indx
0 → 100644
No preview for this file type
inst/com/test/test_COM.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib COMPTEL module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2012-2015 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2012-2018 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -17,7 +17,9 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | +import os | |
| 20 | 21 | import gammalib |
| 22 | +import test_support | |
| 21 | 23 | |
| 22 | 24 | |
| 23 | 25 | # ====================================== # |
| ... | ... | @@ -25,12 +27,12 @@ import gammalib |
| 25 | 27 | # ====================================== # |
| 26 | 28 | class Test(gammalib.GPythonTestSuite): |
| 27 | 29 | """ |
| 28 | - Test class for GammaLib COMPTEL module. | |
| 30 | + Test class for GammaLib COMPTEL module | |
| 29 | 31 | """ |
| 30 | 32 | # Constructor |
| 31 | 33 | def __init__(self): |
| 32 | 34 | """ |
| 33 | - Constructor. | |
| 35 | + Constructor | |
| 34 | 36 | """ |
| 35 | 37 | # Call base class constructor |
| 36 | 38 | gammalib.GPythonTestSuite.__init__(self) |
| ... | ... | @@ -38,24 +40,127 @@ class Test(gammalib.GPythonTestSuite): |
| 38 | 40 | # Return |
| 39 | 41 | return |
| 40 | 42 | |
| 41 | - # Set test functions | |
| 42 | - def set(self): | |
| 43 | + # Test class pickeling | |
| 44 | + def _test_pickeling(self): | |
| 43 | 45 | """ |
| 44 | - Set all test functions. | |
| 46 | + Test class pickeling | |
| 45 | 47 | """ |
| 46 | - # Set test name | |
| 47 | - self.name("COMPTEL") | |
| 48 | + # Set CALDB | |
| 49 | + os.environ['CALDB'] = os.environ['TEST_COM_DATA']+'/../caldb' | |
| 48 | 50 | |
| 49 | - # Append tests | |
| 50 | - self.append(self.test, "COMPTEL dummy test") | |
| 51 | + # Perform pickeling tests of empty classes | |
| 52 | + test_support._pickeling(self, gammalib.GCOMD1Response()) | |
| 53 | + test_support._pickeling(self, gammalib.GCOMD2Response()) | |
| 54 | + test_support._pickeling(self, gammalib.GCOMDri()) | |
| 55 | + test_support._pickeling(self, gammalib.GCOMEventAtom()) | |
| 56 | + test_support._pickeling(self, gammalib.GCOMEventBin()) | |
| 57 | + test_support._pickeling(self, gammalib.GCOMEventCube()) | |
| 58 | + test_support._pickeling(self, gammalib.GCOMEventList()) | |
| 59 | + #test_support._pickeling(self, gammalib.GCOMIaq()) | |
| 60 | + #test_support._pickeling(self, gammalib.GCOMInstChars()) | |
| 61 | + test_support._pickeling(self, gammalib.GCOMInstDir()) | |
| 62 | + test_support._pickeling(self, gammalib.GCOMModelDRBFitting()) | |
| 63 | + test_support._pickeling(self, gammalib.GCOMOad()) | |
| 64 | + test_support._pickeling(self, gammalib.GCOMOads()) | |
| 65 | + test_support._pickeling(self, gammalib.GCOMObservation()) | |
| 66 | + test_support._pickeling(self, gammalib.GCOMResponse()) | |
| 67 | + test_support._pickeling(self, gammalib.GCOMRoi()) | |
| 68 | + #test_support._pickeling(self, gammalib.GCOMSelection()) | |
| 69 | + #test_support._pickeling(self, gammalib.GCOMStatus()) | |
| 70 | + test_support._pickeling(self, gammalib.GCOMTim()) | |
| 71 | + | |
| 72 | + # Setup test | |
| 73 | + caldb = gammalib.GCaldb('cgro','comptel') | |
| 74 | + dir = gammalib.GSkyDir() | |
| 75 | + instdir = gammalib.GCOMInstDir(dir, 10.0) | |
| 76 | + energy = gammalib.GEnergy(1.0,'MeV') | |
| 77 | + time = gammalib.GTime(1.0,'sec') | |
| 78 | + map = gammalib.GSkyMap('CAR','GAL',0.0,0.0,1.0,1.0,10,10,10) | |
| 79 | + dri = gammalib.GCOMDri(map, 0.0, 2.0, 10) | |
| 80 | + atom = gammalib.GCOMEventAtom() | |
| 81 | + ebds = gammalib.GEbounds(1,gammalib.GEnergy(0.75,'MeV'),gammalib.GEnergy(30.0,'MeV')) | |
| 82 | + gti = gammalib.GGti(gammalib.GTime(1.0,'secs'),gammalib.GTime(3.0,'secs')) | |
| 83 | + dre = gammalib.GCOMDri(map, 0.0, 2.0, 10) | |
| 84 | + obs = gammalib.GObservations(os.environ['TEST_COM_DATA']+'/obs.xml') | |
| 85 | + model = gammalib.GModels(os.environ['TEST_COM_DATA']+'/crab.xml') | |
| 86 | + dre.ebounds(ebds) | |
| 87 | + dre.gti(gti) | |
| 88 | + atom.dir(instdir) | |
| 89 | + atom.energy(energy) | |
| 90 | + atom.time(time) | |
| 91 | + atom.e1(100.0) | |
| 92 | + atom.e2(200.0) | |
| 93 | + atom.phibar(11.1) | |
| 94 | + atom.theta(22.2) | |
| 95 | + atom.phi(33.3) | |
| 96 | + atom.eha(44.4) | |
| 97 | + atom.psd(55.5) | |
| 98 | + atom.tof(66.6) | |
| 99 | + atom.modcom(1) | |
| 100 | + atom.reflag(2) | |
| 101 | + atom.veto(3) | |
| 102 | + list = gammalib.GCOMEventList() | |
| 103 | + list.append(atom) | |
| 104 | + bin = gammalib.GCOMEventBin() | |
| 105 | + bin.dir(instdir) | |
| 106 | + bin.energy(energy) | |
| 107 | + bin.time(time) | |
| 108 | + bin.counts(11.0) | |
| 109 | + bin.solidangle(11.0) | |
| 110 | + bin.ewidth(energy) | |
| 111 | + bin.ontime(111.0) | |
| 112 | + oad = gammalib.GCOMOad() | |
| 113 | + oad.tstart(gammalib.GTime(1.0,'secs')) | |
| 114 | + oad.tstop(gammalib.GTime(3.0,'secs')) | |
| 115 | + oad.zaxis(dir) | |
| 116 | + oad.xaxis(dir) | |
| 117 | + oad.tjd(1000) | |
| 118 | + oad.tics(100) | |
| 119 | + oad.gcaz(10.0) | |
| 120 | + oad.gcel(20.0) | |
| 121 | + oad.georad(30.0) | |
| 122 | + oads = gammalib.GCOMOads() | |
| 123 | + oads.append(oad) | |
| 124 | + | |
| 125 | + # Take provision for rounding errors | |
| 126 | + fits = gammalib.GFits() | |
| 127 | + dre.write(fits) | |
| 128 | + dre.read(fits[0]) | |
| 129 | + | |
| 130 | + # Perform pickeling tests of filled classes | |
| 131 | + test_support._pickeling(self, gammalib.GCOMD1Response(caldb,'DEFAULT')) | |
| 132 | + test_support._pickeling(self, gammalib.GCOMD2Response(caldb,'DEFAULT')) | |
| 133 | + test_support._pickeling(self, gammalib.GCOMDri(dri)) | |
| 134 | + test_support._pickeling(self, gammalib.GCOMEventAtom(atom)) | |
| 135 | + test_support._pickeling(self, gammalib.GCOMEventBin(bin)) | |
| 136 | + test_support._pickeling(self, gammalib.GCOMEventCube(dre)) | |
| 137 | + test_support._pickeling(self, gammalib.GCOMEventList(list)) | |
| 138 | + #test_support._pickeling(self, gammalib.GCOMIaq()) | |
| 139 | + #test_support._pickeling(self, gammalib.GCOMInstChars(caldb,'DEFAULT')) | |
| 140 | + test_support._pickeling(self, gammalib.GCOMInstDir(instdir)) | |
| 141 | + test_support._pickeling(self, gammalib.GCOMModelDRBFitting(model['Background'])) | |
| 142 | + test_support._pickeling(self, gammalib.GCOMOad(oad)) | |
| 143 | + test_support._pickeling(self, gammalib.GCOMOads(oads)) | |
| 144 | + test_support._pickeling(self, gammalib.GCOMObservation(obs[0])) | |
| 145 | + test_support._pickeling(self, gammalib.GCOMResponse(caldb, 'UNH(1.0-3.0)MeV')) | |
| 146 | + test_support._pickeling(self, gammalib.GCOMRoi(instdir, 10.0, 1.0, 5.0)) | |
| 147 | + #test_support._pickeling(self, gammalib.GCOMSelection()) | |
| 148 | + #test_support._pickeling(self, gammalib.GCOMStatus()) | |
| 149 | + test_support._pickeling(self, gammalib.GCOMTim(gti)) | |
| 51 | 150 | |
| 52 | 151 | # Return |
| 53 | 152 | return |
| 54 | 153 | |
| 55 | - # Test function | |
| 56 | - def test(self): | |
| 154 | + # Set test functions | |
| 155 | + def set(self): | |
| 57 | 156 | """ |
| 58 | - Test function. | |
| 157 | + Set all test functions | |
| 59 | 158 | """ |
| 159 | + # Set test name | |
| 160 | + self.name('COMPTEL') | |
| 161 | + | |
| 162 | + # Append tests | |
| 163 | + self.append(self._test_pickeling, 'Test COMPTEL class pickeling') | |
| 164 | + | |
| 60 | 165 | # Return |
| 61 | 166 | return | ... | ... |
inst/cta/src/GCTAEventBin.cpp
| ... | ... | @@ -277,7 +277,7 @@ const GTime& GCTAEventBin::time(void) const |
| 277 | 277 | * |
| 278 | 278 | * @return Number of counts in event bin |
| 279 | 279 | * |
| 280 | - * @exception GCTAException::no_member | |
| 280 | + * @exception GCTAException::invalid_value | |
| 281 | 281 | * Invalid counts pointer. |
| 282 | 282 | * |
| 283 | 283 | * Returns reference to the number of counts in the event bin. | ... | ... |
pyext/Makefile.am
| ... | ... | @@ -165,6 +165,25 @@ if WITH_INST_CTA |
| 165 | 165 | testdc1cta_DATA = $(testdc1cta) |
| 166 | 166 | endif |
| 167 | 167 | |
| 168 | +# Distribute COM test data (optionally) | |
| 169 | +if WITH_INST_COM | |
| 170 | + testdatacom = $(top_srcdir)/inst/com/test/data/obs.xml \ | |
| 171 | + $(top_srcdir)/inst/com/test/data/crab.xml \ | |
| 172 | + $(top_srcdir)/inst/com/test/data/m32171_drx.fits.gz \ | |
| 173 | + $(top_srcdir)/inst/com/test/data/m34997_drg.fits.gz \ | |
| 174 | + $(top_srcdir)/inst/com/test/data/m50439_dre.fits.gz | |
| 175 | + testdatacomdir = $(pyexecdir)/gammalib/tests/com/data | |
| 176 | + testdatacom_DATA = $(testdatacom) | |
| 177 | + testcaldbcom = $(top_srcdir)/inst/com/test/caldb/data/cgro/comptel/caldb.indx | |
| 178 | + testcaldbcomdir = $(pyexecdir)/gammalib/tests/com/caldb/data/cgro/comptel | |
| 179 | + testcaldbcom_DATA = $(testcaldbcom) | |
| 180 | + testirfcom = $(top_srcdir)/inst/com/test/caldb/data/cgro/comptel/bcf/m10371_sda.fits.gz \ | |
| 181 | + $(top_srcdir)/inst/com/test/caldb/data/cgro/comptel/bcf/m10564_sdb.fits.gz \ | |
| 182 | + $(top_srcdir)/inst/com/test/caldb/data/cgro/comptel/bcf/u47569_iaq.fits.gz | |
| 183 | + testirfcomdir = $(pyexecdir)/gammalib/tests/com/caldb/data/cgro/comptel/bcf | |
| 184 | + testirfcom_DATA = $(testirfcom) | |
| 185 | +endif | |
| 186 | + | |
| 168 | 187 | # If building of Python wrappers was requested then add them to the build |
| 169 | 188 | # source |
| 170 | 189 | if BUILD_WRAPPERS | ... | ... |