GammaLib
2.1.0.dev
|
Multi-wavelength spectrum class interface. More...
#include <GMWLSpectrum.hpp>
Public Member Functions | |
GMWLSpectrum (void) | |
Void constructor. More... | |
GMWLSpectrum (const GFilename &filename) | |
File constructor. More... | |
GMWLSpectrum (const GMWLSpectrum &spec) | |
Copy constructor. More... | |
virtual | ~GMWLSpectrum (void) |
Destructor. More... | |
virtual GMWLSpectrum & | operator= (const GMWLSpectrum &spec) |
Assignment operator. More... | |
virtual GMWLDatum * | operator[] (const int &index) |
Spectral point access operator. More... | |
virtual const GMWLDatum * | operator[] (const int &index) const |
Spectral point access operator (const version) More... | |
virtual void | clear (void) |
Clear spectrum. More... | |
virtual GMWLSpectrum * | clone (void) const |
Clone spectrum. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual int | size (void) const |
Return number of spectral bins. More... | |
virtual int | dim (void) const |
Return dimension of spectrum. More... | |
virtual int | naxis (const int &axis) const |
Return number of spectral bins per dimension. More... | |
virtual void | load (const GFilename &filename) |
Load spectrum. More... | |
virtual void | save (const GFilename &filename, const bool &clobber=false) const |
Save spectrum. More... | |
virtual void | read (const GFits &file) |
Read spectrum from FITS file. More... | |
virtual void | write (GFits &file) const |
Write spectrum into FITS file. More... | |
virtual int | number (void) const |
Return number of points in spectrum. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print spectrum. More... | |
void | read (const GFits &file, const std::string &extname) |
Read spectrum from FITS file. More... | |
void | read (const GFits &file, const int &extno) |
Read spectrum from FITS file. More... | |
const std::string & | telescope (void) const |
Return telescope name. More... | |
const std::string & | instrument (void) const |
Return instrument name. More... | |
Public Member Functions inherited from GEventCube | |
GEventCube (void) | |
Void constructor. More... | |
GEventCube (const GEventCube &cube) | |
Copy constructor. More... | |
virtual | ~GEventCube (void) |
Destructor. More... | |
virtual GEventCube & | operator= (const GEventCube &cube) |
Assignment operator. More... | |
Public Member Functions inherited from GEvents | |
GEvents (void) | |
Void constructor. More... | |
GEvents (const GEvents &events) | |
Copy constructor. More... | |
virtual | ~GEvents (void) |
Destructor. More... | |
virtual GEvents & | operator= (const GEvents &events) |
Assignment operator. More... | |
void | ebounds (const GEbounds &ebounds) |
Set energy boundaries. More... | |
void | gti (const GGti >i) |
Set Good Time Intervals. More... | |
const GEbounds & | ebounds (void) const |
Return energy boundaries. More... | |
const GGti & | gti (void) const |
Return Good Time Intervals. More... | |
const GTime & | tstart (void) const |
Return start time. More... | |
const GTime & | tstop (void) const |
Return stop time. More... | |
const GEnergy & | emin (void) const |
Return minimum energy. More... | |
const GEnergy & | emax (void) const |
Return maximum energy. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GMWLSpectrum &spec) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | set_ebounds (void) |
Set energy boundaries. More... | |
void | read_fits (const GFitsTable &table) |
Read spectrum from FITS file. More... | |
GEnergy | conv_energy (const double &energy, const std::string &unit) |
Convert value into energy. More... | |
double | conv_flux (const GEnergy &energy, const double &flux, const std::string &unit) |
Convert value into flux. More... | |
Protected Member Functions inherited from GEventCube | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GEventCube &cube) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
virtual void | set_energies (void) |
Set energies (dummy method) More... | |
virtual void | set_times (void) |
Set times (dummy method) More... | |
Protected Member Functions inherited from GEvents | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GEvents &events) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
std::string | m_telescope |
Telescope name. More... | |
std::string | m_instrument |
Instrument name. More... | |
std::vector< GMWLDatum > | m_data |
Spectral data. More... | |
Protected Attributes inherited from GEvents | |
GEbounds | m_ebounds |
Energy boundaries covered by events. More... | |
GGti | m_gti |
Good time intervals covered by events. More... | |
Multi-wavelength spectrum class interface.
This class defines a multi-wavelength spectrum and is a container for spectral points of type GMWLDatum. It derives from the abstract GEventCube base class.
Definition at line 50 of file GMWLSpectrum.hpp.
GMWLSpectrum::GMWLSpectrum | ( | void | ) |
Void constructor.
Creates instance of an undefined spectrum.
Definition at line 66 of file GMWLSpectrum.cpp.
References init_members().
Referenced by clone().
|
explicit |
File constructor.
[in] | filename | File name. |
Creates instance from file.
Definition at line 83 of file GMWLSpectrum.cpp.
References init_members(), and load().
GMWLSpectrum::GMWLSpectrum | ( | const GMWLSpectrum & | spec | ) |
Copy constructor.
[in] | spec | Spectrum. |
Creates instance by copying an existing spectrum.
Definition at line 103 of file GMWLSpectrum.cpp.
References copy_members(), and init_members().
|
virtual |
Destructor.
Destroy instance.
Definition at line 121 of file GMWLSpectrum.cpp.
References free_members().
|
inlinevirtual |
Return class name.
Implements GEventCube.
Definition at line 109 of file GMWLSpectrum.hpp.
|
virtual |
Clear spectrum.
Implements GEventCube.
Definition at line 220 of file GMWLSpectrum.cpp.
References GEventCube::free_members(), free_members(), GEvents::free_members(), GEventCube::init_members(), init_members(), and GEvents::init_members().
|
virtual |
Clone spectrum.
Implements GEventCube.
Definition at line 242 of file GMWLSpectrum.cpp.
References GMWLSpectrum().
|
protected |
Convert value into energy.
[in] | energy | Energy value. |
[in] | unit | Unit of value. |
Converts an energy value into a GEnergy object based on the specified units. The following units are supported (case insensitive): erg, keV, MeV, GeV, and TeV.
Definition at line 671 of file GMWLSpectrum.cpp.
Referenced by read_fits().
|
protected |
Convert value into flux.
[in] | energy | Energy at which flux is given. |
[in] | flux | Flux value. |
[in] | unit | Unit of value. |
GException::invalid_argument | Invalid unit encountered. |
Converts a flux value into units of ph/cm2/s/MeV based on the specified units. The following units are supported (case insensitive): ph/cm2/s/MeV, ph/s/cm2/MeV, erg/cm2/s and erg/s/cm2.
Definition at line 695 of file GMWLSpectrum.cpp.
References gammalib::erg2MeV, G_CONV_FLUX, GEnergy::MeV(), gammalib::strip_whitespace(), and gammalib::toupper().
Referenced by read_fits().
|
protected |
Copy class members.
[in] | spec | Instance to be copied. |
Definition at line 516 of file GMWLSpectrum.cpp.
References m_data, m_instrument, and m_telescope.
Referenced by GMWLSpectrum(), and operator=().
|
inlinevirtual |
Return dimension of spectrum.
Implements GEventCube.
Definition at line 133 of file GMWLSpectrum.hpp.
|
protected |
Delete class members.
Definition at line 531 of file GMWLSpectrum.cpp.
Referenced by clear(), operator=(), and ~GMWLSpectrum().
|
protected |
Initialise class members.
Definition at line 499 of file GMWLSpectrum.cpp.
References m_data, m_instrument, and m_telescope.
Referenced by clear(), GMWLSpectrum(), and operator=().
|
inline |
Return instrument name.
Definition at line 170 of file GMWLSpectrum.hpp.
References m_instrument.
Referenced by GMWLObservation::load().
|
virtual |
Load spectrum.
[in] | filename | File name. |
This method loads a spectrum from a variety of file types. The method analyses the format of the file that is presented and choses then the appropriate method to load the specific format. The following file formats are supported: FITS, TBW ...
Implements GEventCube.
Definition at line 260 of file GMWLSpectrum.cpp.
References clear(), GFits::close(), GFilename::extname(), GFilename::extno(), GFilename::has_extname(), GFilename::has_extno(), and read().
Referenced by GMWLSpectrum(), and GMWLObservation::load().
|
inlinevirtual |
Return number of spectral bins per dimension.
[in] | axis | Axis (ignored). |
Implements GEventCube.
Definition at line 146 of file GMWLSpectrum.hpp.
References m_data.
|
virtual |
Return number of points in spectrum.
Implements GEventCube.
Definition at line 413 of file GMWLSpectrum.cpp.
References size().
|
virtual |
Assignment operator.
[in] | spec | Spectrum. |
Definition at line 143 of file GMWLSpectrum.cpp.
References copy_members(), free_members(), init_members(), and GEventCube::operator=().
|
virtual |
Spectral point access operator.
[in] | index | Spectral point index [0,...,size()-1]. |
GException::out_of_range | Spectral point index outside valid range. |
Implements GEventCube.
Definition at line 175 of file GMWLSpectrum.cpp.
References G_OPERATOR, m_data, and size().
|
virtual |
Spectral point access operator (const version)
[in] | index | Spectral point index [0,...,size()-1]. |
GException::out_of_range | Spectral point index outside valid range. |
Implements GEventCube.
Definition at line 197 of file GMWLSpectrum.cpp.
References G_OPERATOR, m_data, and size().
Print spectrum.
[in] | chatter | Chattiness (defaults to NORMAL). |
Implements GEventCube.
Definition at line 426 of file GMWLSpectrum.cpp.
References GEvents::emax(), GEvents::emin(), EXPLICIT, m_data, GEvents::m_ebounds, GEvents::m_gti, m_instrument, m_telescope, gammalib::parformat(), SILENT, size(), GGti::size(), GEbounds::size(), gammalib::str(), GEvents::tstart(), and GEvents::tstop().
|
virtual |
Read spectrum from FITS file.
[in] | file | FITS file. |
Read spectrum from first extension in FITS file.
Implements GEventCube.
Definition at line 310 of file GMWLSpectrum.cpp.
References clear().
Referenced by load().
void GMWLSpectrum::read | ( | const GFits & | fits, |
const std::string & | extname | ||
) |
Read spectrum from FITS file.
[in] | fits | FITS file. |
[in] | extname | FITS extension name. |
Definition at line 329 of file GMWLSpectrum.cpp.
References clear(), read_fits(), and GFits::table().
void GMWLSpectrum::read | ( | const GFits & | fits, |
const int & | extno | ||
) |
Read spectrum from FITS file.
[in] | fits | FITS file. |
[in] | extno | Extension number of spectrum. |
GException::invalid_argument | No table found in FITS file. |
Read the spectrum from a FITS table found in the specified extension. In no extension number if specified (or if extno=0) then the spectrum is loaded from the first table extension that is found in the file.
Definition at line 358 of file GMWLSpectrum.cpp.
References GFits::at(), clear(), GFitsHDU::exttype(), GFits::filename(), G_READ, GFitsHDU::HT_ASCII_TABLE, GFitsHDU::HT_BIN_TABLE, read_fits(), GFits::size(), GFits::table(), and GFilename::url().
|
protected |
Read spectrum from FITS file.
[in] | table | FITS table. |
GException::invalid_argument | Table does not contain at least two columns. |
Read spectrum from FITS table. The table is expected to be in one of the three following formats: 2 columns: energy, flux 3 columns: energy, flux, e_flux 4 columns or more: energy, e_energy, flux, e_flux, ...
Definition at line 584 of file GMWLSpectrum.cpp.
References conv_energy(), conv_flux(), GFitsHDU::extname(), G_READ_FITS, GFitsHDU::has_card(), m_data, GMWLDatum::m_eng, GMWLDatum::m_eng_err, GMWLDatum::m_flux, GMWLDatum::m_flux_err, m_instrument, m_telescope, GFitsTable::ncols(), GFitsTable::nrows(), GFitsTableCol::real(), set_ebounds(), gammalib::str(), GFitsHDU::string(), and GFitsTableCol::unit().
Referenced by read().
|
virtual |
Save spectrum.
[in] | filename | File name. |
[in] | clobber | Overwrite existing file (default: false). |
Implements GEventCube.
Definition at line 295 of file GMWLSpectrum.cpp.
|
protected |
Set energy boundaries.
Definition at line 541 of file GMWLSpectrum.cpp.
References GEbounds::append(), GEbounds::clear(), GEvents::emax(), GEvents::emin(), m_data, GEvents::m_ebounds, and size().
Referenced by read_fits().
|
inlinevirtual |
Return number of spectral bins.
Implements GEventCube.
Definition at line 121 of file GMWLSpectrum.hpp.
References m_data.
Referenced by number(), operator[](), print(), and set_ebounds().
|
inline |
Return telescope name.
Definition at line 158 of file GMWLSpectrum.hpp.
References m_telescope.
|
virtual |
Write spectrum into FITS file.
[in] | file | FITS file. |
Implements GEventCube.
Definition at line 403 of file GMWLSpectrum.cpp.
|
protected |
Spectral data.
Definition at line 99 of file GMWLSpectrum.hpp.
Referenced by copy_members(), init_members(), naxis(), operator[](), print(), read_fits(), set_ebounds(), and size().
|
protected |
Instrument name.
Definition at line 98 of file GMWLSpectrum.hpp.
Referenced by copy_members(), init_members(), instrument(), print(), and read_fits().
|
protected |
Telescope name.
Definition at line 97 of file GMWLSpectrum.hpp.
Referenced by copy_members(), init_members(), print(), read_fits(), and telescope().