Synopsis
Add a column to a crate given a name and array of values
Syntax
add_colvals(crate, colname, colvals, unit=None, desc=None)
Description
Adds a column with a name of colname and contents of colvals - which should be an array - to the table crate. If the unit argument is not None then it is a string listing the units of the column. If desc is not None then it is used as the description of the column.
Loading the routine
The routine can be loaded into Python by saying:
from crates_contrib.utils import *
Example
>>> cr = read_file('table.dat') >>> c = get_colvals(cr, 'counts') >>> t = get_colvals(cr, 'exposure') >>> add_colvals(cr, 'rate', c/t, unit='s**-1') >>> write_file(cr, 'table.dat', clobber=True)
Here we add the column "rate", defined as counts/exposure, to the table and then overwrite the original file.
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
- make_table_crate, write_columns
- crates
- add_col, col_exists, copy_colvals, delete_col, get_col, get_col_names, get_colvals, get_number_cols, is_virtual, set_colvals