Skip to the navigation links
Last modified: December 2009

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

add_col

Context: sl.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

slsh> cr = read_file("evt2.fits");
slsh> print (get_col_names(cr));
['CHANNEL' 'E_MIN' 'E_MAX']
slsh> emin = copy_colvals(cr, "E_MIN");
slsh> emax = copy_colvals(cr, "E_MAX");
slsh> emid = 0.5 * (emin + emax);
slsh> col = CrateData();
slsh> col.name = "E_MID";
slsh> py_call(col.load, emid, 1);
1
slsh> add_col(cr, col);
1
slsh> 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.

The syntax for adding data to a column - namely

py_call(col.load, <values>, 1)

- will be improved in a later release.

Bugs

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

See Also

sl.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
sl.crates_contrib
make_table_crate, scale_image_crate, write_columns

Last modified: December 2009