GammaLib
2.0.0
|
Pulse Height Analyzer class. More...
#include <GPha.hpp>
Public Member Functions | |
GPha (void) | |
Void constructor. More... | |
GPha (const GFilename &filename) | |
File constructor. More... | |
GPha (const GEbounds &ebds) | |
Energy boundary constructor. More... | |
GPha (const int &bins) | |
Energy bins constructor. More... | |
GPha (const GPha &pha) | |
Copy constructor. More... | |
virtual | ~GPha (void) |
Destructor. More... | |
GPha & | operator= (const GPha &pha) |
Assignment operator. More... | |
GPha & | operator+= (const GPha &pha) |
Add spectrum. More... | |
GPha & | operator-= (const GPha &pha) |
Subtract spectrum. More... | |
GPha & | operator*= (const double &scale) |
Scale spectrum values. More... | |
GPha & | operator/= (const double &scale) |
Divide spectrum values. More... | |
double & | operator[] (const int &index) |
Return content of spectral bin. More... | |
const double & | operator[] (const int &index) const |
Return content of spectral bin (const version) More... | |
double & | operator() (const int &index, const int &col) |
Return content of additional columns. More... | |
const double & | operator() (const int &index, const int &col) const |
Return content of additional columns (const version) More... | |
std::vector< double > & | operator[] (const std::string &colname) |
Return additional vector column. More... | |
const std::vector< double > & | operator[] (const std::string &colname) const |
Return additional vector column (const version) More... | |
void | clear (void) |
Clear object. More... | |
GPha * | clone (void) const |
Clone object. More... | |
std::string | classname (void) const |
Return class name. More... | |
int | size (void) const |
Return number of bins in spectrum. More... | |
int | columns (void) const |
Return number of additional columns. More... | |
double & | at (const int &index) |
Return content of spectral bin. More... | |
const double & | at (const int &index) const |
Return content of spectral bin (const version) More... | |
double & | at (const int &index, const int &col) |
Return content of additional columns. More... | |
const double & | at (const int &index, const int &col) const |
Return content of additional columns (const version) More... | |
void | append (const std::string &name, const std::vector< double > &column) |
Append additional column to spectrum. More... | |
const GEbounds & | ebounds (void) const |
Return energy boundaries. More... | |
double | counts (void) const |
Number of counts in spectrum. More... | |
GNdarray | counts_spectrum (void) const |
Get number of counts in spectrum as GNdarray. More... | |
void | areascal (const int &index, const double &areascal) |
Set area scaling factor. More... | |
const double & | areascal (const int &index) const |
Return area scaling factor. More... | |
void | backscal (const int &index, const double &backscal) |
Set background scaling factor. More... | |
const double & | backscal (const int &index) const |
Return background scaling factor. More... | |
GNdarray | backscal_spectrum (void) const |
Get background scaling factors as GNdarray. More... | |
const double & | underflow (void) const |
Return number of underflow counts. More... | |
const double & | overflow (void) const |
Return number of overflow counts. More... | |
const double & | outflow (void) const |
Return number of outflow counts. More... | |
void | exposure (const double &exposure) |
Set exposure time. More... | |
const double & | exposure (void) const |
Return exposure time. More... | |
void | emin_obs (const GEnergy &emin_obs) |
Set minimum energy of observations. More... | |
const GEnergy & | emin_obs (void) const |
Return minimum energy of observations. More... | |
void | emax_obs (const GEnergy &emax_obs) |
Set maximum energy of observations. More... | |
const GEnergy & | emax_obs (void) const |
Return maximum energy of observations. More... | |
void | backfile (const std::string &backfile) |
Set background file name. More... | |
const std::string & | backfile (void) const |
Return background file name. More... | |
void | corrfile (const std::string &corrfile) |
Set correction file name. More... | |
const std::string & | corrfile (void) const |
Return correction file name. More... | |
void | respfile (const std::string &respfile) |
Set Redistribution Matrix File name. More... | |
const std::string & | respfile (void) const |
Return Redistribution Matrix File name. More... | |
void | ancrfile (const std::string &ancrfile) |
Set Ancilliary Response File name. More... | |
const std::string & | ancrfile (void) const |
Return Ancilliary Response File name. More... | |
void | fill (const GEnergy &energy, const double &value=1.0) |
Fill spectrum with a value. More... | |
void | load (const GFilename &filename) |
Load Pulse Height Analyzer spectrum. More... | |
void | save (const GFilename &filename, const bool &clobber=false) const |
Save Pulse Height Analyzer spectrum. More... | |
void | read (const GFits &fits) |
Read Pulse Height Analyzer spectrum. More... | |
void | read (const GFitsTable &table) |
Read Pulse Height Analyzer spectrum. More... | |
void | write (GFits &fits) const |
Write Pulse Height Analyzer spectrum. More... | |
const GFilename & | filename (void) const |
Return file name. More... | |
const GFitsHeader & | header (void) const |
Return FITS header. More... | |
void | header (const GFitsHeader &header) |
Set FITS header. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print Pulse Height Analyzer spectrum. 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 GPha &pha) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | alloc (const int &size) |
Allocate spectrum. More... | |
int | column_index (const std::string &colname) const |
Returns index of additional vector column. More... | |
Protected Attributes | |
GFilename | m_filename |
Filename of origin. More... | |
std::vector< double > | m_counts |
Counts data. More... | |
std::vector< double > | m_areascal |
Area scaling. More... | |
std::vector< double > | m_backscal |
Background scaling. More... | |
std::vector< std::string > | m_colnames |
Additional column names. More... | |
std::vector< std::vector < double > > | m_coldata |
Additional column data. More... | |
GEnergy | m_emin_obs |
Minimum energy of observation. More... | |
GEnergy | m_emax_obs |
Minimum energy of observation. More... | |
double | m_underflow |
Number of underflowing events. More... | |
double | m_overflow |
Number of overflowing events. More... | |
double | m_outflow |
Number of outflowing events. More... | |
double | m_exposure |
Deadtime corr. exp. time (sec) More... | |
GEbounds | m_ebounds |
Energy boundaries. More... | |
std::string | m_backfile |
Background file. More... | |
std::string | m_corrfile |
Correction file. More... | |
std::string | m_respfile |
RMF file. More... | |
std::string | m_ancrfile |
ARF file. More... | |
GFitsHeader | m_header |
FITS header cards. More... | |
Friends | |
GPha | operator+ (const GPha &a, const GPha &b) |
Spectrum addition operator friend. More... | |
GPha | operator- (const GPha &a, const GPha &b) |
Spectrum subtraction operator friend. More... | |
GPha | operator* (const GPha &pha, const double &scale) |
Spectrum scaling operator friend. More... | |
GPha | operator* (const double &scale, const GPha &pha) |
Spectrum scaling operator friend. More... | |
GPha | operator/ (const GPha &pha, const double &scale) |
Spectrum division operator friend. More... | |
Pulse Height Analyzer class.
This class implements a Pulse Height Analyzer (PHA) spectrum that is used as data container for an XSPEC analysis. A PHA spectrum is a vector that provides the number of measured counts as function of the channel number.
As an extension to the PHA format, the GPha class may also store the energy boundaries for all PHA channels. If defined, the energy boundaries will be written as a EBOUNDS extension to the same file where the PHA spectrum resides. Upon loading, GPha will also load the energy boundaries from an EBOUNDS extension if they are present.
GPha::GPha | ( | void | ) |
Void constructor.
Definition at line 71 of file GPha.cpp.
References init_members().
Referenced by clone().
|
explicit |
File constructor.
[in] | filename | File name. |
Definition at line 86 of file GPha.cpp.
References init_members(), and load().
|
explicit |
Energy boundary constructor.
[in] | ebds | Energy boundaries. |
Definition at line 104 of file GPha.cpp.
References alloc(), init_members(), m_ebounds, and GEbounds::size().
|
explicit |
Energy bins constructor.
[in] | bins | Number of energy bins. |
Definition at line 125 of file GPha.cpp.
References alloc(), and init_members().
GPha::GPha | ( | const GPha & | pha | ) |
Copy constructor.
[in] | pha | Pulse Height Analyzer spectrum. |
Definition at line 143 of file GPha.cpp.
References copy_members(), and init_members().
|
virtual |
|
protected |
Allocate spectrum.
[in] | size | Size of spectrum. |
Allocates memory for a spectrum of given size
and sets number of counts to zero and area and background scaling factors to one.
Definition at line 1303 of file GPha.cpp.
References m_areascal, m_backscal, m_counts, m_exposure, m_outflow, m_overflow, and m_underflow.
|
inline |
Set Ancilliary Response File name.
[in] | ancrfile | Ancilliary Response File name. |
Set the Ancilliary Response File name.
Definition at line 514 of file GPha.hpp.
References ancrfile(), and m_ancrfile.
|
inline |
Return Ancilliary Response File name.
Returns the Ancilliary Response File name.
Definition at line 529 of file GPha.hpp.
References m_ancrfile.
Referenced by ancrfile(), read(), and write().
void GPha::append | ( | const std::string & | name, |
const std::vector< double > & | column | ||
) |
Append additional column to spectrum.
[in] | name | Additional column name. |
[in] | column | Additional column data. |
Definition at line 574 of file GPha.cpp.
References G_APPEND, m_coldata, m_colnames, size(), and gammalib::str().
Referenced by GCTAOnOffObservation::compute_bgd(), and read().
void GPha::areascal | ( | const int & | index, |
const double & | areascal | ||
) |
Set area scaling factor.
[in] | index | Bin index [0,...,size()-1]. |
[in] | areascal | Area scaling factor. |
GException::out_of_range | Spectral bin index is out of range. |
Set area scaling for spectral bin with specified index
.
Definition at line 607 of file GPha.cpp.
References G_AREASCAL_SET, m_areascal, and size().
const double & GPha::areascal | ( | const int & | index | ) | const |
Return area scaling factor.
[in] | index | Bin index [0,...,size()-1]. |
GException::out_of_range | Spectral bin index is out of range. |
Returns reference to area scaling for spectral bin with specified index
.
Definition at line 634 of file GPha.cpp.
References G_AREASCAL_GET, m_areascal, and size().
double & GPha::at | ( | const int & | index | ) |
const double & GPha::at | ( | const int & | index | ) | const |
Return content of spectral bin (const version)
[in] | index | Bin index [0,...,size()-1]. |
GException::out_of_range | Spectral bin index is out of range. |
Returns reference to content of spectral bin with specified index
.
double & GPha::at | ( | const int & | index, |
const int & | col | ||
) |
Return content of additional columns.
GException::out_of_range | Spectral bin or column index is out of range. |
Returns reference to content of additional columns.
const double & GPha::at | ( | const int & | index, |
const int & | col | ||
) | const |
Return content of additional columns (const version)
GException::out_of_range | Spectral bin or column index is out of range. |
Returns reference to content of additional columns.
|
inline |
Set background file name.
[in] | backfile | Background file name. |
Set the background file name.
Definition at line 427 of file GPha.hpp.
References backfile(), and m_backfile.
|
inline |
Return background file name.
Returns the background file name.
Definition at line 442 of file GPha.hpp.
References m_backfile.
Referenced by backfile(), read(), and write().
void GPha::backscal | ( | const int & | index, |
const double & | backscal | ||
) |
Set background scaling factor.
[in] | index | Bin index [0,...,size()-1]. |
[in] | backscal | Background scaling factor. |
GException::out_of_range | Spectral bin index is out of range. |
Set background scaling for spectral bin with specified index
.
Definition at line 658 of file GPha.cpp.
References G_BACKSCAL_SET, m_backscal, and size().
Referenced by GCTAOnOffObservation::compute_alpha(), GCTAOnOffObservation::GCTAOnOffObservation(), GCTAOnOffObservation::likelihood_cstat(), GCTAOnOffObservation::likelihood_wstat(), and GCTAOnOffObservation::model_background().
const double & GPha::backscal | ( | const int & | index | ) | const |
Return background scaling factor.
[in] | index | Bin index [0,...,size()-1]. |
GException::out_of_range | Spectral bin index is out of range. |
Returns reference to background scaling for spectral bin with specified index
.
Definition at line 685 of file GPha.cpp.
References G_BACKSCAL_GET, m_backscal, and size().
GNdarray GPha::backscal_spectrum | ( | void | ) | const |
|
inlinevirtual |
|
virtual |
Clear object.
Reset object to a clean initial state.
Implements GBase.
Definition at line 447 of file GPha.cpp.
References free_members(), and init_members().
Referenced by GCTAOnOffObservation::init_members(), load(), and read().
|
virtual |
|
protected |
Returns index of additional vector column.
[in] | colname | Vector column name. |
Returns index of additional vector column. Returns -1 if the vector column has not found.
Definition at line 1330 of file GPha.cpp.
References columns(), and m_colnames.
Referenced by operator[]().
|
inline |
Return number of additional columns.
Returns the number of additional columns.
Definition at line 268 of file GPha.hpp.
References m_colnames.
Referenced by at(), column_index(), and write().
|
protected |
Copy class members.
[in] | pha | Pulse Height Analyzer spectrum. |
Definition at line 1258 of file GPha.cpp.
References m_ancrfile, m_areascal, m_backfile, m_backscal, m_coldata, m_colnames, m_corrfile, m_counts, m_ebounds, m_emax_obs, m_emin_obs, m_exposure, m_filename, m_header, m_outflow, m_overflow, m_respfile, and m_underflow.
Referenced by GPha(), and operator=().
|
inline |
Set correction file name.
[in] | corrfile | Correction file name. |
Set the correction file name.
Definition at line 456 of file GPha.hpp.
References corrfile(), and m_corrfile.
|
inline |
Return correction file name.
Returns the correction file name.
Definition at line 471 of file GPha.hpp.
References m_corrfile.
Referenced by corrfile(), read(), and write().
double GPha::counts | ( | void | ) | const |
Number of counts in spectrum.
Returns the number of counts in the spectrum.
Definition at line 703 of file GPha.cpp.
References m_counts.
Referenced by counts_spectrum(), GCTAOnOffObservation::nobserved(), and print().
GNdarray GPha::counts_spectrum | ( | void | ) | const |
|
inline |
Return energy boundaries.
Returns the energy boundaries for all spectral bins.
Definition at line 282 of file GPha.hpp.
References m_ebounds.
Referenced by GCTAOnOffObservation::check_consistency(), GCTAOnOffObservation::compute_bgd(), GCTAOnOffObservation::GCTAOnOffObservation(), GCTAOnOffObservation::model_background(), GCTAOnOffObservation::model_gamma(), GCTAOnOffObservation::N_bgd(), operator+=(), operator-=(), and read().
|
inline |
Set maximum energy of observations.
[in] | emax_obs | Maximum energy of observation. |
Set the maximum energy of the observation.
Definition at line 398 of file GPha.hpp.
References emax_obs(), and m_emax_obs.
Referenced by GCTAOnOffObservation::GCTAOnOffObservation(), and GCTAOnOffObservation::set().
|
inline |
Return maximum energy of observations.
Returns the maximum energy of the observation.
Definition at line 413 of file GPha.hpp.
References m_emax_obs.
Referenced by emax_obs().
|
inline |
Set minimum energy of observations.
[in] | emin_obs | Minimum energy of observation. |
Set the minimum energy of the observation.
Definition at line 369 of file GPha.hpp.
References emin_obs(), and m_emin_obs.
Referenced by GCTAOnOffObservation::GCTAOnOffObservation(), and GCTAOnOffObservation::set().
|
inline |
Return minimum energy of observations.
Returns the minimum energy of the observation.
Definition at line 384 of file GPha.hpp.
References m_emin_obs.
Referenced by emin_obs().
|
inline |
Set exposure time.
[in] | exposure | Exposure time (seconds). |
Set the exposure time in seconds.
Definition at line 340 of file GPha.hpp.
References exposure(), and m_exposure.
Referenced by GCTAOnOffObservation::GCTAOnOffObservation(), GCTAOnOffObservation::N_bgd(), GCTAOnOffObservation::N_gamma(), GCTAOnOffObservation::set(), and GCTAOnOffObservation::set_exposure().
|
inline |
Return exposure time.
Returns the exposure time in seconds.
Definition at line 355 of file GPha.hpp.
References m_exposure.
Referenced by exposure(), and print().
|
inline |
Return file name.
Returns the file name from which the PHA information has been read or into which PHA information has been saved. The returned string will be empty if no load() or save() method has been called before.
Definition at line 546 of file GPha.hpp.
References m_filename.
Referenced by GCTAOnOffObservation::write().
void GPha::fill | ( | const GEnergy & | energy, |
const double & | value = 1.0 |
||
) |
Fill spectrum with a value.
[in] | energy | Energy. |
[in] | value | Fill value (defaults to 1.0). |
Fills the specified value
at a given energy
in the spectrum.
Definition at line 771 of file GPha.cpp.
References GEbounds::emax(), GEbounds::emin(), GEbounds::index(), m_counts, m_ebounds, m_outflow, m_overflow, and m_underflow.
Referenced by GCTAOnOffObservation::model_background(), GCTAOnOffObservation::model_gamma(), and GCTAOnOffObservation::set().
|
protected |
Delete class members.
Definition at line 1288 of file GPha.cpp.
Referenced by clear(), operator=(), and ~GPha().
|
inline |
Return FITS header.
Definition at line 558 of file GPha.hpp.
References m_header.
Referenced by header(), and GCTAOnOffObservation::set().
|
inline |
|
protected |
Initialise class members.
Definition at line 1226 of file GPha.cpp.
References GFitsHeader::clear(), GEnergy::clear(), GFilename::clear(), GEbounds::clear(), m_ancrfile, m_areascal, m_backfile, m_backscal, m_coldata, m_colnames, m_corrfile, m_counts, m_ebounds, m_emax_obs, m_emin_obs, m_exposure, m_filename, m_header, m_outflow, m_overflow, m_respfile, and m_underflow.
Referenced by clear(), GPha(), and operator=().
void GPha::load | ( | const GFilename & | filename | ) |
Load Pulse Height Analyzer spectrum.
[in] | filename | File name. |
Loads the Pulse Height Analyzer spectrum from a FITS file.
Definition at line 806 of file GPha.cpp.
References clear(), m_filename, read(), and GFilename::url().
Referenced by GPha(), and GCTAOnOffObservation::read().
|
inline |
|
inline |
GPha & GPha::operator*= | ( | const double & | scale | ) |
Scale spectrum values.
[in] | scale | Scale factor. |
Multiplies the counts of a spectrum with a scale factor. The exposure time and area and background scale factors are not altered.
Definition at line 343 of file GPha.cpp.
References m_counts, m_outflow, m_overflow, m_underflow, and size().
Add spectrum.
[in] | pha | Pulse Height Analyzer spectrum. |
GException::invalid_value | Incompatible spectrum. |
Adds the counts of a spectrum to the counts of the current spectrum. The operator also adds the exposure times of the spectrum to the current exposure time. The area scaling factor \(\alpha\) is recomputed for each spectral bin using
\[ \alpha = \frac{N_1 + N_2}{\frac{N_1}{\alpha_1} + \frac{N_2}{\alpha_2}} \]
where \(N_1\) and \(N_2\) are the number of events in the bin for spectrum 1 and 2, respectively, and \(\alpha_1\) and \(\alpha_2\) are the corresponding area scaling factors.
The background scaling factor is not altered.
The operator only works if the provide specturm has the same energy binning than the current spectrum.
Definition at line 231 of file GPha.cpp.
References ebounds(), G_OPERATOR_PLUS, m_areascal, m_counts, m_exposure, m_outflow, m_overflow, m_underflow, and size().
Subtract spectrum.
[in] | pha | Pulse Height Analyzer spectrum. |
GException::invalid_value | Incompatible spectrum. |
Subtracts the counts of a spectrum from the counts of the current spectrum. The operator also subtracts the exposure times of the spectrum from the current exposure time. The area scaling factor \(\alpha\) is recomputed for each spectral bin using
\[ \alpha = \frac{N_1 - N_2}{\frac{N_1}{\alpha_1} - \frac{N_2}{\alpha_2}} \]
where \(N_1\) and \(N_2\) are the number of events in the bin for spectrum 1 and 2, respectively, and \(\alpha_1\) and \(\alpha_2\) are the corresponding area scaling factors.
The background scaling factor is not altered.
The operator only works if the provide specturm has the same energy binning than the current spectrum.
Definition at line 297 of file GPha.cpp.
References ebounds(), G_OPERATOR_MINUS, m_areascal, m_counts, m_exposure, m_outflow, m_overflow, m_underflow, and size().
GPha & GPha::operator/= | ( | const double & | scale | ) |
Divide spectrum values.
[in] | scale | Division factor. |
Divides the counts of a spectrum by a scale factor. The exposure time and the area and background scale factors are not altered.
Definition at line 369 of file GPha.cpp.
References m_counts, m_outflow, m_overflow, m_underflow, and size().
Assignment operator.
[in] | pha | Pulse Height Analyzer spectrum. |
Definition at line 181 of file GPha.cpp.
References copy_members(), free_members(), and init_members().
|
inline |
|
inline |
std::vector< double > & GPha::operator[] | ( | const std::string & | colname | ) |
Return additional vector column.
[in] | colname | Vector column name. |
Returns reference to additional vector column.
Definition at line 394 of file GPha.cpp.
References column_index(), G_OPERATOR, and m_coldata.
const std::vector< double > & GPha::operator[] | ( | const std::string & | colname | ) | const |
Return additional vector column (const version)
[in] | colname | Vector column name. |
Returns reference to additional vector column.
Definition at line 419 of file GPha.cpp.
References column_index(), G_OPERATOR, and m_coldata.
|
inline |
|
inline |
Return number of overflow counts.
Returns the number of counts with energies larger than the last energy bin.
Definition at line 312 of file GPha.hpp.
References m_overflow.
Print Pulse Height Analyzer spectrum.
[in] | chatter | Chattiness. |
Implements GBase.
Definition at line 1163 of file GPha.cpp.
References counts(), GEbounds::emax(), GEbounds::emin(), exposure(), m_ebounds, m_emax_obs, m_emin_obs, m_outflow, m_overflow, m_underflow, gammalib::parformat(), GEnergy::print(), SILENT, GEbounds::size(), size(), and gammalib::str().
Referenced by GCTAOnOffObservation::print().
void GPha::read | ( | const GFits & | fits | ) |
Read Pulse Height Analyzer spectrum.
[in] | fits | File file. |
Reads the Pulse Height Analyzer spectrum from the SPECTRUM
extension of the FITS file. If the file contains also an EBOUNDS
extension the energy boundaries of all Pulse Height Analyzer channels are also loaded.
Definition at line 874 of file GPha.cpp.
References clear(), GFits::contains(), ebounds(), gammalib::extname_ebounds, gammalib::extname_pha, m_ebounds, GEbounds::read(), and GFits::table().
Referenced by load().
void GPha::read | ( | const GFitsTable & | table | ) |
Read Pulse Height Analyzer spectrum.
[in] | table | FITS table. |
GException::invalid_value | Mismatch between PHA file and energy boundaries. |
Reads the Pulse Height Analyzer spectrum from a FITS table. The channel values are expected in the COUNTS
column of the table. All other columns are ignored.
See https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node5.html for details about the Pulse Height Analyzer spectrum format.
Definition at line 917 of file GPha.cpp.
References alloc(), ancrfile(), append(), backfile(), clear(), corrfile(), G_READ, GFitsHDU::has_card(), GFitsHDU::header(), m_ancrfile, m_areascal, m_backfile, m_backscal, m_corrfile, m_counts, m_ebounds, m_emax_obs, m_emin_obs, m_exposure, m_header, m_outflow, m_overflow, m_respfile, m_underflow, GEnergy::MeV(), GFitsTable::ncols(), GFitsTableCol::nrows(), GFitsTableCol::real(), GFitsHDU::real(), respfile(), GEbounds::size(), gammalib::str(), GFitsHDU::string(), and gammalib::tolower().
|
inline |
Set Redistribution Matrix File name.
[in] | respfile | Redistribution Matrix File name. |
Set the Redistribution Matrix File name.
Definition at line 485 of file GPha.hpp.
References m_respfile, and respfile().
|
inline |
Return Redistribution Matrix File name.
Returns the Redistribution Matrix File name.
Definition at line 500 of file GPha.hpp.
References m_respfile.
Referenced by read(), respfile(), and write().
void GPha::save | ( | const GFilename & | filename, |
const bool & | clobber = false |
||
) | const |
Save Pulse Height Analyzer spectrum.
[in] | filename | File name. |
[in] | clobber | Overwrite existing file? |
Saves the Pulse Height Analyzer spectrum and energy boundaries into a FITS file. If a file with the given filename
does not yet exist it will be created. If the file exists it can be overwritten if the clobber
flag is set to true
. Otherwise an exception is thrown.
The method will save two binary FITS tables into the FITS file: a SPECTRUM
extension that contains the channel values of the Pulse Height Analyzer spectrum and an EBOUNDS
extension that contains the energy boundaries for all channels.
Definition at line 845 of file GPha.cpp.
References m_filename, GFits::saveto(), GFilename::url(), and write().
|
inline |
Return number of bins in spectrum.
Returns the number of bins in the spectrum.
Definition at line 254 of file GPha.hpp.
References m_counts.
Referenced by append(), areascal(), at(), backscal(), backscal_spectrum(), counts_spectrum(), GCTAOnOffObservation::GCTAOnOffObservation(), GCTAOnOffObservation::likelihood_cstat(), GCTAOnOffObservation::likelihood_wstat(), GCTAOnOffObservation::model_background(), GCTAOnOffObservation::model_gamma(), GCTAOnOffObservation::N_bgd(), GCTAOnOffObservation::N_gamma(), operator*=(), operator+=(), operator-=(), operator/=(), print(), and write().
|
inline |
Return number of underflow counts.
Returns the number of counts with energies lower than the first energy bin.
Definition at line 297 of file GPha.hpp.
References m_underflow.
void GPha::write | ( | GFits & | fits | ) | const |
Write Pulse Height Analyzer spectrum.
[in] | fits | FITS file. |
Writes the Pulse Height Analyzer spectrum into SPECTRUM
and EBOUNDS
extensions of the FITS file. Extensions with these names will be removed from the FITS file before writing.
The columns CHANNEL
, COUNTS
, STAT_ERR
, SYS_ERR
, QUALITY
, GROUPING
, AREASCAL
, and BACKSCAL
will be written into the SPECTRUM
extension, but only the CHANNEL
and COUNTS
columns will be filled with values. Note that the channels start from 1 in the Pulse Height Analyzer spectrum.
See https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node5.html for details about the PHA file format.
Definition at line 1035 of file GPha.cpp.
References abs(), ancrfile(), GFitsTable::append(), GFits::append(), backfile(), GFitsHDU::card(), columns(), GFits::contains(), corrfile(), GFitsHDU::extname(), gammalib::extname_ebounds, gammalib::extname_pha, GFitsHDU::has_card(), m_ancrfile, m_areascal, m_backfile, m_backscal, m_coldata, m_colnames, m_corrfile, m_counts, m_ebounds, m_emax_obs, m_emin_obs, m_exposure, m_header, m_outflow, m_overflow, m_respfile, m_underflow, GEnergy::MeV(), GFits::remove(), respfile(), GFitsHeader::size(), GEbounds::size(), size(), sqrt(), and GEbounds::write().
Referenced by save().
|
protected |
ARF file.
Definition at line 171 of file GPha.hpp.
Referenced by ancrfile(), copy_members(), init_members(), read(), and write().
|
protected |
Area scaling.
Definition at line 157 of file GPha.hpp.
Referenced by alloc(), areascal(), copy_members(), init_members(), operator+=(), operator-=(), read(), and write().
|
protected |
Background file.
Definition at line 168 of file GPha.hpp.
Referenced by backfile(), copy_members(), init_members(), read(), and write().
|
protected |
Background scaling.
Definition at line 158 of file GPha.hpp.
Referenced by alloc(), backscal(), backscal_spectrum(), copy_members(), init_members(), read(), and write().
|
protected |
Additional column data.
Definition at line 160 of file GPha.hpp.
Referenced by append(), at(), copy_members(), init_members(), operator()(), operator[](), and write().
|
protected |
Additional column names.
Definition at line 159 of file GPha.hpp.
Referenced by append(), column_index(), columns(), copy_members(), init_members(), and write().
|
protected |
Correction file.
Definition at line 169 of file GPha.hpp.
Referenced by copy_members(), corrfile(), init_members(), read(), and write().
|
protected |
Counts data.
Definition at line 156 of file GPha.hpp.
Referenced by alloc(), at(), copy_members(), counts(), counts_spectrum(), fill(), init_members(), operator*=(), operator+=(), operator-=(), operator/=(), operator[](), read(), size(), and write().
|
protected |
Energy boundaries.
Definition at line 167 of file GPha.hpp.
Referenced by copy_members(), ebounds(), fill(), GPha(), init_members(), print(), read(), and write().
|
protected |
Minimum energy of observation.
Definition at line 162 of file GPha.hpp.
Referenced by copy_members(), emax_obs(), init_members(), print(), read(), and write().
|
protected |
Minimum energy of observation.
Definition at line 161 of file GPha.hpp.
Referenced by copy_members(), emin_obs(), init_members(), print(), read(), and write().
|
protected |
Deadtime corr. exp. time (sec)
Definition at line 166 of file GPha.hpp.
Referenced by alloc(), copy_members(), exposure(), init_members(), operator+=(), operator-=(), read(), and write().
|
mutableprotected |
Filename of origin.
Definition at line 155 of file GPha.hpp.
Referenced by copy_members(), filename(), init_members(), load(), and save().
|
protected |
FITS header cards.
Definition at line 172 of file GPha.hpp.
Referenced by copy_members(), header(), init_members(), read(), and write().
|
protected |
Number of outflowing events.
Definition at line 165 of file GPha.hpp.
Referenced by alloc(), copy_members(), fill(), init_members(), operator*=(), operator+=(), operator-=(), operator/=(), outflow(), print(), read(), and write().
|
protected |
Number of overflowing events.
Definition at line 164 of file GPha.hpp.
Referenced by alloc(), copy_members(), fill(), init_members(), operator*=(), operator+=(), operator-=(), operator/=(), overflow(), print(), read(), and write().
|
protected |
RMF file.
Definition at line 170 of file GPha.hpp.
Referenced by copy_members(), init_members(), read(), respfile(), and write().
|
protected |
Number of underflowing events.
Definition at line 163 of file GPha.hpp.
Referenced by alloc(), copy_members(), fill(), init_members(), operator*=(), operator+=(), operator-=(), operator/=(), print(), read(), underflow(), and write().