Skip to the navigation links
Last modified: December 2009

URL: http://cxc-newtest.cfa.harvard.edu/ciao4.2/get_key.py.html
AHELP for CIAO 4.2

get_key

Context: py.crates

Synopsis

Return a CrateKey object of a keyword from a crate.

Syntax

get_key(crate, keyid)

Description

  • 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)
Key

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)
Key

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

Bugs

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

See Also

py.crates
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