          Return a CrateKey object of a keyword from a crate.

get_key(crate, keyname)
get_key(crate, keynum)

Argument
Description
crate
A Crate object such as a TABLECrate or IMAGECrate
keyname
The key name (case insensitive).
keynum
The number of the key, where the first key is numbered 0.

The get_key command returns a CrateKey object representing the given keyword within the crate. To retrieve just the keyword value (without any metadata), use the get_keyval command.

The get_key_names routine can be used to find the names of all the keywords in a Crate.

>>> cr = read_file("evt2.fits")
>>> key = get_key(cr, "DATE")
>>> print(key)

The output is:

Name: DATE Value: 2011-11-15T15:51:27 Unit: Desc: Date and time of file creation

Fields in the CrateKey object can be used to read or change the values:

>>> print(key.value) >>> 2011-11-15T15:51:27 >>> key.value = time.strftime("%Y-%m-%dT%H:%M:%S")

which replaces the DATE value with the current time, using the same format as used in Chandra (note tha this requires that the time library has already been imported via a

import time

statement).

See the bug pages on the CIAO website for an up-to-date listing of known bugs.

December 2013