GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAResponseTable Class Reference

CTA response table class. More...

#include <GCTAResponseTable.hpp>

Inheritance diagram for GCTAResponseTable:
GBase

Public Member Functions

 GCTAResponseTable (void)
 Void constructor. More...
 
 GCTAResponseTable (const GCTAResponseTable &table)
 Copy constructor. More...
 
 GCTAResponseTable (const GFitsTable &hdu)
 FITS table constructor. More...
 
virtual ~GCTAResponseTable (void)
 Destructor. More...
 
GCTAResponseTableoperator= (const GCTAResponseTable &table)
 Assignment operator. More...
 
std::vector< double > operator() (const double &arg) const
 Linear interpolation operator for 1D tables. More...
 
std::vector< double > operator() (const double &arg1, const double &arg2) const
 Bilinear interpolation operator for 2D tables. More...
 
std::vector< double > operator() (const double &arg1, const double &arg2, const double &arg3) const
 Trilinear interpolation operator for 3D tables. More...
 
const double & operator() (const int &element) const
 Table element access operator (const version) More...
 
double & operator() (const int &element)
 Table element access operator. More...
 
const double & operator() (const int &table, const int &element) const
 Table element access operator (const version) More...
 
double & operator() (const int &table, const int &element)
 Table element access operator. More...
 
double operator() (const int &table, const double &arg) const
 Linear interpolation operator for 1D tables. More...
 
double operator() (const int &table, const double &arg1, const double &arg2) const
 Bilinear interpolation operator for 2D tables. More...
 
double operator() (const int &index, const double &arg1, const double &arg2, const double &arg3) const
 Trilinear interpolation operator for 3D tables. More...
 
void clear (void)
 Clear response table. More...
 
GCTAResponseTableclone (void) const
 Clone response table. More...
 
std::string classname (void) const
 Return class name. More...
 
bool has_table (const std::string &name) const
 Check whether a table exists. More...
 
bool has_axis (const std::string &name) const
 Check whether an axis exists. More...
 
const int & axes (void) const
 Return number of axes of the tables. More...
 
const int & tables (void) const
 Return number of tables. More...
 
const int & elements (void) const
 Return number of elements per table. More...
 
int axis (const std::string &name) const
 Determine index of an axis. More...
 
int table (const std::string &name) const
 Determine index of table. More...
 
const std::string & unit (const int &table) const
 Return table unit. More...
 
void scale (const int &table, const double &scale)
 Scale table. More...
 
int axis_bins (const int &axis) const
 Return number bins in an axis. More...
 
const double & axis_lo (const int &axis, const int &bin) const
 Return lower bin boundary for bin in axis. More...
 
const double & axis_hi (const int &axis, const int &bin) const
 Return upper bin boundary for bin in axis. More...
 
const GNodeArrayaxis_nodes (const int &axis) const
 Return axis nodes. More...
 
const std::string & axis_lo_name (const int &axis) const
 Return lower bin boundary FITS table column name for axis. More...
 
const std::string & axis_hi_name (const int &axis) const
 Return upper bin boundary FITS table column name for axis. More...
 
const std::string & axis_lo_unit (const int &axis) const
 Return lower bin boundary unit for axis. More...
 
const std::string & axis_hi_unit (const int &axis) const
 Return upper bin boundary unit for axis. More...
 
void axis_linear (const int &axis)
 Set nodes for a linear axis. More...
 
void axis_log10 (const int &axis)
 Set nodes for a logarithmic (base 10) axis. More...
 
void axis_radians (const int &axis)
 Set nodes for a radians axis. More...
 
const std::string & telescope (void) const
 Return telescope string. More...
 
void telescope (const std::string &telescope)
 Set telescope string. More...
 
void append_axis (const std::vector< double > &axis_lo, const std::vector< double > &axis_hi, const std::string &name, const std::string &unit)
 Append an axis to the response table. More...
 
void append_table (const std::string &name, const std::string &unit)
 Append table to response table. More...
 
void read (const GFitsTable &table)
 Read response table from FITS table HDU. More...
 
void write (GFitsTable &table) const
 Write response table into FITS table HDU. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print response table information. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Private Member Functions

void init_members (void)
 Initialise response table members. More...
 
void copy_members (const GCTAResponseTable &table)
 Copy response table members. More...
 
void free_members (void)
 Delete response table members. More...
 
void read_colnames (const GFitsTable &hdu)
 Read column names from FITS HDU. More...
 
void read_axes (const GFitsTable &hdu)
 Read axes definitions from FITS HDU. More...
 
void read_tables (const GFitsTable &hdu)
 Read tables. More...
 
void update (const double &arg) const
 Update 1D cache. More...
 
void update (const double &arg1, const double &arg2) const
 Update 2D cache. More...
 
void update (const double &arg1, const double &arg2, const double &arg3) const
 Update 3D cache. More...
 

Private Attributes

int m_naxes
 Number of axes. More...
 
int m_ntables
 Number of tables. More...
 
int m_nelements
 Number of elements per table. More...
 
std::vector< std::string > m_colname_lo
 Column names for lower boundaries. More...
 
std::vector< std::string > m_colname_hi
 Column names for upper boundaries. More...
 
std::vector< std::string > m_colname_table
 Column names for table. More...
 
std::vector< std::vector
< double > > 
m_axis_lo
 Axes lower boundaries. More...
 
std::vector< std::vector
< double > > 
m_axis_hi
 Axes upper boundaries. More...
 
std::vector< std::string > m_units_lo
 Lower boundaries units. More...
 
std::vector< std::string > m_units_hi
 Upper boundaries units. More...
 
std::vector< std::string > m_units_table
 Parameter units. More...
 
std::vector< GNodeArraym_axis_nodes
 Axes node arrays. More...
 
std::vector< std::vector
< double > > 
m_tables
 Tables. More...
 
std::string m_telescope
 Telescope keyword. More...
 
int m_inx_left
 Index of left node. More...
 
int m_inx_right
 Index of right node. More...
 
double m_wgt_left
 Weight of left node. More...
 
double m_wgt_right
 Weight of right node. More...
 
int m_inx1
 Index of upper left node. More...
 
int m_inx2
 Index of lower left node. More...
 
int m_inx3
 Index of upper right node. More...
 
int m_inx4
 Index of lower right node. More...
 
double m_wgt1
 Weight of upper left node. More...
 
double m_wgt2
 Weight of lower left node. More...
 
double m_wgt3
 Weight of upper right node. More...
 
double m_wgt4
 Weight of lower right node. More...
 
int m_inx5
 Index of upper left node. More...
 
int m_inx6
 Index of lower left node. More...
 
int m_inx7
 Index of upper right node. More...
 
int m_inx8
 Index of lower right node. More...
 
double m_wgt5
 Weight of upper left node. More...
 
double m_wgt6
 Weight of lower left node. More...
 
double m_wgt7
 Weight of upper right node. More...
 
double m_wgt8
 Weight of lower right node. More...
 

Detailed Description

CTA response table class.

A CTA response table holds n-dimensional data cubes that describe a component of the instrumental response function.

Each dimension of the n-dimensional cube is describe by two axes vectors, providing the lower and upper bin boundaries of each axis.

Each n-dimensional data cube is called a table. Table elements can be accessed by element index, or through linear, bilinear or trilinear interpolation operators.

Definition at line 53 of file GCTAResponseTable.hpp.

Constructor & Destructor Documentation

GCTAResponseTable::GCTAResponseTable ( void  )

Void constructor.

Construct an empty CTA response table.

Definition at line 95 of file GCTAResponseTable.cpp.

References init_members().

Referenced by clone().

GCTAResponseTable::GCTAResponseTable ( const GCTAResponseTable table)

Copy constructor.

Parameters
[in]tableResponse table.

Construct a CTA response table by copying information from an existing response table. A deep copy is performed for construction, so that the original object may be destroyed after construction the new object.

Definition at line 114 of file GCTAResponseTable.cpp.

References copy_members(), and init_members().

GCTAResponseTable::GCTAResponseTable ( const GFitsTable hdu)
explicit

FITS table constructor.

Parameters
[in]hduFITS table HDU.

Construct a CTA response table from the information in a FITS table HDU. Refer to the read() method for details.

Definition at line 135 of file GCTAResponseTable.cpp.

References init_members(), and read().

GCTAResponseTable::~GCTAResponseTable ( void  )
virtual

Destructor.

Destroys the CTA response table.

Definition at line 153 of file GCTAResponseTable.cpp.

References free_members().

Member Function Documentation

void GCTAResponseTable::append_axis ( const std::vector< double > &  axis_lo,
const std::vector< double > &  axis_hi,
const std::string &  name,
const std::string &  unit 
)

Append an axis to the response table.

Parameters
[in]axis_loLower axis boundaries.
[in]axis_hiUpper axis boundaries.
[in]nameAxis name.
[in]unitAxis unit.
Exceptions
GException::invalid_argumentIncompatible axis boundaries.

Append an axis to the response table.

Definition at line 1212 of file GCTAResponseTable.cpp.

References axes(), axis_bins(), axis_nodes(), G_APPEND_AXIS, m_axis_hi, m_axis_lo, m_axis_nodes, m_colname_hi, m_colname_lo, m_naxes, m_nelements, m_units_hi, m_units_lo, and gammalib::str().

Referenced by GCTAModelSpatialLookup::GCTAModelSpatialLookup().

void GCTAResponseTable::append_table ( const std::string &  name,
const std::string &  unit 
)

Append table to response table.

Parameters
[in]nameTable name.
[in]unitTable unit.
Exceptions
GException::invalid_valueNo axes have been specified.

Append a table to the response table. The number of elements in the table is the product of the length of all axes. All elements are set to zero by default.

Definition at line 1273 of file GCTAResponseTable.cpp.

References G_APPEND_TABLE, m_colname_table, m_nelements, m_ntables, m_tables, m_units_table, and table().

Referenced by GCTAModelSpatialLookup::GCTAModelSpatialLookup().

int GCTAResponseTable::axis ( const std::string &  name) const

Determine index of an axis.

Parameters
[in]nameColumn name
Returns
Axis index.
Exceptions
GException::invalid_valueAxis definition columns not found.

Determines the index of an axis name, where the lower and upper bin edges of the axis are stored in the columns name_LO and name_HI. An exception is thrown if the axis is not found.

Definition at line 845 of file GCTAResponseTable.cpp.

References axes(), axis_hi_name(), axis_lo_name(), and G_AXIS.

Referenced by axis_linear(), axis_log10(), axis_radians(), has_axis(), GCTAModelSpatialLookup::prepare_table(), GCTAPsf2D::read(), GCTAPsfTable::read(), GCTAPsfKing::read(), GCTAAeff2D::set_indices(), GCTABackground3D::set_members(), and GCTAEdisp2D::set_table().

const double & GCTAResponseTable::axis_hi ( const int &  axis,
const int &  bin 
) const
const std::string & GCTAResponseTable::axis_hi_name ( const int &  axis) const

Return upper bin boundary FITS table column name for axis.

Parameters
[in]axisAxis index [0,...,axes()-1].
Returns
FITS table column name of upper bin boundary.
Exceptions
GException::out_of_rangeAxis index out of range.

Returns the FITS table column name of the upper boundary for the specified axis.

Definition at line 996 of file GCTAResponseTable.cpp.

References axes(), G_AXIS_HI_NAME, and m_colname_hi.

Referenced by axis(), and has_axis().

const std::string & GCTAResponseTable::axis_hi_unit ( const int &  axis) const

Return upper bin boundary unit for axis.

Parameters
[in]axisAxis index [0,...,axes()-1].
Returns
Unit of upper bin boundary.
Exceptions
GException::out_of_rangeAxis index out of range.

Returns the unit of the upper boundary for the specified axis.

Definition at line 1046 of file GCTAResponseTable.cpp.

References axes(), G_AXIS_HI_UNIT, and m_units_hi.

Referenced by GCTABackground3D::init_mc_cache(), GCTAAeff2D::set_boundaries(), and GCTABackground3D::set_members().

void GCTAResponseTable::axis_linear ( const int &  axis)

Set nodes for a linear axis.

Parameters
[in]axisAxis index [0,...,axes()-1].
Exceptions
GException::out_of_rangeAxis index out of range.

Set axis nodes so that each node is the linear mean of the lower and upper bin boundary, i.e.

\[ n_i = 0.5 \times ({\rm LO}_i + {\rm HI}_i) \]

where \(n_i\) is node \(i\), \({\rm LO}_i\) is the lower bin boundary for bin \(i\), and \({\rm HI}_i\) is the upper bin boundary for bin \(i\).

Definition at line 1076 of file GCTAResponseTable.cpp.

References axes(), axis(), axis_bins(), axis_nodes(), G_AXIS_LINEAR, m_axis_hi, m_axis_lo, and m_axis_nodes.

const double & GCTAResponseTable::axis_lo ( const int &  axis,
const int &  bin 
) const
const std::string & GCTAResponseTable::axis_lo_name ( const int &  axis) const

Return lower bin boundary FITS table column name for axis.

Parameters
[in]axisAxis index [0,...,axes()-1].
Returns
FITS table column name of lower bin boundary.
Exceptions
GException::out_of_rangeAxis index out of range.

Returns the FITS table column name of the lower boundary for the specified axis.

Definition at line 970 of file GCTAResponseTable.cpp.

References axes(), G_AXIS_LO_NAME, and m_colname_lo.

Referenced by axis(), and has_axis().

const std::string & GCTAResponseTable::axis_lo_unit ( const int &  axis) const

Return lower bin boundary unit for axis.

Parameters
[in]axisAxis index [0,...,axes()-1].
Returns
Unit of lower bin boundary.
Exceptions
GException::out_of_rangeAxis index out of range.

Returns the unit of the lower boundary for the specified axis.

Definition at line 1021 of file GCTAResponseTable.cpp.

References axes(), G_AXIS_LO_UNIT, and m_units_lo.

Referenced by GCTABackground3D::init_mc_cache(), GCTAAeff2D::set_boundaries(), and GCTABackground3D::set_members().

void GCTAResponseTable::axis_log10 ( const int &  axis)

Set nodes for a logarithmic (base 10) axis.

Parameters
[in]axisAxis index [0,...,axes()-1].
Exceptions
GException::out_of_rangeAxis index out of range.

Set axis nodes so that each node is the logarithmic mean of the lower and upper bin boundary, i.e.

\[ n_i = \log \sqrt{{\rm LO}_i \times {\rm HI}_i} \]

where \(n_i\) is node \(i\), \({\rm LO}_i\) is the lower bin boundary for bin \(i\), and \({\rm HI}_i\) is the upper bin boundary for bin \(i\).

Todo:
Check that none of the axis boundaries is non-positive.

Definition at line 1123 of file GCTAResponseTable.cpp.

References axes(), axis(), axis_bins(), axis_nodes(), G_AXIS_LOG10, log10(), m_axis_hi, m_axis_lo, m_axis_nodes, and sqrt().

Referenced by GCTAModelSpatialLookup::prepare_table(), GCTAAeff2D::read(), GCTAPsfTable::read(), GCTAPsf2D::read(), GCTAPsfKing::read(), GCTABackground3D::set_members(), GCTAEdisp2D::set_table(), and GCTAAeff2D::table().

const GNodeArray & GCTAResponseTable::axis_nodes ( const int &  axis) const
void GCTAResponseTable::axis_radians ( const int &  axis)

Set nodes for a radians axis.

Parameters
[in]axisAxis index [0,...,axes()-1].
Exceptions
GException::out_of_rangeAxis index out of range.

Set axis nodes so that each node is the lo mean of the lower and upper bin boundary in radians, i.e.

\[ n_i = \frac{\pi}{360} \times ({\rm LO}_i + {\rm HI}_i) \]

where \(n_i\) is node \(i\), \({\rm LO}_i\) is the lower bin boundary for bin \(i\), and \({\rm HI}_i\) is the upper bin boundary for bin \(i\).

Definition at line 1169 of file GCTAResponseTable.cpp.

References axes(), axis(), axis_bins(), axis_nodes(), gammalib::deg2rad, G_AXIS_RADIANS, m_axis_hi, m_axis_lo, and m_axis_nodes.

Referenced by GCTAModelSpatialLookup::prepare_table(), GCTAAeff2D::read(), GCTAPsfTable::read(), GCTAPsf2D::read(), GCTAPsfKing::read(), GCTABackground3D::set_members(), GCTAEdisp2D::set_table(), and GCTAAeff2D::table().

std::string GCTAResponseTable::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GCTAResponseTable").

Implements GBase.

Definition at line 177 of file GCTAResponseTable.hpp.

GCTAResponseTable * GCTAResponseTable::clone ( void  ) const
virtual

Clone response table.

Returns
Deep copy of response table instance.

Returns a pointer to a deep copy of the response table.

Implements GBase.

Definition at line 677 of file GCTAResponseTable.cpp.

References GCTAResponseTable().

void GCTAResponseTable::copy_members ( const GCTAResponseTable table)
private

Copy response table members.

Parameters
[in]tableResponse table.

Copies all response table members.

Definition at line 1568 of file GCTAResponseTable.cpp.

References m_axis_hi, m_axis_lo, m_axis_nodes, m_colname_hi, m_colname_lo, m_colname_table, m_inx1, m_inx2, m_inx3, m_inx4, m_inx5, m_inx6, m_inx7, m_inx8, m_inx_left, m_inx_right, m_naxes, m_nelements, m_ntables, m_tables, m_telescope, m_units_hi, m_units_lo, m_units_table, m_wgt1, m_wgt2, m_wgt3, m_wgt4, m_wgt5, m_wgt6, m_wgt7, m_wgt8, m_wgt_left, and m_wgt_right.

Referenced by GCTAResponseTable(), and operator=().

const int & GCTAResponseTable::elements ( void  ) const
inline

Return number of elements per table.

Returns
Number of elements per table.

Returns the number of elements per table.

Definition at line 220 of file GCTAResponseTable.hpp.

References m_nelements.

Referenced by GCTAModelSpatialLookup::eval(), GCTAModelSpatialLookup::fill(), operator()(), and GCTAPsfTable::precompute().

void GCTAResponseTable::free_members ( void  )
private

Delete response table members.

De-allocates any memory that was allocated by the response table.

Definition at line 1618 of file GCTAResponseTable.cpp.

Referenced by clear(), operator=(), and ~GCTAResponseTable().

bool GCTAResponseTable::has_axis ( const std::string &  name) const

Check whether an axis exists.

Parameters
[in]nameColumn name
Returns
True if axis exists.

Check whether an axis exists.

Definition at line 718 of file GCTAResponseTable.cpp.

References axes(), axis(), axis_hi_name(), and axis_lo_name().

Referenced by GCTAEdisp2D::set_table().

bool GCTAResponseTable::has_table ( const std::string &  name) const

Check whether a table exists.

Parameters
[in]nameColumn name
Returns
True if table exists.

Checks whether a table exists.

Definition at line 691 of file GCTAResponseTable.cpp.

References m_colname_table, table(), and tables().

Referenced by GCTAAeff2D::set_indices(), and GCTABackground3D::set_members().

void GCTAResponseTable::init_members ( void  )
private
std::vector< double > GCTAResponseTable::operator() ( const double &  arg) const

Linear interpolation operator for 1D tables.

Parameters
[in]argValue.
Returns
Vector of linearly interpolated response tables.
Exceptions
GException::invalid_valueInvalid response table dimension.

Evaluates all response tables at a given value. This method applies to one-dimensional tables only. If the tables have a different dimension an exception is thrown.

The evaluation is performed by a linear interpolation of the table. If the specified value lies outside the range covered by the table, the table is linearly extrapolated from using either the first or the last two vector elements.

Todo:
Write down formula.

Definition at line 220 of file GCTAResponseTable.cpp.

References axes(), G_OPERATOR1, m_inx_left, m_inx_right, m_ntables, m_tables, m_wgt_left, m_wgt_right, gammalib::str(), and update().

std::vector< double > GCTAResponseTable::operator() ( const double &  arg1,
const double &  arg2 
) const

Bilinear interpolation operator for 2D tables.

Parameters
[in]arg1Value for first axis.
[in]arg2Value for second axis.
Returns
Vector of bilinearly interpolated response tables.
Exceptions
GException::invalid_valueInvalid response table dimension.

Evaluates all response tables at a given value. This method applies to two-dimensional tables only. If the tables have a different dimension an exception is thrown.

The evaluation is performed by a bilinear interpolation of the table. If the specified value lies outside the range covered by the table, the table is linearly extrapolated from using either the first or the last two vector elements.

Todo:
Write down formula.

Definition at line 268 of file GCTAResponseTable.cpp.

References axes(), G_OPERATOR2, m_inx1, m_inx2, m_inx3, m_inx4, m_ntables, m_tables, m_wgt1, m_wgt2, m_wgt3, m_wgt4, gammalib::str(), and update().

std::vector< double > GCTAResponseTable::operator() ( const double &  arg1,
const double &  arg2,
const double &  arg3 
) const

Trilinear interpolation operator for 3D tables.

Parameters
[in]arg1Value for first axis.
[in]arg2Value for second axis.
[in]arg3Value for third axis.
Returns
Vector of trilinearly interpolated response tables.
Exceptions
GException::invalid_valueInvalid response table dimension.

Evaluates all response tables at a given value. This method applies to three-dimensional tables only. If the tables have a different dimension an exception is thrown.

The evaluation is performed by a trilinear interpolation of the table. If the specified value lies outside the range covered by the table, the table is linearly extrapolated from using either the first or the last two vector elements.

Todo:
Write down formula.

Definition at line 320 of file GCTAResponseTable.cpp.

References axes(), G_OPERATOR3, m_inx1, m_inx2, m_inx3, m_inx4, m_inx5, m_inx6, m_inx7, m_inx8, m_ntables, m_tables, m_wgt1, m_wgt2, m_wgt3, m_wgt4, m_wgt5, m_wgt6, m_wgt7, m_wgt8, gammalib::str(), and update().

const double & GCTAResponseTable::operator() ( const int &  element) const

Table element access operator (const version)

Parameters
[in]elementTable element index [0,...,elements()-1].
Returns
Table element value.
Exceptions
GException::out_of_rangeInvalid element index.

Returns the value of a table element for the first response table.

Definition at line 392 of file GCTAResponseTable.cpp.

References elements(), G_ELEMENT_OPERATOR1, and m_tables.

double & GCTAResponseTable::operator() ( const int &  element)

Table element access operator.

Parameters
[in]elementTable element index [0,...,elements()-1].
Returns
Table element value.
Exceptions
GException::out_of_rangeInvalid element index.

Returns the value of a table element for the first response table.

Definition at line 366 of file GCTAResponseTable.cpp.

References elements(), G_ELEMENT_OPERATOR1, and m_tables.

const double & GCTAResponseTable::operator() ( const int &  table,
const int &  element 
) const

Table element access operator (const version)

Parameters
[in]tableTable index [0,...,tables()-1].
[in]elementElement index [0,...,elements()-1].
Returns
Response table element.
Exceptions
GException::out_of_rangeInvalid table or element index.

Returns the value of a table element for the response table with index table.

Definition at line 452 of file GCTAResponseTable.cpp.

References elements(), G_ELEMENT_OPERATOR2, m_tables, and tables().

double & GCTAResponseTable::operator() ( const int &  table,
const int &  element 
)

Table element access operator.

Parameters
[in]tableTable index [0,...,tables()-1].
[in]elementElement index [0,...,elements()-1].
Returns
Response table element.
Exceptions
GException::out_of_rangeInvalid table or element index.

Returns the value of a table element for the response table with index table.

Definition at line 420 of file GCTAResponseTable.cpp.

References elements(), G_ELEMENT_OPERATOR2, m_tables, and tables().

double GCTAResponseTable::operator() ( const int &  table,
const double &  arg 
) const

Linear interpolation operator for 1D tables.

Parameters
[in]tableTable index [0,...,tables()-1].
[in]argValue.
Returns
Linearly interpolated response table.
Exceptions
GException::invalid_valueInvalid response table dimension.
GException::out_of_rangeInvalid table index.

Evaluates one response table at a given value. This method applies to one-dimensional response tables. If the table has a different dimension an exception is thrown.

The evaluation is performed by a linear interpolation of the table values. If the specified value lies outside the range covered by the table, the table is linearly extrapolated from using either the first or the last two vector elements.

Todo:
Write down formula.

Definition at line 494 of file GCTAResponseTable.cpp.

References axes(), G_INX_OPERATOR1, m_inx_left, m_inx_right, m_tables, m_wgt_left, m_wgt_right, gammalib::str(), table(), tables(), and update().

double GCTAResponseTable::operator() ( const int &  table,
const double &  arg1,
const double &  arg2 
) const

Bilinear interpolation operator for 2D tables.

Parameters
[in]tableTable index [0,...,tables()-1].
[in]arg1Value for first axis.
[in]arg2Value for second axis.
Returns
Bilinearly interpolated response table.
Exceptions
GException::invalid_valueInvalid response table dimension.
GException::out_of_rangeInvalid table index.

Evaluates one response table at a given value. This method applies to two-dimensional response tables. If the table has a different dimension an exception is thrown.

The evaluation is performed by a bilinear interpolation of the table values. If the specified value lies outside the range covered by the table, the table is linearly extrapolated from using either the first or the last two vector elements.

Todo:
Write down formula.

Definition at line 548 of file GCTAResponseTable.cpp.

References axes(), G_INX_OPERATOR2, m_inx1, m_inx2, m_inx3, m_inx4, m_tables, m_wgt1, m_wgt2, m_wgt3, m_wgt4, gammalib::str(), table(), tables(), and update().

double GCTAResponseTable::operator() ( const int &  table,
const double &  arg1,
const double &  arg2,
const double &  arg3 
) const

Trilinear interpolation operator for 3D tables.

Parameters
[in]tableTable index [0,...,tables()-1].
[in]arg1Value for first axis.
[in]arg2Value for second axis.
[in]arg3Value for second axis.
Returns
Trilinearly interpolated response table.
Exceptions
GException::invalid_valueInvalid response table dimension.
GException::out_of_rangeInvalid table index.

Evaluates one response table at a given value. This method applies to three-dimensional response tables. If the table has a different dimension an exception is thrown.

The evaluation is performed by a trilinear interpolation of the table values. If the specified value lies outside the range covered by the table, the table is linearly extrapolated from using either the first or the last two vector elements.

Todo:
Write down formula.

Definition at line 607 of file GCTAResponseTable.cpp.

References axes(), G_INX_OPERATOR3, m_inx1, m_inx2, m_inx3, m_inx4, m_inx5, m_inx6, m_inx7, m_inx8, m_tables, m_wgt1, m_wgt2, m_wgt3, m_wgt4, m_wgt5, m_wgt6, m_wgt7, m_wgt8, gammalib::str(), table(), tables(), and update().

GCTAResponseTable & GCTAResponseTable::operator= ( const GCTAResponseTable table)

Assignment operator.

Parameters
[in]tableResponse table.
Returns
Response table.

Assigns a CTA response table to another object. The method is assigning a deep copy of the response table, so that the original object can be destroyed after assignment without any loss of information.

Definition at line 179 of file GCTAResponseTable.cpp.

References copy_members(), free_members(), and init_members().

std::string GCTAResponseTable::print ( const GChatter chatter = NORMAL) const
virtual

Print response table information.

Parameters
[in]chatterChattiness.
Returns
String containing response table information.

Puts CTA response table information into a std::string object for printing.

Implements GBase.

Definition at line 1453 of file GCTAResponseTable.cpp.

References axes(), axis_bins(), m_colname_hi, m_colname_lo, m_colname_table, m_telescope, m_units_hi, m_units_lo, m_units_table, gammalib::parformat(), SILENT, gammalib::str(), and tables().

void GCTAResponseTable::read ( const GFitsTable table)

Read response table from FITS table HDU.

Parameters
[in]tableFITS table.

Reads CTA response table information from a FITS table. The FITS table is expected to have a single row, and axes and table information are found in vector columns. Axes information is expected to be placed before table information.

Each axis is defined by two vector columns of equal width, describing the lower and upper limits for each bin. The column names for this boundary information terminates by "_LO" and "HI", respectively (upper case). It is expected that the "_LO" column preceeds the "_HI" column.

Following the axes columns are table columns of equal width. The width of each table column is given by the product of the lengths of all axes. It is furthermore expected that the first axis is the most rapidely varying index of the vector.

Definition at line 1347 of file GCTAResponseTable.cpp.

References clear(), GFitsHDU::has_card(), m_telescope, read_axes(), read_colnames(), read_tables(), and GFitsHDU::string().

Referenced by GCTAResponseTable(), GCTABackground3D::read(), GCTAAeff2D::read(), GCTAModelSpatialLookup::read(), GCTAPsf2D::read(), GCTAPsfTable::read(), GCTAPsfKing::read(), and GCTAEdisp2D::read().

void GCTAResponseTable::read_axes ( const GFitsTable hdu)
private

Read axes definitions from FITS HDU.

Parameters
[in]hduResponse table HDU.
Exceptions
GException::invalid_valueIncompatible axes columns encoutered.

Reads the lower and upper boundaries for all response table axes from the FITS HDU. The method verifies if the lower and upper boundary axes have the same vector dimensions.

The method also allocates the nodes for each axis, assuming that axis will be used linearily, where each node is given by the linear mean of the lower and upper boundary. In case that the axis should be used logarithmically, the method axis_log10() can be used to change to a logarithmic scale. The axis_linear() can be used to switch back to a linear scale.

This method sets the following members: m_axis_lo - Axes lower boundaries m_axis_hi - Axes upper boundaries m_axis_nodes - Axes mean values

Definition at line 1780 of file GCTAResponseTable.cpp.

References axes(), axis_hi(), axis_lo(), axis_nodes(), G_READ_AXES, m_axis_hi, m_axis_lo, m_axis_nodes, m_colname_hi, m_colname_lo, m_units_hi, m_units_lo, GFitsTableCol::number(), GFitsTableCol::real(), gammalib::str(), and GFitsTableCol::unit().

Referenced by read().

void GCTAResponseTable::read_colnames ( const GFitsTable hdu)
private

Read column names from FITS HDU.

Parameters
[in]hduResponse table HDU.
Exceptions
GException::invalid_valueInvalid response table format encountered.

Read the response table column names from the HDU. Column names terminating with "_LO" and "_HI" define the table axes, while all other column names define response tables. It is assumed that table axes are given in subsequent order, with the first column corresponding to the lower bin boundaries of the first axis. Lower bin boundaries are indicated by the "_LO" termination. Upper bin boundaries are assumed to follow immediately the lower bin boundaires and are designated by the "_HI" termination.

This method sets the following members: m_colname_lo - Column names of lower boundaries m_colname_hi - Column names of upper boundaries m_colname_table - Column names of tables m_naxes - Number of axes m_ntables - Number of tables

Todo:
Implement exceptions for invalid HDU format

Definition at line 1651 of file GCTAResponseTable.cpp.

References G_READ_COLNAMES, m_colname_hi, m_colname_lo, m_colname_table, m_naxes, m_ntables, and GFitsTable::ncols().

Referenced by read().

void GCTAResponseTable::read_tables ( const GFitsTable hdu)
private

Read tables.

Parameters
[in]hduResponse table HDU.
Exceptions
GException::invalid_valueTable vector of bad size encountered.

Reads the tables from the FITS HDU.

The method also sets m_nelements which gives the number of elements in a response table.

Definition at line 1851 of file GCTAResponseTable.cpp.

References axes(), axis_bins(), GFitsTableCol::dim(), G_READ_TABLES, m_colname_hi, m_colname_lo, m_colname_table, m_nelements, m_tables, m_units_table, GFitsTableCol::number(), GFitsTableCol::real(), gammalib::str(), table(), tables(), and GFitsTableCol::unit().

Referenced by read().

void GCTAResponseTable::scale ( const int &  table,
const double &  scale 
)

Scale table.

Parameters
[in]tableTable index [0,...,tables()-1].
[in]scaleScaling factor.
Exceptions
GException::out_of_rangeAxis index out of range.

Multiplies all values in a table by the scaling factor scale.

Definition at line 812 of file GCTAResponseTable.cpp.

References G_SCALE, m_nelements, m_tables, table(), and tables().

Referenced by GCTAAeff2D::read(), GCTAPsf2D::read(), GCTAPsfKing::read(), GCTAAeff2D::write(), GCTAPsf2D::write(), and GCTAPsfKing::write().

int GCTAResponseTable::table ( const std::string &  name) const

Determine index of table.

Parameters
[in]nameColumn name
Returns
Table index.
Exceptions
GException::invalid_valueTable not found.

Determines the index of a table name. An exception is thrown if the table is not found.

Definition at line 754 of file GCTAResponseTable.cpp.

References G_TABLE, m_colname_table, and tables().

Referenced by append_table(), has_table(), operator()(), GCTAPsf2D::read(), GCTAPsfTable::read(), GCTAPsfKing::read(), read_tables(), scale(), GCTAAeff2D::set_indices(), GCTABackground3D::set_members(), and GCTAEdisp2D::set_table().

const int & GCTAResponseTable::tables ( void  ) const
inline

Return number of tables.

Returns
Number of tables.

Returns the number of tables.

Definition at line 206 of file GCTAResponseTable.hpp.

References m_ntables.

Referenced by GCTAModelSpatialLookup::eval(), GCTAModelSpatialLookup::fill(), has_table(), operator()(), print(), GCTAAeff2D::read(), read_tables(), scale(), table(), unit(), GCTAAeff2D::write(), GCTAPsf2D::write(), and GCTAPsfKing::write().

const std::string & GCTAResponseTable::telescope ( void  ) const
inline

Return telescope string.

Returns
Telescope name.

Returns string containing the telescope name.

Definition at line 234 of file GCTAResponseTable.hpp.

References m_telescope.

Referenced by GCTAEdisp2D::set_table(), and telescope().

void GCTAResponseTable::telescope ( const std::string &  telescope)
inline

Set telescope string.

Parameters
[in]telescopeTelescope name.

Sets telescope name.

Definition at line 248 of file GCTAResponseTable.hpp.

References m_telescope, and telescope().

const std::string & GCTAResponseTable::unit ( const int &  table) const

Return table unit.

Parameters
[in]tableTable index [0,...,tables()-1].
Returns
Unit of table.
Exceptions
GException::out_of_rangeTable index out of range.

Returns the unit of the table.

Definition at line 787 of file GCTAResponseTable.cpp.

References G_UNIT, m_units_table, and tables().

void GCTAResponseTable::update ( const double &  arg) const
private

Update 1D cache.

Parameters
[in]argArgument.

Updates the 1D interpolation cache. The interpolation cache is composed of two indices and weights that define 2 data values of the 2D table that are used for linear interpolation.

Todo:
Write down formula

Definition at line 1948 of file GCTAResponseTable.cpp.

References GNodeArray::inx_left(), GNodeArray::inx_right(), m_axis_nodes, m_inx_left, m_inx_right, m_wgt_left, m_wgt_right, GNodeArray::set_value(), GNodeArray::wgt_left(), and GNodeArray::wgt_right().

Referenced by operator()().

void GCTAResponseTable::update ( const double &  arg1,
const double &  arg2 
) const
private

Update 2D cache.

Parameters
[in]arg1Argument for first axis.
[in]arg2Argument for second axis.

Updates the 2D interpolation cache. The interpolation cache is composed of four indices and weights that define 4 data values of the 2D table that are used for bilinear interpolation.

Todo:
Write down formula

Definition at line 1979 of file GCTAResponseTable.cpp.

References axis_bins(), GNodeArray::inx_left(), GNodeArray::inx_right(), m_axis_nodes, m_inx1, m_inx2, m_inx3, m_inx4, m_wgt1, m_wgt2, m_wgt3, m_wgt4, GNodeArray::set_value(), GNodeArray::wgt_left(), and GNodeArray::wgt_right().

void GCTAResponseTable::update ( const double &  arg1,
const double &  arg2,
const double &  arg3 
) const
private

Update 3D cache.

Parameters
[in]arg1Argument for first axis.
[in]arg2Argument for second axis.
[in]arg3Argument for third axis.

Updates the 3D interpolation cache. The interpolation cache is composed of four indices and weights that define 4 data values of the 2D table that are used for bilinear interpolation.

Todo:
Write down formula

Definition at line 2024 of file GCTAResponseTable.cpp.

References axis_bins(), GNodeArray::inx_left(), GNodeArray::inx_right(), m_axis_nodes, m_inx1, m_inx2, m_inx3, m_inx4, m_inx5, m_inx6, m_inx7, m_inx8, m_wgt1, m_wgt2, m_wgt3, m_wgt4, m_wgt5, m_wgt6, m_wgt7, m_wgt8, GNodeArray::set_value(), GNodeArray::wgt_left(), and GNodeArray::wgt_right().

void GCTAResponseTable::write ( GFitsTable table) const

Write response table into FITS table HDU.

Parameters
[in]tableFITS table.

Writes the response table in a FITS table HDU.

Axes columns are written in floating point columns with the suffixes "_LO" and "_HI". After the axes columns the response tables are written in floating point columns.

Definition at line 1380 of file GCTAResponseTable.cpp.

References GFitsTable::append(), axis_bins(), GFitsHDU::card(), GFitsTableCol::dim(), m_axis_hi, m_axis_lo, m_colname_hi, m_colname_lo, m_colname_table, m_naxes, m_ntables, m_tables, m_telescope, m_units_hi, m_units_lo, m_units_table, and GFitsTableCol::unit().

Referenced by GCTABackground3D::write(), GCTAAeff2D::write(), GCTAModelSpatialLookup::write(), GCTAPsf2D::write(), GCTAPsfTable::write(), GCTAPsfKing::write(), and GCTAEdisp2D::write().

Member Data Documentation

std::vector<std::vector<double> > GCTAResponseTable::m_axis_hi
private

Axes upper boundaries.

Definition at line 135 of file GCTAResponseTable.hpp.

Referenced by append_axis(), axis_hi(), axis_linear(), axis_log10(), axis_radians(), copy_members(), init_members(), read_axes(), and write().

std::vector<std::vector<double> > GCTAResponseTable::m_axis_lo
private
std::vector<GNodeArray> GCTAResponseTable::m_axis_nodes
private
std::vector<std::string> GCTAResponseTable::m_colname_hi
private

Column names for upper boundaries.

Definition at line 132 of file GCTAResponseTable.hpp.

Referenced by append_axis(), axis_hi_name(), copy_members(), init_members(), print(), read_axes(), read_colnames(), read_tables(), and write().

std::vector<std::string> GCTAResponseTable::m_colname_lo
private

Column names for lower boundaries.

Definition at line 131 of file GCTAResponseTable.hpp.

Referenced by append_axis(), axis_lo_name(), copy_members(), init_members(), print(), read_axes(), read_colnames(), read_tables(), and write().

std::vector<std::string> GCTAResponseTable::m_colname_table
private

Column names for table.

Definition at line 133 of file GCTAResponseTable.hpp.

Referenced by append_table(), copy_members(), has_table(), init_members(), print(), read_colnames(), read_tables(), table(), and write().

int GCTAResponseTable::m_inx1
mutableprivate

Index of upper left node.

Definition at line 150 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTAResponseTable::m_inx2
mutableprivate

Index of lower left node.

Definition at line 151 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTAResponseTable::m_inx3
mutableprivate

Index of upper right node.

Definition at line 152 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTAResponseTable::m_inx4
mutableprivate

Index of lower right node.

Definition at line 153 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTAResponseTable::m_inx5
mutableprivate

Index of upper left node.

Definition at line 160 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTAResponseTable::m_inx6
mutableprivate

Index of lower left node.

Definition at line 161 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTAResponseTable::m_inx7
mutableprivate

Index of upper right node.

Definition at line 162 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTAResponseTable::m_inx8
mutableprivate

Index of lower right node.

Definition at line 163 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTAResponseTable::m_inx_left
mutableprivate

Index of left node.

Definition at line 144 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTAResponseTable::m_inx_right
mutableprivate

Index of right node.

Definition at line 145 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTAResponseTable::m_naxes
private

Number of axes.

Definition at line 128 of file GCTAResponseTable.hpp.

Referenced by append_axis(), axes(), copy_members(), init_members(), read_colnames(), and write().

int GCTAResponseTable::m_nelements
private

Number of elements per table.

Definition at line 130 of file GCTAResponseTable.hpp.

Referenced by append_axis(), append_table(), copy_members(), elements(), init_members(), read_tables(), and scale().

int GCTAResponseTable::m_ntables
private

Number of tables.

Definition at line 129 of file GCTAResponseTable.hpp.

Referenced by append_table(), copy_members(), init_members(), operator()(), read_colnames(), tables(), and write().

std::vector<std::vector<double> > GCTAResponseTable::m_tables
private

Tables.

Definition at line 140 of file GCTAResponseTable.hpp.

Referenced by append_table(), copy_members(), init_members(), operator()(), read_tables(), scale(), and write().

std::string GCTAResponseTable::m_telescope
private

Telescope keyword.

Definition at line 141 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), print(), read(), telescope(), and write().

std::vector<std::string> GCTAResponseTable::m_units_hi
private

Upper boundaries units.

Definition at line 137 of file GCTAResponseTable.hpp.

Referenced by append_axis(), axis_hi_unit(), copy_members(), init_members(), print(), read_axes(), and write().

std::vector<std::string> GCTAResponseTable::m_units_lo
private

Lower boundaries units.

Definition at line 136 of file GCTAResponseTable.hpp.

Referenced by append_axis(), axis_lo_unit(), copy_members(), init_members(), print(), read_axes(), and write().

std::vector<std::string> GCTAResponseTable::m_units_table
private

Parameter units.

Definition at line 138 of file GCTAResponseTable.hpp.

Referenced by append_table(), copy_members(), init_members(), print(), read_tables(), unit(), and write().

double GCTAResponseTable::m_wgt1
mutableprivate

Weight of upper left node.

Definition at line 154 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTAResponseTable::m_wgt2
mutableprivate

Weight of lower left node.

Definition at line 155 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTAResponseTable::m_wgt3
mutableprivate

Weight of upper right node.

Definition at line 156 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTAResponseTable::m_wgt4
mutableprivate

Weight of lower right node.

Definition at line 157 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTAResponseTable::m_wgt5
mutableprivate

Weight of upper left node.

Definition at line 164 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTAResponseTable::m_wgt6
mutableprivate

Weight of lower left node.

Definition at line 165 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTAResponseTable::m_wgt7
mutableprivate

Weight of upper right node.

Definition at line 166 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTAResponseTable::m_wgt8
mutableprivate

Weight of lower right node.

Definition at line 167 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTAResponseTable::m_wgt_left
mutableprivate

Weight of left node.

Definition at line 146 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTAResponseTable::m_wgt_right
mutableprivate

Weight of right node.

Definition at line 147 of file GCTAResponseTable.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().


The documentation for this class was generated from the following files: