Skip to the navigation links
Last modified: December 2009

AHELP for CIAO 4.2


Context: py.crates


Set the values of a column in a crate.


set_colvals(crate, colid, values)


  • crate - input crate; allowed values are table, ARF, PHA, or RMF
  • colid - column name or number, where the first column is numbered 0
  • values - array of values

The set_colvals command sets the values of the specified column within the crate. To create an entirely new column, use the add_col command ("ahelp add_col").

The crate must be of type 'Table', 'ARF', 'PHA', or 'RMF'; for an IMAGECrate, use the set_piximgvals command. The command returns a "1" if the values are successfully added.

The value is only changed in the crate; the input file is unaffected. The write_file command ("ahelp write_file") can be used to save the modified crate to a file.

Example 1

chips> cr = read_file("evt2.fits")
chips> orig = get_colvals(cr, "energy")
chips> set_colvals(cr, "energy", orig+0.2)
chips> write_file(cr, "energy_evt2.fits")

Increase the values in the "energy" column by 0.2 in the crate, then write out the new file as energy_evt2.fits.

Example 2

chips> cr = read_file("table.fits")
chips> nrows = get_number_rows(cr)
chips> set_colvals(cr, 1, np.arange(nrows)+1)
chips> write_file(cr, "rowct.fits")

The second column in the crate (counting from 0) is edited to contain the row number value (starting count at 1). The edited crate is written out to the file rowct.fits.


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

See Also

add_col, col_exists, copy_colvals, delete_col, get_col, get_col_names, get_colvals, get_number_cols, is_virtual, print_col_names, set_keyval, set_piximgvals

Last modified: December 2009