Chandra X-Ray Observatory
	(CXC)
Skip to the navigation links
Last modified: December 2016

URL: http://cxc.harvard.edu/sherpa/ahelp/save_all.html
Jump to: Description · Examples · Bugs · See Also


AHELP for CIAO 4.9 Sherpa v1

save_all

Context: saving

Synopsis

Save all the information about the current session

Syntax

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

Description

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.

Arguments:

  • 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 (in the following, the ellipsis "..." is used to indicate that some text is not being shown):

sherpa> load_pha("data.pi")
sherpa> notice(0.5, 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()
from sherpa.astro.ui import *
import numpy

######### Load Data Sets

load_data(1,"data.pi")

...

######### Set Energy or Wave Units

set_analysis(1, 'energy', "rate", 0)
if (get_data(1).subtracted == False):
	######### Subtract Background Data
	subtract(1)

######### Filter Data

notice_id(1,"0.503699988127:5.993299961090")


######### Set Statistic

set_stat("chi2gehrels")


######### Set Fitting Method

set_method("neldermead")

...

######### Set Source, Pileup and Background Models

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




######### XSPEC Module Settings

set_xschatter(0)
set_xsabund("angr")
set_xscosmo(70, 0, 0.73)
set_xsxsect("bcmc")

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.

Bugs

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

See Also

contrib
save_chart_spectrum
modeling
save_model, save_source
saving
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 2016
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:   cxchelp@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2017. All rights reserved.