Last modified: June 2019

Jump to: Description · Examples · See Also

AHELP for CIAO 4.15


Context: contrib


Access various information about the Chandra Calibration DataBase (CALDB)


Information on the locally-installed version:
dname = get_caldb_dir()
(v,d) = get_caldb_installed(caldb=None)
v = get_caldb_installed_version(caldb=None)
d = get_caldb_installed_date(caldb=None)

v is a string containing the CALDB version (e.g. '4.2.2') and d is a
Python time object representing the release date.

Information on the release history of the CALDB:
rels = get_caldb_releases()

rels is a dictionary with the keys "CIAO", "CALDB", "SDP" and "L3".
Each key stores an array of (version,date) tuples for all relevant
releases for that key.



The get_caldb_dir() routine returns the name of the directory which contains the locally-installed CALDB (i.e. the value of the $CALDB environment variable).


The get_caldb_installed() routine returns the version and release date of the locally-installed version of the Chandra Calibration Database (CALDB). The get_caldb_installed_version() and get_caldb_installed_date() routines just return one of the pieces of information returned by get_caldb_installed().

If these routines are called without an argument then the CALDB environment variable is used to determine the location of the files, otherwise the argument is taken to be the name of the directory to look in.


The get_caldb_releases() routine returns information on the Chandra Calibration Database (CALDB) releases. Unlike the other routines, it requires that the computer is on-line and able to access the CALDB web site.

The return value is a dictionary with the following keys: "CALDB", "CIAO", "SDP" and "L3". The values are a list of (version, date) tuples, where the version is a string (e.g. "4.2.2") and the date is a Python time "structure" (see the time module documentation for more information).

Loading the routines

The routines can be loaded into Python by saying:

from ciao_contrib.caldb import *

Loading other modules

The examples below make use of the Python os and time modules; to ensure that they will run they each start with the necessary "import" call, but this is only necessary if the module has not already been loaded.


Example 1

>>> import os
>>> dname = get_caldb_dir()
>>> print(os.listdir(dname))
['software', 'docs', 'data']

The os.listdir() routine returns a list of the contents of the given directory (in this case the top-level CALDB directory). The os.path.walk() routine can be used to recursively scan through the directory contents; see 'help(os.path.walk)' for more information.

Example 2

>>> import time
>>> (rv, rt) = get_caldb_installed()
>>> rtstr = time.asctime(rt)
>>> print("The installed CALDB is v {0}, released on {1}".format(rv,

The return value of get_caldb_installed() is a tuple where the first element is the version (as a string) and the second the release date (as a Python time object; see 'help time' for more information).

The print statement displayes the value; we use the time.asctime function to convert the time value to a string. The screen output on May 5 2010 was

The installed CALDB is v 4.2.2, released on Mon Apr 19 19:00:00 2010

Example 3

>>> import time
>>> rs = get_caldb_releases()
>>> ciao = rs["CIAO"]
>>> (rv, rt) = ciao[0]
>>> rtstr = time.strftime("%a %b %d %H:%M:%S %Y", rt)
>>> print("The latest version is {0}, released on {1}".format(rv,

The return value of get_caldb_releases() is a dictionary with keys "CIAO", "CALDB", "SDP" and "L3". The values are an array of tuples which contain the version, as a string, and the release date, as a Python time object (see 'help time' for more information).

Here we access the first item in the CIAO list, and store the version and release dates in the variables rv and rt respectively. The print statement displayes the value; we use the time.strftime function to convert the time value to a string. The screen output on May 5 2010 was

The latest version is 4.2.2, released on Mon Apr 19 19:00:00 2010

See Also

check_caldb_version, ciao_caldb