Skip to the navigation links
Last modified: December 2009

AHELP for CIAO 4.2


Context: sl.crates


Write a crate to an output file.


write_file(crate, filename);


  • crate - input crate
  • filename - name of the output file

The write_file command creates an output file for the input crate, overwriting any existing file with the same name. This command may be used with any type of crate. The command returns a "1" if the file is written successfully.

The write_arf, write_pha, and write_rmf routines can be used when the type of the dataset is known.

Example 1

chips> cr = read_file("evt2.fits");
chips> delete_key(cr, "FILTER");
chips> write_file(cr, "edit.fits");

Delete the FILTER keyword from the crate, then write the crate to file edit.fits.

Example 2

chips> cr = read_file("tbl.dat");
chips> x = copy_colvals(cr, "x");
chips> y = copy_colvals(cr, "y");
chips> z = sqrt(x^2 + y^2);
chips> cd = CrateData;
chips> = "z";
chips> py_call (cd.load, z, 1);
chips> add_col(cr, cd);
chips> write_file(cr, "tbl2.dat[opt kernel=text/simple]");

In this example we read in the file tbl.dat, extract the x and y columns and create a new column, called z, from these values. This new column is added to the crate and then the crate is written out to the file tbl2.dat. The addition of the Data Model option "[opt kernel=text/simple]" ensures that the output is a text file (see "ahelp dmopt" and "ahelp dmascii" for more information on options and the ASCII file support in CIAO).

If the input file looked like:

unix% cat tbl.dat
# x y
1 2
3 5
9 10

then the output file will look like:

unix% cat tbl2.dat
# x y z
1.0 2.0 2.236067977500
3.0 5.0 5.830951894845
9.0 10.0 13.45362404707


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

See Also

add_col, add_key, add_piximg, delete_col, delete_key, delete_piximg, read_arf, read_file, read_pha, read_rmf, write_arf, write_pha, write_rmf
make_table_crate, scale_image_crate, write_columns

Last modified: December 2009