Last modified: December 2015

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.15


Context: crates


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.

Deleting vector columns and components

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.

Deleting associated virtual columns

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.


Example 1

>>> cr = read_file("evt2.fits")
>>> print(get_col_names(cr))
>>> delete_col(cr, "STAT_ERR")
>>> col_exists(cr, "STAT_ERR")
>>> 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.

Example 2

>>> cr = read_file("evt2.fits")
>>> delete_col(cr, 4)
>>> col_exists(cr, "BACKGROUND")
>>> 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.

Refer to the CIAO bug pages for an up-to-date listing of known issues.

See Also

add_colvals, make_image_crate, make_table_crate, scale_image_crate, smooth_image_crate, write_arrays, write_columns
add_col, add_key, add_piximg, col_exists, copy_colvals, delete_key, delete_piximg, get_col, get_col_names, get_colvals, get_number_cols, is_virtual, read_file, read_pha, read_rmf, set_colvals, write_file, write_pha, write_rmf