Chandra X-Ray Observatory
	(CXC)
Skip to the navigation links
Last modified: December 2013

URL: http://cxc.harvard.edu/ciao/ahelp/get_key.html
Jump to: Description · Example · Bugs · See Also


AHELP for CIAO 4.9

get_key

Context: crates

Synopsis

Return a CrateKey object of a keyword from a crate.

Syntax

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

Description

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.

Example

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

Bugs

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

Refer to the CIAO bug pages for an up-to-date listing of known issues.

See Also

crates
add_key, copy_piximgvals, cratekey, 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, set_key, set_keyval

Last modified: December 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email:   cxchelp@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2017. All rights reserved.