save_all
- sherpa.astro.ui.save_all(outfile=None, clobber=False) None
Save the information about the current session to a text file.
This differs to the
save
command in that the output is human readable. Three consequences are:numeric values may not be recorded to their full precision
data sets are not included in the file
some settings and values may not be recorded (such as header information).
Changed in version 4.17.0: The file will now contain a
set_default_id
call if the default identifier has been changed.Changed in version 4.16.0: Any set_psf calls are now included in the output file. The filter is no longer included if it does not exclude any data, and the code tries to recreate manually-created datasets (e.g. use of
dataspace1d
orload_arrays
), but not all situations are handled. XSPEC table models are now correctly restored.- Parameters:
outfile (str or file-like, optional) – If given, the output is written to this file, and the
clobber
parameter controls what happens if the file already exists.outfile
can be a filename string or a file handle (or file-like object, such asStringIO
) to write to. If not set then the standard output is used.clobber (bool, optional) – If
outfile
is a filename, then this flag controls whether an existing file can be overwritten (True
) or if it raises an exception (False
, the default setting).
- Raises:
sherpa.utils.err.IOErr – If
outfile
already exists andclobber
isFalse
.
See also
Notes
This command will create a series of commands that restores the current Sherpa set up. It does not save the set of commands used. Not all Sherpa settings are saved. Items not fully restored include:
grating data is not guaranteed to be restored correctly,
data changed from the version on disk - e.g. by calls to
set_counts
- will not be restored correctly,any optional keywords to commands such as
load_data
orload_pha
,user models may not be restored correctly,
and only a subset of Sherpa commands are saved.
Examples
Write the current Sherpa session to the screen:
>>> save_all()
Save the session to the file ‘fit.sherpa’, overwriting it if it already exists:
>>> save_all('fit.sherpa', clobber=True)
Write the contents to a StringIO object:
>>> from io import StringIO >>> store = StringIO() >>> save_all(store) >>> print(store.getvalue()) import numpy from sherpa.astro.ui import * ...