| AHELP for CIAO 4.4 | add_col |
Context: 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 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("mdl.fits")
>>> print(get_col_names(cr))
['E_MIN' 'E_MAX' 'MDLFLUX']
>>> emin = copy_colvals(cr, "E_MIN")
>>> emax = copy_colvals(cr, "E_MAX")
>>> emid = 0.5 * (emin + emax)
>>> col = CrateData()
>>> col.name = "E_MID"
>>> col.values = emid
>>> add_col(cr, col)
>>> print(get_col_names(cr))
['E_MIN' 'E_MAX' 'MDLFLUX' 'E_MID']
>>> write_file(cr, "mdl2.fits")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. The write_file call creates a new file which includes this column.
Changes in CIAO 4.4
The routine no longer returns a value (1) to indicate it was succesfull.
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_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, read_file, read_pha, read_rmf, set_colvals, write_file, write_pha, write_rmf

![[CIAO Logo]](../imgs/ciao_logo_navbar.gif)