GammaLib 2.0.0
Loading...
Searching...
No Matches
GMWLSpectrum.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GMWLSpectrum.hpp - Multi-wavelength spectrum class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-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 GMWLSpectrum.hpp
23 * @brief Multi-wavelength spectrum class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GMWLSPECTRUM_HPP
28#define GMWLSPECTRUM_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GEventCube.hpp"
33#include "GMWLDatum.hpp"
34#include "GFitsTable.hpp"
35#include "GEnergy.hpp"
36
37/* __ Forward declarations _______________________________________________ */
38class GFilename;
39
40
41/***********************************************************************//**
42 * @class GMWLSpectrum
43 *
44 * @brief Multi-wavelength spectrum class interface
45 *
46 * This class defines a multi-wavelength spectrum and is a container for
47 * spectral points of type GMWLDatum. It derives from the abstract
48 * GEventCube base class.
49 ***************************************************************************/
50class GMWLSpectrum : public GEventCube {
51
52public:
53 // Constructors and destructors
54 GMWLSpectrum(void);
55 explicit GMWLSpectrum(const GFilename& filename);
56 GMWLSpectrum(const GMWLSpectrum& spec);
57 virtual ~GMWLSpectrum(void);
58
59 // Operators
60 virtual GMWLSpectrum& operator=(const GMWLSpectrum& spec);
61 virtual GMWLDatum* operator[](const int& index);
62 virtual const GMWLDatum* operator[](const int& index) const;
63
64 // Implemented pure virtual methods
65 virtual void clear(void);
66 virtual GMWLSpectrum* clone(void) const;
67 virtual std::string classname(void) const;
68 virtual int size(void) const;
69 virtual int dim(void) const;
70 virtual int naxis(const int& axis) const;
71 virtual void load(const GFilename& filename);
72 virtual void save(const GFilename& filename,
73 const bool& clobber = false) const;
74 virtual void read(const GFits& file);
75 virtual void write(GFits& file) const;
76 virtual int number(void) const;
77 virtual std::string print(const GChatter& chatter = NORMAL) const;
78
79 // Other methods
80 void read(const GFits& file, const std::string& extname);
81 void read(const GFits& file, const int& extno);
82 const std::string& telescope(void) const;
83 const std::string& instrument(void) const;
84
85protected:
86 // Protected methods
87 void init_members(void);
88 void copy_members(const GMWLSpectrum& spec);
89 void free_members(void);
90 void set_ebounds(void);
91 void read_fits(const GFitsTable& table);
92 GEnergy conv_energy(const double& energy, const std::string& unit);
93 double conv_flux(const GEnergy& energy, const double& flux,
94 const std::string& unit);
95
96 // Protected members
97 std::string m_telescope; //!< Telescope name
98 std::string m_instrument; //!< Instrument name
99 std::vector<GMWLDatum> m_data; //!< Spectral data
100};
101
102
103/***********************************************************************//**
104 * @brief Return class name
105 *
106 * @return String containing the class name ("GMWLSpectrum").
107 ***************************************************************************/
108inline
109std::string GMWLSpectrum::classname(void) const
110{
111 return ("GMWLSpectrum");
112}
113
114
115/***********************************************************************//**
116 * @brief Return number of spectral bins
117 *
118 * @return Number of bins in spectrum.
119 ***************************************************************************/
120inline
121int GMWLSpectrum::size(void) const
122{
123 return (int)m_data.size();
124}
125
126
127/***********************************************************************//**
128 * @brief Return dimension of spectrum
129 *
130 * @return Dimension of spectrum (always 1).
131 ***************************************************************************/
132inline
133int GMWLSpectrum::dim(void) const
134{
135 return 1;
136}
137
138
139/***********************************************************************//**
140 * @brief Return number of spectral bins per dimension
141 *
142 * @param[in] axis Axis (ignored).
143 * @return Number of bins in spectrum.
144 ***************************************************************************/
145inline
146int GMWLSpectrum::naxis(const int& axis) const
147{
148 return (int)m_data.size();
149}
150
151
152/***********************************************************************//**
153 * @brief Return telescope name
154 *
155 * @return Telescope name.
156 ***************************************************************************/
157inline
158const std::string& GMWLSpectrum::telescope(void) const
159{
160 return m_telescope;
161}
162
163
164/***********************************************************************//**
165 * @brief Return instrument name
166 *
167 * @return Instrument name.
168 ***************************************************************************/
169inline
170const std::string& GMWLSpectrum::instrument(void) const
171{
172 return m_instrument;
173}
174
175#endif /* GMWLSPECTRUM_HPP */
Energy value class definition.
Abstract event bin container class interface definition.
FITS table abstract base class interface definition.
Multi-wavelength spectral point class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract event bin container class.
Filename class.
Definition GFilename.hpp:62
Abstract interface for FITS table.
FITS file class.
Definition GFits.hpp:63
Multi-wavelength spectral point class.
Definition GMWLDatum.hpp:45
Multi-wavelength spectrum class interface.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print spectrum.
virtual void load(const GFilename &filename)
Load spectrum.
virtual int dim(void) const
Return dimension of spectrum.
void free_members(void)
Delete class members.
virtual void read(const GFits &file)
Read spectrum from FITS file.
GEnergy conv_energy(const double &energy, const std::string &unit)
Convert value into energy.
std::string m_telescope
Telescope name.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save spectrum.
virtual GMWLSpectrum & operator=(const GMWLSpectrum &spec)
Assignment operator.
virtual void clear(void)
Clear spectrum.
virtual int naxis(const int &axis) const
Return number of spectral bins per dimension.
virtual GMWLDatum * operator[](const int &index)
Spectral point access operator.
double conv_flux(const GEnergy &energy, const double &flux, const std::string &unit)
Convert value into flux.
void init_members(void)
Initialise class members.
void copy_members(const GMWLSpectrum &spec)
Copy class members.
const std::string & telescope(void) const
Return telescope name.
virtual ~GMWLSpectrum(void)
Destructor.
virtual std::string classname(void) const
Return class name.
virtual GMWLSpectrum * clone(void) const
Clone spectrum.
std::string m_instrument
Instrument name.
GMWLSpectrum(void)
Void constructor.
virtual void write(GFits &file) const
Write spectrum into FITS file.
virtual int size(void) const
Return number of spectral bins.
void set_ebounds(void)
Set energy boundaries.
virtual int number(void) const
Return number of points in spectrum.
void read_fits(const GFitsTable &table)
Read spectrum from FITS file.
std::vector< GMWLDatum > m_data
Spectral data.
const std::string & instrument(void) const
Return instrument name.