Skip to the navigation links
Last modified: December 2009

AHELP for CIAO 4.2


Context: py.crates


Return a CrateKey object of a keyword from a crate.


get_key(crate, keyid)


  • crate - input crate
  • keyid - keyword name or number, where the first keyword is numbered 0

The get_key command returns a CrateKey object representing the given keyword within the crate. The print_key_names command ("ahelp print_key_names") lists all the keywords in the file with the corresponding numbers.

To retrieve just the keyword value (without any metadata), use get_keyval ("ahelp get_keyval") .

Example 1

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

The DATE keyword is retrieved from the crate "cr" as a CrateKey object. The get_crate_item_type command is used to confirm its type.

Example 2

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

Keyword number 30 - the DETNAM keyword in this file - is retrieved as a CrateKey object.


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

See Also

add_key, delete_key, get_axis_transform, get_col, get_col_names, get_colvals, get_crate_item_type, get_crate_type, get_key_names, get_keyval, get_number_cols, get_number_rows, get_piximg, get_piximg_shape, get_piximgvals, get_transform, get_transform_matrix, key_exists, print_key_names, set_keyval

Last modified: December 2009