          Delete a column from a crate.

delete_col(crate, colname)
delete_col(crate, colnum)

Argument
Description
crate
The table crate.
colname
The column name (case insensitive).
colnum
The column number, where the first column is numbered 0.

The delete_col command removes the column - and any associated virtual columns - from the crate. If a virtual column is deleted then the column from which it is based, such as SKY if removing EQPOS from a Chandra event list, will not be deleted.

It cannot be used to delete the component of a vector, such as 'x' when the file contains a 'sky' column containing 'x' and 'y' components. In this case the parent column - 'sky' in this example - has to be removed, which will remove the components.

When a column is deleted, any associated virtual column is now also deleted from the crate. Note that if you delete a virtual column then its source column will remain in 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_col_names routine can be used to find the columns in a Crate.

>>> cr = read_file("evt2.fits")
>>> print(get_col_names(cr))
['CHANNEL' 'COUNTS' 'STAT_ERR' 'BACKGROUND' 'BIN_LO' 'BIN_HI']
>>> delete_col(cr, "STAT_ERR")
>>> col_exists(cr, "STAT_ERR")
False
>>> write_file(cr, "nostat.fits")

Delete the STAT_ERR column from the crate, then use the col_exists command to confirm it has been deleted. Write the crate to nostat.fits.

>>> cr = read_file("evt2.fits")
>>> delete_col(cr, 4)
>>> col_exists(cr, "BACKGROUND")
False
>>> write_file(cr, "edit.fits")

Delete column number 4 - the BACKGROUND column 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.

December 2015