42 #define G_OPERATOR_PLUS "GRmf::operator+=(GRmf&)"
43 #define G_OPERATOR_MINUS "GRmf::operator-=(GRmf&)"
44 #define G_AT "GRmf::at(int&, int&)"
196 std::string msg =
"Incompatible true energy binning of "
197 "Redistribution Matrix File.";
201 std::string msg =
"Incompatible measured energy binning of "
202 "Redistribution Matrix File.";
207 for (
int itrue = 0; itrue <
ntrue(); ++itrue) {
208 for (
int imeasured = 0; imeasured <
nmeasured(); ++imeasured) {
237 std::string msg =
"Incompatible true energy binning of "
238 "Redistribution Matrix File.";
242 std::string msg =
"Incompatible measured energy binning of "
243 "Redistribution Matrix File.";
248 for (
int itrue = 0; itrue <
ntrue(); ++itrue) {
249 for (
int imeasured = 0; imeasured <
nmeasured(); ++imeasured) {
271 for (
int itrue = 0; itrue <
ntrue(); ++itrue) {
272 for (
int imeasured = 0; imeasured <
nmeasured(); ++imeasured) {
273 m_matrix(itrue, imeasured) *= scale;
293 for (
int itrue = 0; itrue <
ntrue(); ++itrue) {
294 for (
int imeasured = 0; imeasured <
nmeasured(); ++imeasured) {
295 m_matrix(itrue, imeasured) /= scale;
334 return new GRmf(*
this);
350 double&
GRmf::at(
const int& itrue,
const int& imeasured)
353 if (itrue < 0 || itrue >=
ntrue()) {
358 if (imeasured < 0 || imeasured >=
nmeasured()) {
364 return (
m_matrix(itrue, imeasured));
380 const double&
GRmf::at(
const int& itrue,
const int& imeasured)
const
383 if (itrue < 0 || itrue >=
ntrue()) {
388 if (imeasured < 0 || imeasured >=
nmeasured()) {
394 return (
m_matrix(itrue, imeasured));
437 if (row_start != -1 && row_stop != -1) {
473 int column_start = -1;
474 int column_stop = -1;
477 column_start = column;
483 column_stop = column;
489 if (column_start != -1 && column_stop != -1) {
553 const std::string& unit)
const
635 int rows = energy_lo->
nrows();
645 for (
int itrue = 0; itrue < rows; ++itrue) {
654 int ngroups = n_grp->
integer(itrue);
655 for (
int igroup = 0; igroup < ngroups; ++igroup) {
658 int imeasured = f_chan->
integer(itrue, igroup);
659 int nvalues = n_chan->
integer(itrue, igroup);
662 for (
int i = 0; i < nvalues; ++i, ++imeasured, ++icolumn) {
665 m_matrix(itrue, imeasured) = matrix->
real(itrue, icolumn);
668 if (max <
m_matrix(itrue, imeasured)) {
721 int length =
ntrue();
728 for (
int i = 0; i < length; i++) {
740 for (; ilast >= 0; --ilast) {
747 int num = ilast - ifirst + 1;
750 if (num > maxcolumns) {
768 for (
int itrue = 0; itrue < length; ++itrue) {
773 if (
m_matrix(itrue, ifirst) != 0.0) {
780 for (; ilast >= 0; --ilast) {
781 if (
m_matrix(itrue, ilast) != 0.0) {
787 int num = ilast - ifirst + 1;
799 f_chan(itrue) = ifirst;
803 for (
int i = 0; i < num; ++i, ++ifirst) {
810 energy_lo.
unit(unit);
811 energy_hi.
unit(unit);
825 hdu.
card(
"TELESCOP",
"unknown",
"Telescope");
826 hdu.
card(
"INSTRUME",
"unknown",
"Instrument");
827 hdu.
card(
"FILTER",
"none",
"Filter");
828 hdu.
card(
"CHANTYPE",
"PI",
"Channel type");
829 hdu.
card(
"DETCHANS",
nmeasured(),
"Total number of possible channels");
830 hdu.
card(
"HDUCLASS",
"OGIP",
"Format conforms to OGIP standard");
831 hdu.
card(
"HDUCLAS1",
"RESPONSE",
"Extension contains response data");
832 hdu.
card(
"HDUCLAS2",
"RSP_MATRIX",
"Extension contains a RMF");
833 hdu.
card(
"HDUVERS",
"1.3.0",
"Version of the file format");
834 hdu.
card(
"TLMIN4", 0,
"Minimum value allowed in column 4");
840 (
m_header[i].keyname() ==
"TELESCOP") ||
841 (
m_header[i].keyname() ==
"INSTRUME") ||
842 (
m_header[i].keyname() ==
"FILTER")) {
875 result.append(
"=== GRmf ===");
884 result.append(
" - ");
888 result.append(
" - ");
std::string print(const GChatter &chatter=NORMAL) const
Print Redistribution Matrix File.
int m_imeasmax
Index of measured maximum.
void unit(const std::string &unit)
Set column unit.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GRmf(void)
Void constructor.
void free_members(void)
Delete class members.
Sparse matrix class interface definition.
int size(void) const
Return number of energy boundaries.
void append(const GEnergy &emin, const GEnergy &emax)
Append energy interval.
bool contains(const std::string &colname) const
Checks the presence of a column in table.
void nrows(const int &nrows)
Set number of rows in column.
Redistribution Matrix File class.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
void read(const GFitsTable &table)
Read energy boundaries from FITS table.
int nmeasured(void) const
Return number of measured energy bins in redistribution matrix.
double & at(const int &itrue, const int &imeasured)
Return content of redistribution matrix bin.
GFilename m_filename
Filename of origin.
FITS table float column class interface definition.
const GFitsHeader & header(void) const
Return extension header.
FITS file class interface definition.
GRmf & operator=(const GRmf &rmf)
Assignment operator.
virtual void clear(void)
Clear matrix.
void copy_members(const GRmf &rmf)
Copy class members.
void write(GFits &file, const std::string &extname=gammalib::extname_ebounds, const std::string &unit="keV") const
Write energy boundaries into FITS object.
void init_members(void)
Initialise class members.
int index(const GEnergy &eng) const
Returns energy bin index for a given energy.
GRmf & operator+=(const GRmf &rmf)
Add Redistribution Matrix File.
const GEbounds & emeasured(void) const
Return measured energy boundaries.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
int m_itruemax
Index of true maximum.
GRmf & operator-=(const GRmf &rmf)
Subtract Redistribution Matrix File.
XSPEC Redistribution Matrix File class definition.
Energy boundaries container class.
void remove(const int &extno)
Remove HDU from FITS file.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
GRmf * clone(void) const
Clone object.
const int & rows(void) const
Return number of matrix rows.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
Abstract interface for FITS table column.
GMatrixSparse m_matrix
Sparse redistribution matrix.
const std::string extname_ebounds
Abstract interface for FITS table.
GEbounds m_ebds_measured
Measured energy boundaries.
int ntrue(void) const
Return number of true energy bins in redistribution matrix.
void clear(void)
Clear object.
const std::string & extname(void) const
Return extension name.
void clear(void)
Clear energy boundaries.
void save(const GFilename &filename, const bool &clobber=false, const std::string &unit="keV") const
Save Redistribution Matrix File.
double max(const GVector &vector)
Computes maximum vector element.
GFitsHeader m_header
FITS header cards.
GRmf & operator/=(const double &scale)
Divide Redistribution Matrix File values.
GRmf & operator*=(const double &scale)
Scale Redistribution Matrix File values.
std::string url(void) const
Return Uniform Resource Locator (URL)
virtual int integer(const int &row, const int &inx=0) const =0
void clear(void)
Clear file name.
virtual double real(const int &row, const int &inx=0) const =0
Exception handler interface definition.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
FITS binary table class definition.
FITS table short integer column class interface definition.
void read(const GFits &fits)
Read Redistribution Matrix File.
FITS table short integer column.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
const GEbounds & etrue(void) const
Return true energy boundaries.
GEbounds m_ebds_true
True energy boundaries.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
GFitsHeaderCard & card(const int &cardno)
Return header card.
virtual ~GRmf(void)
Destructor.
const int & columns(void) const
Return number of matrix columns.
void write(GFits &fits, const std::string &unit="keV") const
Write Redistribution Matrix File.
void load(const GFilename &filename)
Load Redistribution Matrix File.
const GMatrixSparse & matrix(void) const
Return redistribution matrix.
Mathematical function definitions.
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.
const std::string extname_rmf