Last modified: December 2015

URL: https://cxc.cfa.harvard.edu/ciao/ahelp/set_keyval.html
Jump to: Description · Example · Bugs · See Also


AHELP for CIAO 4.16

set_keyval

Context: crates

Synopsis

Set the keyword value in a crate.

Syntax

set_keyval(crate, keyname, value)
set_keyval(crate, keynum, value)

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.
value The value for the key; it can be a string, integer, floating-point number, or a boolean. If a keyword contains an invalid value - such as np.nan - then Crates will produce a warning when the crate is written out - such as "Unable to write key 'foo' to block. Invalid key value." - and the key will not be written out.

The set_keyval command sets the value of an existing keyword within the input crate. Use the set_key or add_key routines to create a new keyword.

Only the crate is changed; the input file is unaffected. The write_file command can be used to save the modified crate to a file.


Example

>>> cr = read_file("in.fits")
>>> set_keyval(cr, "ORIGIN", "CXC")
>>> set_keyval(cr, "EXPOSURE", 1.0)
>>> write_file(cr, "in.fits", clobber=True)

Update the value of the ORIGIN keyword to "CXC" and the EXPOSURE value to 1.0, then overwrite the original file.


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, cratekey, delete_key, get_key, get_key_names, get_keyval, key_exists, set_colvals, set_key, set_piximgvals