GammaLib
2.1.0.dev
|
Calibration database class. More...
#include <GCaldb.hpp>
Public Member Functions | |
GCaldb (void) | |
Void constructor. More... | |
GCaldb (const GCaldb &caldb) | |
Copy constructor. More... | |
GCaldb (const std::string &pathname) | |
Initalisation constructor. More... | |
GCaldb (const std::string &mission, const std::string &instrument) | |
Calibration database constructor. More... | |
virtual | ~GCaldb (void) |
Destructor. More... | |
GCaldb & | operator= (const GCaldb &caldb) |
Assignment operator. More... | |
void | clear (void) |
Clear calibration database. More... | |
GCaldb * | clone (void) const |
Clone calibration database. More... | |
std::string | classname (void) const |
Return class name. More... | |
int | size (void) const |
Returns number of entries in calibration database. More... | |
std::string | rootdir (void) const |
Return path to CALDB root directory. More... | |
void | rootdir (const std::string &pathname) |
Set calibration database root directory. More... | |
std::string | path (const std::string &mission, const std::string &instrument="") |
Return path to calibration directory. More... | |
std::string | cifname (const std::string &mission, const std::string &instrument="") |
Return absolute CIF filename. More... | |
void | open (const std::string &mission, const std::string &instrument="") |
Open calibration database. More... | |
void | close (void) |
Close calibration database. More... | |
GFilename | filename (const std::string &detector, const std::string &filter, const std::string &codename, const std::string &date, const std::string &time, const std::string &expr) |
Return calibration file name based on selection parameters. More... | |
const std::string & | mission (void) const |
Return mission. More... | |
const std::string & | instrument (void) const |
Return instrument. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print calibration database information. 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 GCaldb &caldb) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
std::string | m_opt_rootdir |
Optional root directory. More... | |
std::string | m_mission |
Mission of opened database. More... | |
std::string | m_instrument |
Instrument of opened database. More... | |
std::string | m_cifname |
CIF filename of opened database. More... | |
GFits | m_fits |
CIF FITS file. More... | |
GFitsTable * | m_cif |
Pointer to CIF table. More... | |
Calibration database class.
This class holds the definition of a calibration database. The calibration database is located in a root directory that can be set using the GCaldb::rootdir method. If no root directory is set, GCaldb will take the directory path from the CALDB environment variable, which is mandatory in case that no root directory has been set.
It is assumed that the calibration data are found under
$CALDB/data/<mission>[/<instrument>]
and that the Calibration Index File (CIF) is located at
$CALDB/data/<mission>[/<instrument>]/caldb.indx
where <mission> is the name of the mission and <instrument> is the optional instrument name (all lower case). If the root directory has been set using the GCaldb::rootdir method, $CALDB is replaced by the root directory name.
The calibration database for a given mission and instrument is opened using the open() method. Once opened, database information can be accessed. After usage, the database is closed using the close() method.
Definition at line 66 of file GCaldb.hpp.
GCaldb::GCaldb | ( | void | ) |
Void constructor.
Creates void instance of a calibration database.
Definition at line 62 of file GCaldb.cpp.
References init_members().
Referenced by clone().
GCaldb::GCaldb | ( | const GCaldb & | caldb | ) |
Copy constructor.
[in] | caldb | Calibration database. |
Definition at line 77 of file GCaldb.cpp.
References copy_members(), and init_members().
|
explicit |
Initalisation constructor.
[in] | pathname | Calibration database root directory. |
This constructor sets the calibration database using the specified root directory. Unless the specified pathname is not empty, any existing CALDB environment variables will be ignored.
Definition at line 99 of file GCaldb.cpp.
References gammalib::expand_env(), init_members(), and rootdir().
GCaldb::GCaldb | ( | const std::string & | mission, |
const std::string & | instrument | ||
) |
Calibration database constructor.
[in] | mission | Mission name (case insensitive). |
[in] | instrument | Instrument name (case insensitive). |
Constructs a calibration database instance by opening the calibration database for the specified mission
and instrument
. Opening consists of loading the Calibration Index File (CIF) in memory. Once opened, calibration information can be accessed.
For more information about opening the database, refer to GCaldb::open.
Definition at line 127 of file GCaldb.cpp.
References init_members(), and open().
|
virtual |
std::string GCaldb::cifname | ( | const std::string & | mission, |
const std::string & | instrument = "" |
||
) |
Return absolute CIF filename.
[in] | mission | Mission name (case insensitive). |
[in] | instrument | Instrument name (case insensitive; optional). |
GException::file_error | Calibration Index File not found. |
The calibration directory path is given by one of the following
$CALDB/data/<mission>/caldb.indx $CALDB/data/<mission>/<instrument>/caldb.indx
where <mission> is the name of the mission and <instrument> is the optional instrument name (all lower case). The arguments provided to the method are transformed to lower case.
Definition at line 430 of file GCaldb.cpp.
References GFilename::exists(), filename(), G_CIFNAME, and path().
Referenced by open().
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 125 of file GCaldb.hpp.
|
virtual |
Clear calibration database.
Implements GBase.
Definition at line 194 of file GCaldb.cpp.
References free_members(), and init_members().
Referenced by GCOMInstChars::init_members(), GCOMD1Response::init_members(), GCOMD2Response::init_members(), GCOMResponse::init_members(), and GCTAResponseIrf::init_members().
|
virtual |
Clone calibration database.
Cloning provides a copy of the calibration database.
Implements GBase.
Definition at line 212 of file GCaldb.cpp.
References GCaldb().
void GCaldb::close | ( | void | ) |
Close calibration database.
Close any previously opened calibration database.
Definition at line 487 of file GCaldb.cpp.
References GFits::close(), m_cif, m_cifname, m_fits, m_instrument, and m_mission.
Referenced by free_members(), and open().
|
protected |
Copy class members.
[in] | caldb | Calibration database. |
Definition at line 725 of file GCaldb.cpp.
References m_cif, m_cifname, m_fits, m_instrument, m_mission, m_opt_rootdir, and GFits::table().
Referenced by GCaldb(), and operator=().
GFilename GCaldb::filename | ( | const std::string & | detector, |
const std::string & | filter, | ||
const std::string & | codename, | ||
const std::string & | date, | ||
const std::string & | time, | ||
const std::string & | expr | ||
) |
Return calibration file name based on selection parameters.
[in] | detector | Detector name (not used if empty). |
[in] | filter | Filter name (not used if empty). |
[in] | codename | Code name (not used if empty). |
[in] | date | Date in yyyy-mm-dd format (not used if empty). |
[in] | time | Time in hh:mm:ss format (not used if empty). |
[in] | expr | Boolean selection expression (not used if empty). |
Returns a calibration file name based on selection parameters. If more files satisfy the specified selection parameters, the first file will be returned.
data should support "now" and probably be implemented using < condition.
time should support "now" and probably be implemented using < condition.
expr should support arbitrary Boolean expressions.
Definition at line 524 of file GCaldb.cpp.
References GFitsTableCol::elements(), m_cif, path(), rootdir(), size(), GFitsTableCol::string(), and gammalib::toupper().
Referenced by cifname(), GCOMInstChars::load(), GCOMD1Response::load(), GCOMD2Response::load(), GCOMResponse::load(), GLATResponse::load(), GCTAResponseIrf::load(), and GCOMStatus::load_status().
|
protected |
Delete class members.
Definition at line 751 of file GCaldb.cpp.
References close().
Referenced by clear(), operator=(), and ~GCaldb().
|
protected |
Initialise class members.
Definition at line 705 of file GCaldb.cpp.
References GFits::clear(), m_cif, m_cifname, m_fits, m_instrument, m_mission, and m_opt_rootdir.
Referenced by clear(), GCaldb(), and operator=().
|
inline |
Return instrument.
Definition at line 149 of file GCaldb.hpp.
References m_instrument.
Referenced by GCTAResponseIrf::load(), open(), and GCTAResponseIrf::print().
|
inline |
Return mission.
Definition at line 137 of file GCaldb.hpp.
References m_mission.
Referenced by open(), and GCTAResponseIrf::print().
void GCaldb::open | ( | const std::string & | mission, |
const std::string & | instrument = "" |
||
) |
Open calibration database.
[in] | mission | Mission name (case insensitive). |
[in] | instrument | Instrument name (case insensitive; optional). |
Opens the calibration database for a given mission and instrument. Opening consists of loading the Calibration Index File (CIF) in memory. Once opened, calibration information can be accessed.
Definition at line 458 of file GCaldb.cpp.
References cifname(), close(), instrument(), m_cif, m_cifname, m_fits, m_instrument, m_mission, mission(), GFits::open(), and GFits::table().
Referenced by GCaldb().
Assignment operator.
[in] | caldb | Calibration database. |
Definition at line 164 of file GCaldb.cpp.
References copy_members(), free_members(), and init_members().
std::string GCaldb::path | ( | const std::string & | mission, |
const std::string & | instrument = "" |
||
) |
Return path to calibration directory.
[in] | mission | Mission name (case insensitive). |
[in] | instrument | Instrument name (case insensitive; optional). |
GException::invalid_argument | Calibration directory not found. |
GException::invalid_value | No read permission granted to calibration directory. |
The calibration directory path is given by one of the following
$CALDB/data/<mission> $CALDB/data/<mission>/<instrument>
where <mission> is the name of the mission and <instrument> is the optional instrument name (all lower case). The arguments provided to the method are transformed to lower case.
Definition at line 356 of file GCaldb.cpp.
References gammalib::dir_exists(), G_PATH, rootdir(), gammalib::tolower(), and gammalib::toupper().
Referenced by cifname(), and filename().
Print calibration database information.
[in] | chatter | Chattiness (defaults to NORMAL). |
Implements GBase.
Definition at line 657 of file GCaldb.cpp.
References m_cif, m_cifname, m_instrument, m_mission, gammalib::parformat(), rootdir(), SILENT, size(), gammalib::str(), and gammalib::toupper().
Referenced by GCOMInstChars::print(), GCOMD1Response::print(), GCOMD2Response::print(), GCOMResponse::print(), and GCTAResponseIrf::print().
std::string GCaldb::rootdir | ( | void | ) | const |
Return path to CALDB root directory.
GException::invalid_value | CALDB environment variable not set |
The calibration directory path is given by one of the following
$CALDB/data/<mission> $CALDB/data/<mission>/<instrument>
where <mission> is the name of the mission and <instrument> is the optional instrument name (all lower case). The arguments provided to the method are transformed to lower case.
Definition at line 257 of file GCaldb.cpp.
References G_GET_ROOTDIR, gammalib::getenv(), and m_opt_rootdir.
Referenced by filename(), GCaldb(), GCOMInstChars::load(), GCOMD1Response::load(), GCOMD2Response::load(), GCOMResponse::load(), GCTAResponseIrf::load(), path(), print(), and rootdir().
void GCaldb::rootdir | ( | const std::string & | pathname | ) |
Set calibration database root directory.
[in] | pathname | Calibration database root directory. |
GException::invalid_argument | Calibration database root directory not found. |
GException::invalid_value | No read permission granted for calibration database root directory. |
Sets the calibration database root directory to a specific path. The method verifies the existence of the root directory prior to setting.
Definition at line 306 of file GCaldb.cpp.
References gammalib::dir_exists(), gammalib::expand_env(), G_SET_ROOTDIR, m_opt_rootdir, and rootdir().
int GCaldb::size | ( | void | ) | const |
Returns number of entries in calibration database.
This method returns the number of entries that were found in an opened calibration database. An entry corresponds to one line in the Calibration Index File (CIF). If the index file is empty, or if no calibration database has been opened, the method returns 0.
Definition at line 227 of file GCaldb.cpp.
References m_cif, and GFitsTable::nrows().
Referenced by filename(), and print().
|
protected |
Pointer to CIF table.
Definition at line 115 of file GCaldb.hpp.
Referenced by close(), copy_members(), filename(), init_members(), open(), print(), and size().
|
protected |
CIF filename of opened database.
Definition at line 113 of file GCaldb.hpp.
Referenced by close(), copy_members(), init_members(), open(), and print().
|
protected |
CIF FITS file.
Definition at line 114 of file GCaldb.hpp.
Referenced by close(), copy_members(), init_members(), and open().
|
protected |
Instrument of opened database.
Definition at line 112 of file GCaldb.hpp.
Referenced by close(), copy_members(), init_members(), instrument(), open(), and print().
|
protected |
Mission of opened database.
Definition at line 111 of file GCaldb.hpp.
Referenced by close(), copy_members(), init_members(), mission(), open(), and print().
|
protected |
Optional root directory.
Definition at line 110 of file GCaldb.hpp.
Referenced by copy_members(), init_members(), and rootdir().