| AHELP for CIAO 4.4 Sherpa v2 | save_arrays |
Context: saving |
Synopsis
Save a list of arrays as columns to a FITS table or ASCII file
Syntax
save_arrays( filename, args, [fields=None,ascii=True,clobber=False] )
Description
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
- contrib
- save_chart_spectrum
- data
- dataspace1d, dataspace2d, 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
- filtering
- load_filter
- info
- get_default_id, list_bkg_ids, list_data_ids
- modeling
- add_model, add_user_pars, load_table_model, load_template_model, load_user_model, save_model, save_source
- saving
- 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
- statistics
- load_user_stat

![[Sherpa Logo]](../imgs/sherpa_logo_navbar.gif)