GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMDri.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMDri.hpp - COMPTEL Data Space class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2017-2019 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GCOMDri.hpp
23  * @brief COMPTEL Data Space class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCOMDRI_HPP
28 #define GCOMDRI_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 #include "GSkyMap.hpp"
34 #include "GEbounds.hpp"
35 #include "GGti.hpp"
36 #include "GCOMSelection.hpp"
37 
38 /* __ Forward declarations _______________________________________________ */
39 class GFilename;
40 class GFits;
41 class GFitsImage;
42 class GModel;
43 class GModelSky;
44 class GCOMOad;
45 class GCOMTim;
46 class GCOMStatus;
47 class GCOMObservation;
48 
49 /* __ Constants __________________________________________________________ */
50 namespace gammalib {
51  const std::string extname_dri = "DRI";
52 }
53 
54 
55 /***********************************************************************//**
56  * @class GCOMDri
57  *
58  * @brief COMPTEL Data Space class
59  ***************************************************************************/
60 class GCOMDri : public GBase {
61 
62 public:
63  // Constructors and destructors
64  GCOMDri(void);
65  explicit GCOMDri(const GFilename& filename);
66  GCOMDri(const GSkyMap& map, const double& phimin = 0.0,
67  const double& phibin = 0.0,
68  const int& nphibin = 0);
69  GCOMDri(const GCOMDri& dri);
70  virtual ~GCOMDri(void);
71 
72  // Operators
73  GCOMDri& operator=(const GCOMDri& dri);
74  double& operator[](const int& index);
75  const double& operator[](const int& index) const;
76 
77  // Implemented pure virtual base class methods
78  virtual void clear(void);
79  virtual GCOMDri* clone(void) const;
80  virtual std::string classname(void) const;
81  virtual std::string print(const GChatter& chatter = NORMAL) const;
82 
83  // Other methods
84  int size(void) const;
85  int nchi(void) const;
86  int npsi(void) const;
87  int nphibar(void) const;
88  const GSkyMap& map(void) const;
89  const std::string& name(void) const;
90  void name(const std::string& name);
91  const GEbounds& ebounds(void) const;
92  void ebounds(const GEbounds&);
93  const GGti& gti(void) const;
94  void gti(const GGti& gti);
95  const double& phimin(void) const;
96  const double& phibin(void) const;
97  void compute_dre(const GCOMObservation& obs,
98  const GCOMSelection& select = GCOMSelection(),
99  const double& zetamin = 5.0);
100  void compute_drg(const GCOMObservation& obs,
101  const GCOMSelection& select = GCOMSelection(),
102  const double& zetamin = 5.0);
103  void compute_drx(const GCOMObservation& obs);
104  void compute_drm(const GCOMObservation& obs,
105  const GModel& model);
106  double cone_content(const GSkyDir& dir,
107  const double& armmin,
108  const double& armmax) const;
109  void load(const GFilename& filename);
110  void save(const GFilename& filename,
111  const bool& clobber = false) const;
112  void read(const GFitsImage& image);
113  void write(GFits& fits,
114  const std::string& extname = "") const;
115 
116 protected:
117  // Protected methods
118  void init_members(void);
119  void copy_members(const GCOMDri& dri);
120  void free_members(void);
121  void init_cube(void);
122  void init_statistics(void);
123  bool use_superpacket(const GCOMOad &oad, const GCOMTim& tim);
124  void read_attributes(const GFitsHDU* hdu);
125  void write_attributes(GFitsHDU* hdu) const;
126  double compute_geometry(const int& tjd, const double& theta,
127  const double& phi,
128  const GCOMStatus& status) const;
129  void compute_drm_ptsrc(const GCOMObservation& obs,
130  const GModelSky& model);
131 
132  // Protected members
133  std::string m_name; //!< Data cube name
134  GSkyMap m_dri; //!< Data cube
135  GEbounds m_ebounds; //!< Energy boundaries of data cube
136  GGti m_gti; //!< Good Time Intervals of data cube
137  double m_phimin; //!< Phibar minimum (deg)
138  double m_phibin; //!< Phibar binsize (deg)
139 
140  // Computation statistics
141  GTime m_tstart; //!< Selection start time
142  GTime m_tstop; //!< Selection stop time
143  int m_num_superpackets; //!< Number of superpackets
144  int m_num_used_superpackets; //!< Number of used superpackets
145  int m_num_skipped_superpackets; //!< Number of skipped superpackets
146 
147  // Selection parameters
148  GCOMSelection m_selection; //!< Selection parameters
149  double m_zetamin; //!< Minimum zeta angle
150 };
151 
152 
153 /***********************************************************************//**
154  * @brief Return class name
155  *
156  * @return String containing the class name ("GCOMDri").
157  ***************************************************************************/
158 inline
159 std::string GCOMDri::classname(void) const
160 {
161  return ("GCOMDri");
162 }
163 
164 
165 /***********************************************************************//**
166  * @brief DRI bin access operators
167  *
168  * @param[in] index DRI bin index [0,...,size()-1].
169  * @return Reference to DRI bin.
170  ***************************************************************************/
171 inline
172 double& GCOMDri::operator[](const int& index)
173 {
174  return (const_cast<double&>((m_dri.pixels()[index])));
175 }
176 
177 
178 /***********************************************************************//**
179  * @brief DRI bin access operators (const version)
180  *
181  * @param[in] index DRI bin index [0,...,size()-1].
182  * @return Reference to DRI bin.
183  ***************************************************************************/
184 inline
185 const double& GCOMDri::operator[](const int& index) const
186 {
187  return (m_dri.pixels()[index]);
188 }
189 
190 
191 /***********************************************************************//**
192  * @brief Return number of bins
193  *
194  * @return Number of bins.
195  ***************************************************************************/
196 inline
197 int GCOMDri::size(void) const
198 {
199  return (m_dri.npix()*m_dri.nmaps());
200 }
201 
202 
203 /***********************************************************************//**
204  * @brief Return number of Chi bins
205  *
206  * @return Number of Chi bins.
207  ***************************************************************************/
208 inline
209 int GCOMDri::nchi(void) const
210 {
211  return (m_dri.nx());
212 }
213 
214 
215 /***********************************************************************//**
216  * @brief Return number of Psi bins
217  *
218  * @return Number of Psi bins.
219  ***************************************************************************/
220 inline
221 int GCOMDri::npsi(void) const
222 {
223  return (m_dri.ny());
224 }
225 
226 
227 /***********************************************************************//**
228  * @brief Return number of Phibar bins
229  *
230  * @return Number of Phibar bins.
231  ***************************************************************************/
232 inline
233 int GCOMDri::nphibar(void) const
234 {
235  return (m_dri.nmaps());
236 }
237 
238 
239 /***********************************************************************//**
240  * @brief Return DRI sky map
241  *
242  * @return Sky map containing DRI data.
243  ***************************************************************************/
244 inline
245 const GSkyMap& GCOMDri::map(void) const
246 {
247  return (m_dri);
248 }
249 
250 
251 /***********************************************************************//**
252  * @brief Return DRI cube name
253  *
254  * @return DRI cube name.
255  ***************************************************************************/
256 inline
257 const std::string& GCOMDri::name(void) const
258 {
259  return (m_name);
260 }
261 
262 
263 /***********************************************************************//**
264  * @brief Set DRI cube name
265  *
266  * @param[in] name DRI cube name.
267  *
268  * Sets the name of the DRI cube.
269  ***************************************************************************/
270 inline
271 void GCOMDri::name(const std::string& name)
272 {
273  m_name = name;
274  return;
275 }
276 
277 
278 /***********************************************************************//**
279  * @brief Return energy boundaries of DRI cube
280  *
281  * @return Energy boundaries of DRI cube.
282  ***************************************************************************/
283 inline
284 const GEbounds& GCOMDri::ebounds(void) const
285 {
286  return (m_ebounds);
287 }
288 
289 
290 /***********************************************************************//**
291  * @brief Set energy boundaries of DRI cube
292  *
293  * @param[in] ebounds Energy boundaries of DRI cube.
294  *
295  * Sets energy boundaries of DRI cube
296  ***************************************************************************/
297 inline
298 void GCOMDri::ebounds(const GEbounds& ebounds)
299 {
300  m_ebounds = ebounds;
301  return;
302 }
303 
304 
305 /***********************************************************************//**
306  * @brief Return Good Time Intervals of DRI cube
307  *
308  * @return Good Time Intervals of DRI cube.
309  ***************************************************************************/
310 inline
311 const GGti& GCOMDri::gti(void) const
312 {
313  return (m_gti);
314 }
315 
316 
317 /***********************************************************************//**
318  * @brief Set Good Time Intervals of DRI cube
319  *
320  * @param[in] gti Good Time Intervals of DRI data.
321  *
322  * Sets the Good Time Intervals of DRI cube.
323  ***************************************************************************/
324 inline
325 void GCOMDri::gti(const GGti& gti)
326 {
327  m_gti = gti;
328  return;
329 }
330 
331 
332 /***********************************************************************//**
333  * @brief Return minimum Compton scatter angle of DRI cube
334  *
335  * @return Minimum Compton scatter angle of DRI cube (deg).
336  ***************************************************************************/
337 inline
338 const double& GCOMDri::phimin(void) const
339 {
340  return (m_phimin);
341 }
342 
343 
344 /***********************************************************************//**
345  * @brief Return Compton scatter angle bin of DRI cube
346  *
347  * @return Compton scatter angle bin of DRI cube (deg).
348  ***************************************************************************/
349 inline
350 const double& GCOMDri::phibin(void) const
351 {
352  return (m_phibin);
353 }
354 
355 #endif /* GCOMDRI_HPP */
COMPTEL instrument status class.
Definition: GCOMStatus.hpp:49
void compute_drm_ptsrc(const GCOMObservation &obs, const GModelSky &model)
Compute DRM model for a point source.
Definition: GCOMDri.cpp:1430
Abstract model class.
Definition: GModel.hpp:97
Sky map class.
Definition: GSkyMap.hpp:89
Abstract FITS image base class.
Definition: GFitsImage.hpp:43
const int & ny(void) const
Returns number of pixels in y coordinate.
Definition: GSkyMap.hpp:366
GTime m_tstart
Selection start time.
Definition: GCOMDri.hpp:141
GCOMSelection m_selection
Selection parameters.
Definition: GCOMDri.hpp:148
const double & phimin(void) const
Return minimum Compton scatter angle of DRI cube.
Definition: GCOMDri.hpp:338
int size(void) const
Return number of bins.
Definition: GCOMDri.hpp:197
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
GSkyMap m_dri
Data cube.
Definition: GCOMDri.hpp:134
double m_phibin
Phibar binsize (deg)
Definition: GCOMDri.hpp:138
void compute_drg(const GCOMObservation &obs, const GCOMSelection &select=GCOMSelection(), const double &zetamin=5.0)
Compute geometry cube.
Definition: GCOMDri.cpp:506
double compute_geometry(const int &tjd, const double &theta, const double &phi, const GCOMStatus &status) const
Compute DRG geometry factor.
Definition: GCOMDri.cpp:1303
void write_attributes(GFitsHDU *hdu) const
Write DRI attributes into FITS HDU.
Definition: GCOMDri.cpp:1245
Definition of interface for all GammaLib classes.
double & operator[](const int &index)
DRI bin access operators.
Definition: GCOMDri.hpp:172
int m_num_superpackets
Number of superpackets.
Definition: GCOMDri.hpp:143
Time class.
Definition: GTime.hpp:54
FITS file class.
Definition: GFits.hpp:63
int nchi(void) const
Return number of Chi bins.
Definition: GCOMDri.hpp:209
GCOMDri(void)
Void constructor.
Definition: GCOMDri.cpp:84
COMPTEL selection set class.
Sky map class definition.
COMPTEL Orbit Aspect Data class.
Definition: GCOMOad.hpp:48
Good time interval class interface definition.
COMPTEL selection set class definition.
void copy_members(const GCOMDri &dri)
Copy class members.
Definition: GCOMDri.cpp:1046
virtual GCOMDri * clone(void) const
Clone COMPTEL Data Space.
Definition: GCOMDri.cpp:241
double cone_content(const GSkyDir &dir, const double &armmin, const double &armmax) const
Compute content in cone.
Definition: GCOMDri.cpp:794
Energy boundaries container class.
Definition: GEbounds.hpp:60
const GEbounds & ebounds(void) const
Return energy boundaries of DRI cube.
Definition: GCOMDri.hpp:284
const int & nmaps(void) const
Returns number of maps.
Definition: GSkyMap.hpp:378
void init_cube(void)
Initialise DRI cube.
Definition: GCOMDri.cpp:1087
Filename class.
Definition: GFilename.hpp:62
GTime m_tstop
Selection stop time.
Definition: GCOMDri.hpp:142
void write(GFits &fits, const std::string &extname="") const
Write COMPTEL Data Space into FITS image.
Definition: GCOMDri.cpp:915
void compute_drm(const GCOMObservation &obs, const GModel &model)
Compute DRM model.
Definition: GCOMDri.cpp:741
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
const GSkyMap & map(void) const
Return DRI sky map.
Definition: GCOMDri.hpp:245
int m_num_skipped_superpackets
Number of skipped superpackets.
Definition: GCOMDri.hpp:145
GChatter
Definition: GTypemaps.hpp:33
void free_members(void)
Delete class members.
Definition: GCOMDri.cpp:1075
void save(const GFilename &filename, const bool &clobber=false) const
Save COMPTEL Data Space into DRI FITS file.
Definition: GCOMDri.cpp:866
Good Time Interval class.
Definition: GGti.hpp:62
virtual ~GCOMDri(void)
Destructor.
Definition: GCOMDri.cpp:171
int nphibar(void) const
Return number of Phibar bins.
Definition: GCOMDri.hpp:233
GCOMDri & operator=(const GCOMDri &dri)
Assignment operator.
Definition: GCOMDri.cpp:193
const GGti & gti(void) const
Return Good Time Intervals of DRI cube.
Definition: GCOMDri.hpp:311
const std::string extname_dri
Definition: GCOMDri.hpp:51
void init_statistics(void)
Initialise computation statistics.
Definition: GCOMDri.cpp:1102
Sky model class.
Definition: GModelSky.hpp:120
virtual void clear(void)
Clear COMPTEL Data Space.
Definition: GCOMDri.cpp:223
virtual std::string classname(void) const
Return class name.
Definition: GCOMDri.hpp:159
void read(const GFitsImage &image)
Read COMPTEL Data Space from DRI FITS image.
Definition: GCOMDri.cpp:890
void init_members(void)
Initialise class members.
Definition: GCOMDri.cpp:1019
GGti m_gti
Good Time Intervals of data cube.
Definition: GCOMDri.hpp:136
Interface class for COMPTEL observations.
int npsi(void) const
Return number of Psi bins.
Definition: GCOMDri.hpp:221
void load(const GFilename &filename)
Load COMPTEL Data Space from DRI FITS file.
Definition: GCOMDri.cpp:841
GEbounds m_ebounds
Energy boundaries of data cube.
Definition: GCOMDri.hpp:135
Energy boundaries class interface definition.
void compute_dre(const GCOMObservation &obs, const GCOMSelection &select=GCOMSelection(), const double &zetamin=5.0)
Compute event cube.
Definition: GCOMDri.cpp:259
const int & nx(void) const
Returns number of pixels in x coordinate.
Definition: GSkyMap.hpp:350
COMPTEL Data Space class.
Definition: GCOMDri.hpp:60
int m_num_used_superpackets
Number of used superpackets.
Definition: GCOMDri.hpp:144
double m_zetamin
Minimum zeta angle.
Definition: GCOMDri.hpp:149
void compute_drx(const GCOMObservation &obs)
Compute DRX exposure map.
Definition: GCOMDri.cpp:640
COMPTEL Good Time Intervals class.
Definition: GCOMTim.hpp:50
bool use_superpacket(const GCOMOad &oad, const GCOMTim &tim)
Check if superpacket should be used.
Definition: GCOMDri.cpp:1128
const std::string & name(void) const
Return DRI cube name.
Definition: GCOMDri.hpp:257
const int & npix(void) const
Returns number of pixels.
Definition: GSkyMap.hpp:334
const double & phibin(void) const
Return Compton scatter angle bin of DRI cube.
Definition: GCOMDri.hpp:350
void read_attributes(const GFitsHDU *hdu)
Read DRI attributes from FITS HDU.
Definition: GCOMDri.cpp:1179
Sky direction class.
Definition: GSkyDir.hpp:62
virtual std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL Data Space.
Definition: GCOMDri.cpp:936
const double * pixels(void) const
Returns pointer to pixel data.
Definition: GSkyMap.hpp:426
double m_phimin
Phibar minimum (deg)
Definition: GCOMDri.hpp:137
std::string m_name
Data cube name.
Definition: GCOMDri.hpp:133