38#define G_GET_ROOTDIR "GCaldb::rootdir()"
39#define G_SET_ROOTDIR "GCaldb::rootdir(std::string&)"
40#define G_PATH "GCaldb::path(std::string&, std::string&)"
41#define G_CIFNAME "GCaldb::cifname(std::string&, std::string&)"
105 if (pathname.length() > 0) {
167 if (
this != &caldb) {
215 return (
new GCaldb(*
this));
268 char* ptr1 = std::getenv(
"CALDB");
272 std::string msg =
"CALDB environment value not found. Please set "
273 "the CALDB environment variable to a valid "
274 "calibration database root directory.";
280 if (access(ptr1, F_OK) == 0) {
313 std::string msg =
"Calibration database root directory \""+
314 rootdir+
"\" not found. Please specify a valid "
315 "root directory name.";
320 if (access(
rootdir.c_str(), R_OK) != 0) {
321 std::string msg =
"Calibration database root directory \""+
322 rootdir+
"\" is not accessible for read access. "
323 "Please provide read access to the calibration "
324 "database root directory.";
356std::string
GCaldb::path(
const std::string& mission,
const std::string& instrument)
362 "\" not found in calibration database. Please "
363 "specify an available mission or add mission to "
364 "calibration database.";
367 if (access(
path.c_str(), R_OK) != 0) {
368 std::string msg =
"Calibration database directory \""+
path+
"\" for "
370 "not accessible for read access. Please provide "
371 "read access to the calibration database "
385 std::string msg =
"Requested instrument \""+
389 "calibration database. Please specify an "
390 "available instrument or add instrument to "
391 "calibration database.";
394 if (access(
path.c_str(), R_OK) != 0) {
395 std::string msg =
"Calibration database directory \""+
path+
"\" for "
399 "accessible for read access. Please provide "
400 "read access to the calibration database "
438 std::string msg =
"Calibration Index File (CIF) \""+
458void GCaldb::open(
const std::string& mission,
const std::string& instrument)
525 const std::string& filter,
526 const std::string& codename,
527 const std::string& date,
528 const std::string& time,
529 const std::string& expr)
538 for (
int i = 0; i <
size(); ++i) {
541 bool match_detector =
false;
542 bool match_filter =
false;
543 bool match_codename =
false;
544 bool match_date =
false;
545 bool match_time =
false;
546 bool match_expr =
false;
549 if (detector.length() > 0) {
553 match_detector =
true;
557 match_detector =
true;
561 if (filter.length() > 0) {
573 if (codename.length() > 0) {
577 match_codename =
true;
581 match_codename =
true;
585 if (date.length() > 0) {
597 if (time.length() > 0) {
609 if (expr.length() > 0) {
611 int num_columns = column->
elements(i);
612 for (
int k = 0; k < num_columns; ++k) {
625 if (match_detector && match_filter && match_codename &&
626 match_date && match_time && match_expr) {
636 cal_dir->
string(i) +
"/" +
666 result.append(
"=== GCaldb ===");
673 catch (std::exception& e) {
674 result.append(
"undefined");
736 if (caldb.
m_cif != NULL) {
Calibration database class interface definition.
Exception handler interface definition.
Calibration database class.
GCaldb * clone(void) const
Clone calibration database.
GFits m_fits
CIF FITS file.
void init_members(void)
Initialise class members.
std::string cifname(const std::string &mission, const std::string &instrument="")
Return absolute CIF filename.
std::string path(const std::string &mission, const std::string &instrument="")
Return path to calibration directory.
std::string rootdir(void) const
Return path to CALDB root directory.
GFitsTable * m_cif
Pointer to CIF table.
const std::string & mission(void) const
Return mission.
GCaldb & operator=(const GCaldb &caldb)
Assignment operator.
void open(const std::string &mission, const std::string &instrument="")
Open calibration database.
void copy_members(const GCaldb &caldb)
Copy class members.
virtual ~GCaldb(void)
Destructor.
int size(void) const
Returns number of entries in calibration database.
void free_members(void)
Delete class members.
std::string m_cifname
CIF filename of opened database.
const std::string & instrument(void) const
Return instrument.
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.
std::string m_instrument
Instrument of opened database.
GCaldb(void)
Void constructor.
void clear(void)
Clear calibration database.
void close(void)
Close calibration database.
std::string print(const GChatter &chatter=NORMAL) const
Print calibration database information.
std::string m_opt_rootdir
Optional root directory.
std::string m_mission
Mission of opened database.
bool exists(void) const
Checks whether file exists.
Abstract interface for FITS table column.
virtual std::string string(const int &row, const int &inx=0) const =0
void elements(const int &row, const int &elements)
Set number of column elements for specific row.
const int & nrows(void) const
Return number of rows in table.
void open(const GFilename &filename, const bool &create=false)
Open or (optionally) create FITS file.
void close(void)
Close FITS file.
void clear(void)
Clear FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
std::string tolower(const std::string &s)
Convert string to lower case.
std::string expand_env(const std::string &arg)
Expand environment variables in string.
bool dir_exists(const std::string &dirname)
Checks if directory exists.
std::string toupper(const std::string &s)
Convert string to upper case.