save_all

sherpa.astro.ui.save_all(outfile=None, clobber=False)

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:

  1. numeric values may not be recorded to their full precision
  2. data sets are not included in the file
  3. some settings and values may not be recorded.
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 as StringIO) 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 and clobber is False.

See also

save()
Save the current Sherpa session to a file.
restore()
Load in a Sherpa session from a file.

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:

  • data created by calls to load_arrays, or changed from the version on disk - e.g. by calls to sherpa.astro.ui.set_counts.
  • any optional keywords to comands such as load_data or load_pha
  • user models may not be restored correctly
  • 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 six import StringIO
>>> store = StringIO()
>>> save_all(store)