          Set the keyword value in a crate.

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

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.

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

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

December 2015