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\".";
double m_flux
Flux of spectral point (ph/cm2/s/MeV)
void unit(const std::string &unit)
Set column unit.
GFitsHDU * at(const int &extno)
Get pointer to HDU.
const int & ncols(void) const
Return number of columns in table.
void init_members(void)
Initialise class members.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
bool has_card(const int &cardno) const
Check existence of header card.
virtual void write(GFits &file) const
Write spectrum into FITS file.
Energy value class definition.
double m_flux_err
Uncertainty in flux (ph/cm2/s/MeV)
bool has_extno(void) const
Signal if filename has an extension number.
Multi-wavelength spectrum class interface definition.
int size(void) const
Return number of energy boundaries.
void init_members(void)
Initialise class members.
void append(const GEnergy &emin, const GEnergy &emax)
Append energy interval.
virtual GMWLSpectrum & operator=(const GMWLSpectrum &spec)
Assignment operator.
void free_members(void)
Delete class members.
const GFilename & filename(void) const
Return FITS filename.
virtual GEventCube & operator=(const GEventCube &cube)
Assignment operator.
const GTime & tstop(void) const
Return stop time.
bool has_extname(void) const
Signal if filename has an extension name.
virtual HDUType exttype(void) const =0
virtual GMWLDatum * operator[](const int &index)
Spectral point access operator.
GEbounds m_ebounds
Energy boundaries covered by events.
std::string extname(const std::string &defaultname="") const
Return extension name.
double MeV(void) const
Return energy in MeV.
FITS file class interface definition.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
int size(void) const
Return number of Good Time Intervals.
Multi-wavelength spectrum class interface.
GEnergy m_eng_err
Uncertainty in energy.
void read_fits(const GFitsTable &table)
Read spectrum from FITS file.
GEnergy m_eng
Energy of spectral point.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print spectrum.
void free_members(void)
Delete class members.
void free_members(void)
Delete class members.
Abstract interface for FITS table column.
virtual int size(void) const
Return number of spectral bins.
virtual int number(void) const
Return number of points in spectrum.
Abstract interface for FITS table.
virtual void clear(void)
Clear spectrum.
GGti m_gti
Good time intervals covered by events.
GEnergy conv_energy(const double &energy, const std::string &unit)
Convert value into energy.
const std::string & extname(void) const
Return extension name.
void clear(void)
Clear energy boundaries.
std::string m_telescope
Telescope name.
virtual GMWLSpectrum * clone(void) const
Clone spectrum.
const int & nrows(void) const
Return number of rows in table.
void set_ebounds(void)
Set energy boundaries.
std::vector< GMWLDatum > m_data
Spectral data.
Multi-wavelength spectral point class.
void copy_members(const GMWLSpectrum &spec)
Copy class members.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save spectrum.
std::string url(void) const
Return Uniform Resource Locator (URL)
virtual double real(const int &row, const int &inx=0) const =0
const GEnergy & emin(void) const
Return minimum energy.
GMWLSpectrum(void)
Void constructor.
int size(void) const
Return number of HDUs in FITS file.
int extno(const int &defaultno=-1) const
Return extension number.
std::string string(const std::string &keyname) const
Return card value as string.
Exception handler interface definition.
std::string toupper(const std::string &s)
Convert string to upper case.
virtual ~GMWLSpectrum(void)
Destructor.
void init_members(void)
Initialise class members.
double conv_flux(const GEnergy &energy, const double &flux, const std::string &unit)
Convert value into flux.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
const GTime & tstart(void) const
Return start time.
Abstract event bin container class.
void close(void)
Close FITS file.
const GEnergy & emax(void) const
Return maximum energy.
std::string m_instrument
Instrument name.
Filename class interface definition.
virtual void load(const GFilename &filename)
Load spectrum.
virtual void read(const GFits &file)
Read spectrum from FITS file.
Class that handles energies in a unit independent way.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
FITS table abstract base class interface definition.