          Delete a keyword from a crate.

delete_key(crate, keyname)
delete_key(crate, keynum)

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 delete_key command removes the specified keyword from the crate.

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.

The get_key_names routine can be used to find the names of all the keywords in a Crate.

>>> cr = read_file("evt2.fits")
>>> print(get_key_names(cr))
['TELESCOP' 'INSTRUME' 'DETNAME' 'FILTER' 'CHANTYPE' 'DETCHANS'...]
>>> delete_key(cr, "CALDBVER")
>>> key_exists(cr, "CALDBVER")
False
>>> write_file(cr, "copy.fits")

Here we delete the CALDBVER keyword from the file evt2.fits, writing the results to copy.fits. Note that evt2.fits is unchanged by this sequence.

>>> cr = read_file("evt2.fits")
>>> delete_key(cr, 35)
>>> delete_key(cr, -2)

Here we delete the 36th and last-but-one keywords from the crate.

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

December 2013