write_arrays
- sherpa.io.write_arrays(filename: str, args: Sequence[Sequence[float] | ndarray], fields: Sequence[str] | None = None, sep: str = ' ', comment: str = '#', clobber: bool = False, linebreak: str = '\n', format: str = '%g') None[source] [edit on github]
Write a list of arrays to an ASCII file.
- Parameters:
- filename
str The name of the file to write the array to.
- argsarray_like
The arrays to write out.
- fieldsarray_like
ofstr The column names (should match the size of
argsif given).- sep
str,optional The separator character. The default is
' '.- comment
str,optional The comment character. The default is
'#'. This is only used to write out the column names whenfieldsis notNone.- clobberbool,
optional If
filenameis notNone, then this flag controls whether an existing file can be overwritten (True) or if it raises an exception (False, the default setting).- 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%'.
- filename
- Raises:
sherpa.utils.err.IOErrIf
filenamealready exists andclobberisFalseor if there is no data to write.
See also
Examples
Write the x and y arrays to the file ‘src.dat’:
>>> write_arrays('src.dat', [x, y])
Use the column names “r” and “surbri” for the columns:
>>> write_arrays('prof.txt', [x, y], fields=["r", "surbri"], clobber=True)