save_arrays¶
-
sherpa.ui.
save_arrays
(filename, args, fields=None, clobber=False, sep=' ', comment='#', linebreak='\n', format='%g')¶ Write a list of arrays to an ASCII file.
Parameters: - filename (str) – The name of the file to write the array to.
- args (array of arrays) – The arrays to write out.
- fields (array of str) – The column names (should match the size of args).
- clobber (bool, optional) – If filename is not
None
, then this flag controls whether an existing file can be overwritten (True
) or if it raises an exception (False
, the default setting). - sep (str, optional) – The separator character. The default is
' '
. - comment (str, optional) – The comment character. The default is
'#'
. - linebreak (str, optional) – Indicate a new line. The default is
'\n'
. - format (str, optional) – The format used to write out the numeric values. The
default is
'%g%'
.
Raises: sherpa.utils.err.IOErr
– If filename already exists and clobber isFalse
.See also
save_data()
- Save the data to a file.
Examples
Write the x and y columns from the default data set to the file ‘src.dat’:
>>> x = get_indep() >>> y = get_dep() >>> save_arrays('src.dat', [x, y])
Use the column names “r” and “surbri” for the columns:
>>> save_arrays('prof.txt', [x, y], fields=["r", "surbri"], clobber=True)