Delete a keyword from a crate.
- crate - input crate
- keyid - key name or number, where the first key is numbered 0
The delete_key command removes the specified keyword from the
crate. The print_key_names command
("ahelp print_key_names")
lists all the keywords in the file with the corresponding numbers.
The command returns a "1" if the keyword is successfully
deleted. The keyword is only deleted from the data in the
crate; it's not removed from the input file. The write_file
command
("ahelp write_file")
can be used to save the modified crate to a file.
>>> cr = read_file("evt2.fits")
>>> print(get_key_names(cr))
['TELESCOP' 'INSTRUME' 'DETNAME' 'FILTER' 'CHANTYPE' 'DETCHANS'...]
>>> delete_key(cr, "FILTER")
1
>>> key_exists(cr, "FILTER")
0
>>> write_file(cr, "nofilt.fits")
1
Delete the FILTER keyword from the crate, then use the
key_exists command to confirm it has been deleted. Write
the crate to nofilt.fits.
>>> cr = read_file("evt2.fits")
>>> delete_key(cr, 35)
1
>>> key_exists(cr, "OBS_ID")
0
>>> write_file(cr, "edit.fits")
1
Delete keyword number 35 - the OBS_ID keyword in this file
- from the crate, then write the crate to file edit.fits.
See the
bug pages
on the CIAO website for an up-to-date listing of known bugs.
- py.crates
-
add_col,
add_image,
add_key,
delete_col,
delete_image,
get_key,
get_key_names,
get_keyval,
key_exists,
print_key_names,
read_arf,
read_file,
read_pha,
read_rmf,
set_keyval,
write_arf,
write_file,
write_pha,
write_rmf
- py.crates_contrib
-
make_table_crate,
write_columns
|