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) {
133 open(mission, instrument);
167 if (
this != &caldb) {
215 return (
new GCaldb(*
this));
265 if (rootdir.empty()) {
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) {
281 rootdir = std::string(ptr1);
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.";
356 std::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 "
378 if (instrument.length() > 0) {
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 "
430 std::string
GCaldb::cifname(
const std::string& mission,
const std::string& instrument)
433 std::string cif =
path(mission, instrument) +
"/caldb.indx";
438 std::string msg =
"Calibration Index File (CIF) \""+
458 void 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) {
631 filename = cal_dir->
string(i) +
"/" +
635 filename = path +
"/" +
636 cal_dir->
string(i) +
"/" +
666 result.append(
"=== GCaldb ===");
673 catch (std::exception& e) {
674 result.append(
"undefined");
736 if (caldb.
m_cif != NULL) {
GCaldb & operator=(const GCaldb &caldb)
Assignment operator.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
int size(void) const
Returns number of entries in calibration database.
std::string getenv(const std::string &arg)
Return value of environment variable.
std::string path(const std::string &mission, const std::string &instrument="")
Return path to calibration directory.
std::string m_mission
Mission of opened database.
void free_members(void)
Delete class members.
void clear(void)
Clear FITS file.
const std::string & mission(void) const
Return mission.
GCaldb * clone(void) const
Clone calibration database.
void elements(const int &row, const int &elements)
Set number of column elements for specific row.
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.
GFits m_fits
CIF FITS file.
void init_members(void)
Initialise class members.
virtual ~GCaldb(void)
Destructor.
void copy_members(const GCaldb &caldb)
Copy class members.
std::string m_instrument
Instrument of opened database.
void close(void)
Close calibration database.
void open(const std::string &mission, const std::string &instrument="")
Open calibration database.
const std::string & instrument(void) const
Return instrument.
virtual std::string string(const int &row, const int &inx=0) const =0
std::string m_cifname
CIF filename of opened database.
Calibration database class.
GCaldb(void)
Void constructor.
Abstract interface for FITS table column.
void open(const GFilename &filename, const bool &create=false)
Open or (optionally) create FITS file.
bool exists(void) const
Checks whether file exists.
bool dir_exists(const std::string &dirname)
Checks if directory exists.
std::string m_opt_rootdir
Optional root directory.
Calibration database class interface definition.
const int & nrows(void) const
Return number of rows in table.
GFitsTable * m_cif
Pointer to CIF table.
std::string cifname(const std::string &mission, const std::string &instrument="")
Return absolute CIF filename.
std::string print(const GChatter &chatter=NORMAL) const
Print calibration database information.
Exception handler interface definition.
std::string toupper(const std::string &s)
Convert string to upper case.
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.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void close(void)
Close FITS file.
void clear(void)
Clear calibration database.
std::string rootdir(void) const
Return path to CALDB root directory.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.