GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCaldb Class Reference

Calibration database class. More...

#include <GCaldb.hpp>

Inheritance diagram for GCaldb:
GBase

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...
 
GCaldboperator= (const GCaldb &caldb)
 Assignment operator. More...
 
void clear (void)
 Clear calibration database. More...
 
GCaldbclone (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...
 
GFitsTablem_cif
 Pointer to CIF table. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]caldbCalibration database.

Definition at line 77 of file GCaldb.cpp.

References copy_members(), and init_members().

GCaldb::GCaldb ( const std::string &  pathname)
explicit

Initalisation constructor.

Parameters
[in]pathnameCalibration 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.

Parameters
[in]missionMission name (case insensitive).
[in]instrumentInstrument 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().

GCaldb::~GCaldb ( void  )
virtual

Destructor.

Definition at line 143 of file GCaldb.cpp.

References free_members().

Member Function Documentation

std::string GCaldb::cifname ( const std::string &  mission,
const std::string &  instrument = "" 
)

Return absolute CIF filename.

Parameters
[in]missionMission name (case insensitive).
[in]instrumentInstrument name (case insensitive; optional).
Exceptions
GException::file_errorCalibration 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().

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

Return class name.

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

Implements GBase.

Definition at line 125 of file GCaldb.hpp.

void GCaldb::clear ( void  )
virtual
GCaldb * GCaldb::clone ( void  ) const
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().

void GCaldb::copy_members ( const GCaldb caldb)
protected

Copy class members.

Parameters
[in]caldbCalibration 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.

Parameters
[in]detectorDetector name (not used if empty).
[in]filterFilter name (not used if empty).
[in]codenameCode name (not used if empty).
[in]dateDate in yyyy-mm-dd format (not used if empty).
[in]timeTime in hh:mm:ss format (not used if empty).
[in]exprBoolean selection expression (not used if empty).
Returns
Calibration filename (empty if not found).

Returns a calibration file name based on selection parameters. If more files satisfy the specified selection parameters, the first file will be returned.

Todo:

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().

void GCaldb::free_members ( void  )
protected

Delete class members.

Definition at line 751 of file GCaldb.cpp.

References close().

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

void GCaldb::init_members ( void  )
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=().

const std::string & GCaldb::instrument ( void  ) const
inline

Return instrument.

Returns
String containing the instrument.

Definition at line 149 of file GCaldb.hpp.

References m_instrument.

Referenced by GCTAResponseIrf::load(), open(), and GCTAResponseIrf::print().

const std::string & GCaldb::mission ( void  ) const
inline

Return mission.

Returns
String containing the 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.

Parameters
[in]missionMission name (case insensitive).
[in]instrumentInstrument 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().

GCaldb & GCaldb::operator= ( const GCaldb caldb)

Assignment operator.

Parameters
[in]caldbCalibration 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.

Parameters
[in]missionMission name (case insensitive).
[in]instrumentInstrument name (case insensitive; optional).
Exceptions
GException::invalid_argumentCalibration directory not found.
GException::invalid_valueNo 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().

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

Print calibration database information.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing calibration database information.

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.

Exceptions
GException::invalid_valueCALDB 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.

Parameters
[in]pathnameCalibration database root directory.
Exceptions
GException::invalid_argumentCalibration database root directory not found.
GException::invalid_valueNo 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().

Member Data Documentation

GFitsTable* GCaldb::m_cif
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().

std::string GCaldb::m_cifname
protected

CIF filename of opened database.

Definition at line 113 of file GCaldb.hpp.

Referenced by close(), copy_members(), init_members(), open(), and print().

GFits GCaldb::m_fits
protected

CIF FITS file.

Definition at line 114 of file GCaldb.hpp.

Referenced by close(), copy_members(), init_members(), and open().

std::string GCaldb::m_instrument
protected

Instrument of opened database.

Definition at line 112 of file GCaldb.hpp.

Referenced by close(), copy_members(), init_members(), instrument(), open(), and print().

std::string GCaldb::m_mission
protected

Mission of opened database.

Definition at line 111 of file GCaldb.hpp.

Referenced by close(), copy_members(), init_members(), mission(), open(), and print().

std::string GCaldb::m_opt_rootdir
protected

Optional root directory.

Definition at line 110 of file GCaldb.hpp.

Referenced by copy_members(), init_members(), and rootdir().


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