| AHELP for CIAO 4.4 | add_colvals |
Context: contrib |
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 a ChIPS or Sherpa session by saying:
from crates_contrib.utils import *
Example
chips> cr = read_file('table.dat')
chips> c = get_colvals(cr, 'counts')
chips> t = get_colvals(cr, 'exposure')
chips> add_colvals(cr, 'rate', c/t, unit='s**-1')Here we add the column "rate", defined as counts/exposure, to the table.
Integer arrays
On 64-bit build machines, any NumPy array with a dataype of np.int32 will be converted to np.int64 before being added to the crate. This is to work around a bug in CIAO 4.4 release 1, where np.int32 columns are written out incorrectly by the write method of the crate or the write_file() routine.
Changes in the January 2012 Release
The add_colvals() routine is new in this release.
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.

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