Skip to the navigation links
Last modified: December 2009

URL: http://cxc-newtest.cfa.harvard.edu/ciao4.2/add_col.py.html
AHELP for CIAO 4.2

add_col

Context: py.crates

Synopsis

Add a column to a crate.

Syntax

add_col(crate, cratedata)

Description

  • crate - input crate
  • cratedata - CrateData object to be added

The add_col command adds the column to the crate. If the column already exists in the crate, it is replaced. The command returns a "1" if the column is successfully added.

The column is only added to the crate. The write_file ("ahelp write_file") command can be used to save the modified crate to a file.

Example

>>> cr = read_file("evt2.fits")
>>> print get_col_names(cr)
['CHANNEL' 'E_MIN' 'E_MAX']
>>> emin = copy_colvals(cr, "E_MIN")
>>> emax = copy_colvals(cr, "E_MAX")
>>> emid = 0.5 * (emin + emax)
>>> col = CrateData()
>>> col.name = "E_MID"
>>> col.load(emid, 1)
1
>>> add_col(cr, col)
1
>>> print get_col_names(cr)
['CHANNEL' 'E_MIN' 'E_MAX' 'E_MID']

Here we create a column called E_MID, whose values are the mid-points of the E_MIN and E_MAX columns, and then add it to the crate.

Bugs

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

See Also

py.crates
add_key, add_piximg, col_exists, copy_colvals, delete_col, delete_key, delete_piximg, get_col, get_col_names, get_colvals, get_number_cols, is_virtual, print_col_names, read_arf, read_file, read_pha, read_rmf, set_colvals, write_arf, write_file, write_pha, write_rmf
py.crates_contrib
make_table_crate, scale_image_crate, write_columns

Last modified: December 2009