40#define G_OPERATOR "GMWLSpectrum::operator[](int&)"
41#define G_READ "GMWLSpectrum::read(GFits&, int&)"
42#define G_READ_FITS "GMWLSpectrum::read_fits(GFitsTable&)"
43#define G_CONV_ENERGY "GMWLSpectrum::conv_energy(double&, std::string&)"
44#define G_CONV_FLUX "GMWLSpectrum::conv_flux(GEnergy&, double&, "\
178 #if defined(G_RANGE_CHECK)
179 if (index < 0 || index >=
size()) {
200 #if defined(G_RANGE_CHECK)
201 if (index < 0 || index >=
size()) {
266 GFits fits(filename);
296 const bool& clobber)
const
364 int extension = extno;
367 if (extension == 0) {
368 for (
int i = 0; i < fits.
size(); ++i) {
378 if (extension == 0) {
379 std::string msg =
"No table found in file \""+fits.
filename().
url()+
380 "\". Please specify a FITS object containing a "
435 result.append(
"=== GMWLSpectrum ===");
448 result.append(
"not defined");
455 result.append(
"not defined");
460 for (
int i = 0; i <
size(); ++i) {
463 std::string energy =
m_data[i].m_eng.print();
464 if (
m_data[i].m_eng_err.MeV() > 0.0) {
465 energy +=
" +/- "+
m_data[i].m_eng_err.print();
470 if (
m_data[i].m_flux_err > 0.0) {
473 flux +=
" ph/cm2/s/MeV";
552 for (
int i = 0; i <
m_data.size(); ++i) {
596 if (table.
ncols() == 2) {
600 else if (table.
ncols() == 3) {
603 c_flux_err = table[2];
605 else if (table.
ncols() > 3) {
607 c_energy_err = table[1];
609 c_flux_err = table[3];
612 std::string msg =
"At least 2 columns are expected in FITS table \""+
613 table.
extname()+
"\"but found "+
615 "specify a FITS table with at least two columns.";
620 for (
int i = 0; i < table.
nrows(); ++i) {
622 if (c_energy != NULL) {
625 if (c_energy_err != NULL) {
628 if (c_flux != NULL) {
631 if (c_flux_err != NULL) {
696 const std::string& unit)
706 if (str_unit ==
"PH/CM2/S/MEV" || str_unit ==
"PH/S/CM2/MEV") {
709 else if (str_unit ==
"ERG/CM2/S" || str_unit ==
"ERG/S/CM2") {
715 std::string msg =
"Unit \""+unit+
"\" not recognised. Please specify "
716 "one of \"PH/CM2/S/MEV\", \"PH/S/CM2/MEV\", "
717 "\"ERG/CM2/S\" or \"ERG/S/CM2\".";
Energy value class definition.
Exception handler interface definition.
Filename class interface definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
Multi-wavelength spectrum class interface definition.
void append(const GEnergy &emin, const GEnergy &emax)
Append energy interval.
int size(void) const
Return number of energy boundaries.
void clear(void)
Clear energy boundaries.
Class that handles energies in a unit independent way.
double MeV(void) const
Return energy in MeV.
Abstract event bin container class.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
virtual GEventCube & operator=(const GEventCube &cube)
Assignment operator.
void free_members(void)
Delete class members.
GGti m_gti
Good time intervals covered by events.
const GTime & tstart(void) const
Return start time.
GEbounds m_ebounds
Energy boundaries covered by events.
void init_members(void)
Initialise class members.
const GTime & tstop(void) const
Return stop time.
const GEnergy & emax(void) const
Return maximum energy.
const GEnergy & emin(void) const
Return minimum energy.
bool has_extname(void) const
Signal if filename has an extension name.
bool has_extno(void) const
Signal if filename has an extension number.
std::string url(void) const
Return Uniform Resource Locator (URL)
std::string extname(const std::string &defaultname="") const
Return extension name.
int extno(const int &defaultno=-1) const
Return extension number.
virtual HDUType exttype(void) const =0
bool has_card(const int &cardno) const
Check existence of header card.
const std::string & extname(void) const
Return extension name.
std::string string(const std::string &keyname) const
Return card value as string.
Abstract interface for FITS table column.
virtual double real(const int &row, const int &inx=0) const =0
void unit(const std::string &unit)
Set column unit.
Abstract interface for FITS table.
const int & nrows(void) const
Return number of rows in table.
const int & ncols(void) const
Return number of columns in table.
int size(void) const
Return number of HDUs in FITS file.
void close(void)
Close FITS file.
GFitsHDU * at(const int &extno)
Get pointer to HDU.
const GFilename & filename(void) const
Return FITS filename.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
int size(void) const
Return number of Good Time Intervals.
Multi-wavelength spectral point class.
double m_flux_err
Uncertainty in flux (ph/cm2/s/MeV)
GEnergy m_eng
Energy of spectral point.
double m_flux
Flux of spectral point (ph/cm2/s/MeV)
GEnergy m_eng_err
Uncertainty in energy.
Multi-wavelength spectrum class interface.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print spectrum.
virtual void load(const GFilename &filename)
Load 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 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.
virtual ~GMWLSpectrum(void)
Destructor.
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.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
std::string toupper(const std::string &s)
Convert string to upper case.