Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2010

Jump to: Description · Examples · See Also

AHELP for CIAO 4.3 Sherpa v1


Context: saving


Save all the information about the current session


save_all( [outfile="script.txt",clobber=False] )


The save_all function saves to a text file the settings which define the current Sherpa session, specifically the commands to load data from files, define models with user-specified parameter values, set a filter, and set the fit statistic and optimization method that were current when "save_all()" was called. The resulting text file can be read into a future Sherpa session to recreate the session.

To load the file - here saved as "psf_fit.txt" - into another Sherpa session:

sherpa> execfile("psf_fit.txt")

There is an alternate command, script, which saves every command typed in a Sherpa session; see "ahelp script" for information.

Things which are NOT saved by the save_all command:

  • User models are not saved.
  • If a load command such as load_data, load_pha, or load_ascii was used with optional keywords, these keywords are not saved.
  • Any command that is not a known Sherpa command, e.g. Python statements which may *include* valid Sherpa commands, are not saved.


  • outfile - the name of the file to write; default=None
  • clobber - Boolean to specify if existing 'outfile' should be overwritten; default = False

Example 1

sherpa> save_all()

When the save_all function is called without arguments, the settings defining the current Sherpa session (up until the point that the command is issued) are printed to the screen instead of being written to a file.

sherpa> load_pha("data.pi")
sherpa> notice_id(1,0.1,6.0)
sherpa> subtract()
sherpa> set_source(xsphabs.abs1*powlaw1d.p1)
sherpa> abs1.nH=0.07
sherpa> freeze(abs1.nH)
sherpa> set_method("neldermead")

sherpa> save_all()
if (get_data(1).grouped == False):
load_bkg(1,"data_bg.pi", bkg_id=1)
if (get_data(1).subtracted == False):



set_method_opt("iquad", 1)
set_method_opt("initsimplex", 0)
set_method_opt("verbose", 0)
set_method_opt("step", None)
set_method_opt("finalsimplex", 9)
set_method_opt("maxfev", None)
set_method_opt("ftol", 1.19209289551e-07)

abs1.integrate = True

abs1.nH._hard_min = 0.0
abs1.nH._min = 0.0
abs1.nH.modelname = "abs1" = "nH"
abs1.nH._guessed = False
[output omitted]
abs1.nH._max = 100000.0
abs1.nH.hidden = False
abs1.nH._hard_max = 3.40282346639e+38

p1.integrate = True

p1.gamma._hard_min = -3.40282346639e+38
p1.gamma._min = -10.0
p1.gamma.modelname = "p1" = "gamma"
p1.gamma._guessed = False
p1.gamma._val = 1.0
[output omitted]
p1.ampl.fullname = "p1.ampl"
p1.ampl._max = 3.40282346639e+38
p1.ampl.hidden = False
p1.ampl._hard_max = 3.40282346639e+38

set_source(1, (xsphabs.abs1 * powlaw1d.p1))

Example 2

sherpa> save_all("session1.txt")

The save_all function is used to save the settings of the current Sherpa session to the output text file session1.txt; this file can be used to restore the saved session at a later time. The file stores the Sherpa commands to load all data and responses, set filters, define source models, and set all model parameters which were current when the save_all command was issued. If a file with the same name already exists in the current working directory, it will not be overwritten since the 'clobber' argument is set to False by default.

Example 3

sherpa> save_all("session1.txt", clobber=True)

The save_all function is used to save the settings of the current Sherpa session to the output text file session1.txt. If a file with the same name already exists in the current working directory, it will be overwritten since the 'clobber' argument is set to True.

See Also

save_model, save_source
restore, save, save_arrays, 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

Last modified: December 2010
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2019. All rights reserved.