Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2013

Jump to: Description · Examples · See Also

AHELP for CIAO 4.9 Sherpa v1


Context: saving


Save a list of arrays as columns to a FITS table or ASCII file


save_arrays( filename, args, [fields=None,ascii=True,clobber=False] )


The save_arrays() function saves a list of user-specified arrays as columns to a FITS table or ASCII text file, with the option of entering column titles. The arrays supplied to save_arrays() may be read from a column-based text file or FITS table by referencing the data set ID to which the file was assigned when loaded into Sherpa.

  • filename - name of outfile
  • args - array of column arrays to be written to outfile
  • fields - array of strings representing the column names; default=None (omit column names)
  • ascii - outfile format specification; True to save outfile in ASCII format, False for FITS, default=True
  • clobber - clobber outfile; default=False (do not clobber if file exists)

Example 1

sherpa> save_arrays("arrays.txt", [a,b,c])

The save_arrays function can be called with just a filename and list of arrays, in which case all the default arguments will be used. In this example, the arrays 'a', 'b' and 'c' are written as columns to the ASCII file 'arrays.txt'.

Example 2

sherpa> save_arrays("arrays.fits", [a,b,c], ascii=False)

Here, the 'ascii' optional argument is set to False so that arrays 'a', 'b', and 'c' are written to a FITS format file, 'array.fits'.

Example 3

sherpa> save_arrays("image2_axes.dat", [get_data(2).x0, get_data(2).x1,
get_data(2).y], ["Image2 x0 array","Image2 x1 array", "Image2 y
array"], clobber=False)

In this example, the x0, x1, and y arrays of the image data set 'image2.fits' are written as columns to the text file 'image2_axes.dat'. The arrays are read from image2.fits with the get_data() function using the argument id=2, since image2.fits is assigned to Sherpa data set id=2. If file image2_axes.dat already exists in the current working directory, it will not be overwrittenm since clobber is set to False.

See Also

dataspace1d, dataspace2d, datastack, fake, load_arf, load_arrays, load_ascii, load_bkg, load_bkg_arf, load_bkg_rmf, load_data, load_grouping, load_image, load_multi_arfs, load_multi_rmfs, load_pha, load_quality, load_rmf, load_staterror, load_syserror, load_table, pack_image, pack_pha, pack_table, unpack_arf, unpack_arrays, unpack_ascii, unpack_bkg, unpack_data, unpack_image, unpack_pha, unpack_rmf, unpack_table
get_default_id, list_bkg_ids, list_data_ids
add_model, add_user_pars, load_table_model, load_template_model, load_user_model, save_model, save_source
restore, save, save_all, save_data, save_delchi, save_error, save_filter, save_grouping, save_image, save_pha, save_quality, save_resid, save_staterror, save_syserror, save_table, script

Last modified: December 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2017. All rights reserved.