GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLATEventCube.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GLATEventCube.hpp - Fermi/LAT event cube class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2009-2016 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 GLATEventCube.hpp
23  * @brief Fermi/LAT event cube class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GLATEVENTCUBE_HPP
28 #define GLATEVENTCUBE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GEventCube.hpp"
34 #include "GLATInstDir.hpp"
35 #include "GLATEventBin.hpp"
36 #include "GEnergy.hpp"
37 #include "GTime.hpp"
38 #include "GFits.hpp"
39 #include "GFitsImage.hpp"
40 #include "GFitsTable.hpp"
41 #include "GSkyMap.hpp"
42 #include "GNodeArray.hpp"
43 
44 /* __ Forward declarations _______________________________________________ */
45 class GFilename;
46 
47 
48 /***********************************************************************//**
49  * @class GLATEventCube
50  *
51  * @brief Fermi/LAT event cube class
52  ***************************************************************************/
53 class GLATEventCube : public GEventCube {
54 
55 public:
56  // Constructors and destructors
57  GLATEventCube(void);
58  explicit GLATEventCube(const GFilename& filename);
59  GLATEventCube(const GLATEventCube& cube);
60  virtual ~GLATEventCube(void);
61 
62  // Operators
63  virtual GLATEventCube& operator=(const GLATEventCube& cube);
64  virtual GLATEventBin* operator[](const int& index);
65  virtual const GLATEventBin* operator[](const int& index) const;
66 
67  // Implemented pure virtual base class methods
68  virtual void clear(void);
69  virtual GLATEventCube* clone(void) const;
70  virtual std::string classname(void) const;
71  virtual int size(void) const;
72  virtual int dim(void) const;
73  virtual int naxis(const int& axis) const;
74  virtual void load(const GFilename& filename);
75  virtual void save(const GFilename& filename,
76  const bool& clobber = false) const;
77  virtual void read(const GFits& file);
78  virtual void write(GFits& file) const;
79  virtual int number(void) const;
80  virtual std::string print(const GChatter& chatter = NORMAL) const;
81 
82  // Other methods
83  void time(const GTime& time);
84  void map(const GSkyMap& map);
85  void enodes(const GNodeArray& enodes);
86  void ontime(const double& ontime);
87  const GTime& time(void) const;
88  const GSkyMap& map(void) const;
89  const GNodeArray& enodes(void) const;
90  const double& ontime(void) const;
91  int nx(void) const;
92  int ny(void) const;
93  int npix(void) const;
94  int ebins(void) const;
95  int ndiffrsp(void) const;
96  std::string diffname(const int& index) const;
97  GSkyMap* diffrsp(const int& index) const;
98  double maxrad(const GSkyDir& dir) const;
99 
100 protected:
101  // Protected methods
102  void init_members(void);
103  void copy_members(const GLATEventCube& cube);
104  void free_members(void);
105  void read_cntmap(const GFitsImage& hdu);
106  void read_srcmap(const GFitsImage& hdu);
107  void read_ebds(const GFitsTable& hdu);
108  void read_gti(const GFitsTable& hdu);
109  void set_directions(void);
110  virtual void set_energies(void);
111  virtual void set_times(void);
112  void set_bin(const int& index);
113 
114  // Protected data area
115  GLATEventBin m_bin; //!< Actual energy bin
116  GSkyMap m_map; //!< Counts map stored as sky map
117  GTime m_time; //!< Event cube mean time
118  double m_ontime; //!< Event cube ontime (sec)
119  std::vector<GLATInstDir> m_dirs; //!< Array of event directions
120  std::vector<double> m_solidangle; //!< Array of solid angles (sr)
121  std::vector<GEnergy> m_energies; //!< Array of log mean energies
122  std::vector<GEnergy> m_ewidth; //!< Array of energy bin widths
123  std::vector<GSkyMap*> m_srcmap; //!< Pointers to source maps
124  std::vector<std::string> m_srcmap_names; //!< Source map names
125  GNodeArray m_enodes; //!< Energy nodes
126 };
127 
128 
129 /***********************************************************************//**
130  * @brief Return class name
131  *
132  * @return String containing the class name ("GLATEventCube").
133  ***************************************************************************/
134 inline
135 std::string GLATEventCube::classname(void) const
136 {
137  return ("GLATEventCube");
138 }
139 
140 
141 /***********************************************************************//**
142  * @brief Set event cube mean time
143  *
144  * @param[in] time Event cube mean time.
145  ***************************************************************************/
146 inline
147 void GLATEventCube::time(const GTime& time)
148 {
149  m_time = time;
150  return;
151 }
152 
153 
154 /***********************************************************************//**
155  * @brief Set event cube energy nodes
156  *
157  * @param[in] enodes Energy nodes.
158  ***************************************************************************/
159 inline
161 {
162  m_enodes = enodes;
163  return;
164 }
165 
166 
167 /***********************************************************************//**
168  * @brief Set event cube ontime
169  *
170  * @param[in] ontime Ontime.
171  ***************************************************************************/
172 inline
173 void GLATEventCube::ontime(const double& ontime)
174 {
175  m_ontime = ontime;
176  return;
177 }
178 
179 
180 /***********************************************************************//**
181  * @brief Return event cube mean time
182  *
183  * @return Event cube mean time.
184  ***************************************************************************/
185 inline
186 const GTime& GLATEventCube::time(void) const
187 {
188  return m_time;
189 }
190 
191 
192 /***********************************************************************//**
193  * @brief Return event cube sky map
194  *
195  * @return Sky map.
196  ***************************************************************************/
197 inline
198 const GSkyMap& GLATEventCube::map(void) const
199 {
200  return m_map;
201 }
202 
203 
204 /***********************************************************************//**
205  * @brief Return event cube energy nodes
206  *
207  * @return Energy nodes.
208  ***************************************************************************/
209 inline
211 {
212  return m_enodes;
213 }
214 
215 
216 /***********************************************************************//**
217  * @brief Return event cube ontime
218  *
219  * @return Ontime.
220  ***************************************************************************/
221 inline
222 const double& GLATEventCube::ontime(void) const
223 {
224  return m_ontime;
225 }
226 
227 
228 /***********************************************************************//**
229  * @brief Return number of bins in X direction
230  *
231  * @return Number of bins in X direction.
232  ***************************************************************************/
233 inline
234 int GLATEventCube::nx(void) const
235 {
236  return m_map.nx();
237 }
238 
239 
240 /***********************************************************************//**
241  * @brief Return number of bins in Y direction
242  *
243  * @return Number of bins in Y direction.
244  ***************************************************************************/
245 inline
246 int GLATEventCube::ny(void) const
247 {
248  return m_map.ny();
249 }
250 
251 
252 /***********************************************************************//**
253  * @brief Return number of pixels in event cube sky map
254  *
255  * @return Number of pixels in event cube sky map.
256  ***************************************************************************/
257 inline
258 int GLATEventCube::npix(void) const
259 {
260  return m_map.npix();
261 }
262 
263 
264 /***********************************************************************//**
265  * @brief Return number of energy bins in event cube
266  *
267  * @return Number of energy bins in event cube.
268  ***************************************************************************/
269 inline
270 int GLATEventCube::ebins(void) const
271 {
272  return m_map.nmaps();
273 }
274 
275 
276 /***********************************************************************//**
277  * @brief Return number of diffuse model components
278  *
279  * @return Number of diffuse model components.
280  ***************************************************************************/
281 inline
282 int GLATEventCube::ndiffrsp(void) const
283 {
284  return (int)m_srcmap.size();
285 }
286 
287 #endif /* GLATEVENTCUBE_HPP */
GTime m_time
Event cube mean time.
virtual int naxis(const int &axis) const
Return number of bins in axis.
Sky map class.
Definition: GSkyMap.hpp:89
GSkyMap * diffrsp(const int &index) const
Return diffuse response map.
Abstract FITS image base class.
Definition: GFitsImage.hpp:43
const int & ny(void) const
Returns number of pixels in y coordinate.
Definition: GSkyMap.hpp:377
Node array class.
Definition: GNodeArray.hpp:60
virtual void set_times(void)
Set mean event time and ontime of event cube.
virtual ~GLATEventCube(void)
Destructor.
Energy value class definition.
int ndiffrsp(void) const
Return number of diffuse model components.
void free_members(void)
Delete class members.
double maxrad(const GSkyDir &dir) const
Computes the maximum radius (in degrees) around a given source direction that fits spatially into the...
virtual void load(const GFilename &filename)
Load LAT event cube from FITS file.
void read_gti(const GFitsTable &hdu)
Read GTIs from HDU.
virtual std::string classname(void) const
Return class name.
Abstract event bin container class interface definition.
int nx(void) const
Return number of bins in X direction.
std::vector< GEnergy > m_ewidth
Array of energy bin widths.
Time class.
Definition: GTime.hpp:55
virtual void read(const GFits &file)
Read LAT event cube from FITS file.
FITS file class.
Definition: GFits.hpp:63
FITS file class interface definition.
Sky map class definition.
virtual int size(void) const
Return number of bins in event cube.
Abstract FITS image base class definition.
virtual void clear(void)
Clear instance.
std::vector< double > m_solidangle
Array of solid angles (sr)
void read_srcmap(const GFitsImage &hdu)
Read LAT source map from HDU.
void set_bin(const int &index)
Set event bin.
Fermi/LAT event bin class.
GNodeArray m_enodes
Energy nodes.
void init_members(void)
Initialise class members.
Node array class interface definition.
GLATEventCube(void)
Void constructor.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save LAT event cube into FITS file.
const GTime & time(void) const
Return event cube mean time.
Fermi/LAT event bin class interface definition.
const int & nmaps(void) const
Returns number of maps.
Definition: GSkyMap.hpp:389
GLATEventBin m_bin
Actual energy bin.
int npix(void) const
Return number of pixels in event cube sky map.
int ebins(void) const
Return number of energy bins in event cube.
Filename class.
Definition: GFilename.hpp:62
virtual GLATEventCube & operator=(const GLATEventCube &cube)
Assignment operator.
virtual void set_energies(void)
Set log mean energies and energy widths of event cube.
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
virtual void write(GFits &file) const
Write LAT event cube into FITS file.
GChatter
Definition: GTypemaps.hpp:33
void copy_members(const GLATEventCube &cube)
Copy class members.
double m_ontime
Event cube ontime (sec)
Fermi/LAT event cube class.
void read_ebds(const GFitsTable &hdu)
Read energy boundaries from HDU.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print event cube information.
std::vector< GSkyMap * > m_srcmap
Pointers to source maps.
std::vector< GEnergy > m_energies
Array of log mean energies.
void set_directions(void)
Set sky directions and solid angles of events cube.
std::vector< GLATInstDir > m_dirs
Array of event directions.
Fermi/LAT instrument direction class definition.
const int & nx(void) const
Returns number of pixels in x coordinate.
Definition: GSkyMap.hpp:361
virtual GLATEventBin * operator[](const int &index)
Event bin access operator.
const GSkyMap & map(void) const
Return event cube sky map.
virtual int number(void) const
Return number of events in cube.
virtual GLATEventCube * clone(void) const
Clone instance.
virtual int dim(void) const
Return dimension of event cube.
void read_cntmap(const GFitsImage &hdu)
Read Fermi/LAT counts map from HDU.
const int & npix(void) const
Returns number of pixels.
Definition: GSkyMap.hpp:345
Sky direction class.
Definition: GSkyDir.hpp:62
Abstract event bin container class.
Definition: GEventCube.hpp:46
Time class interface definition.
int ny(void) const
Return number of bins in Y direction.
const double & ontime(void) const
Return event cube ontime.
std::vector< std::string > m_srcmap_names
Source map names.
GSkyMap m_map
Counts map stored as sky map.
std::string diffname(const int &index) const
Return name of diffuse model.
FITS table abstract base class interface definition.
const GNodeArray & enodes(void) const
Return event cube energy nodes.