Last modified: December 2015

URL: https://cxc.cfa.harvard.edu/ciao/ahelp/delete_col.html
Jump to: Description · Examples · Bugs · See Also


AHELP for CIAO 4.17

delete_col

Context: crates

Synopsis

Delete a column from a crate.

Syntax

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

Description

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.


Examples

Example 1

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

Example 2

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


Bugs

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

contrib
add_colvals, make_image_crate, make_table_crate, scale_image_crate, smooth_image_crate, write_arrays, write_columns
crates
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