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

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


AHELP for CIAO 4.3 Sherpa v1

save_chart_spectrum

Context: contrib

Synopsis

Write out the model spectrum in the form required by ChaRT

Syntax

save_chart_spectrum( [outfile=None, verbose=True, id=None, elow=None,
ehigh=None, ewidth=None, norm=None] )

Description

The save_chart_spectrum() command writes out the current model values in the form expected by ChaRT, the Chandra Ray Tracer. Please see the ChaRT preparation thread for further information on how to use this routine.

Loading the routine

The routine can be loaded into Sherpa by saying:

from sherpa_contrib.chart import *

Arguments

Name Default value Description
outfile None The name of the file to create; the routine over-writes existing versions of the file. A value of None means that the data will be written to the standard output channel.
verbose True If verbose is True then a message will be printed to the standard output when the file has been created.
id None (which means use the value of get_default_id) Which dataset to use.
elow None The minimum energy at which to evaluate the model; this parameter controls the lower edge of the lowest-energy bin, and is in keV. A value of None means to use the lowest energy bin from the ARF grid. This value should not be smaller than 0.2 keV.
ehigh None The maximum energy at which to evaluate the model; this parameter controls the upper edge of the highest-energy bin, and is in keV. A value of None means to use the highest energy bin from the ARF grid. This valus should not be larger than 10 keV.
ewidth None The bin width to use, in keV. A value of None means to use the bin width from the ARF grid.
norm None A scaling factor to allow you to easily change the overall flux of the model. A value of None is equivalent to a factor of 1; a value of 10 would create a ChaRT spectral model ten times brighter than the input model.

Example 1

sherpa> load_pha("3c273.pi")
sherpa> subtract()
sherpa> notice(0.1, 6)
sherpa> set_source(xsphabs.abs1 * powlaw1d.p1)
sherpa> abs1.nh = 0.07
sherpa> freeze(abs1)
sherpa> guess(p1)
sherpa> fit()
...
sherpa> save_chart_spectrum("chart.dat")

Here we load in a source spectrum from the file 3c273.pi, along with the associated files (e.g. ARF, RMF, and background) that are indicated in its header. The background is subtracted, the analysis restricted to the 0.1 to 6 keV range, a model is created - consisting of an absorbed power law - and then parameter values are set before the fit is made.

After the fit has been made the save_chart_spectrum() routine is used to write out the best-fit model - in a format usable by ChART - to the text file "chart.dat".

Example 2

sherpa> save_chart_spectrum("chart.dat", elow=1, ehigh=8)

In this example the output is restricted to the range 1 to 8 keV, using the default binning given by the ARF grid. Note that this energy range need not overlap the range used to fit the data (or even the energy ranges of the ARF and RMF files). It should however remain within the range 0.2 to 10 keV.

Example 3

sherpa> save_chart_spectrum(elow=1, ehigh=8)

The data is written to the screen rather than a file.

Bugs

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

See Also

contrib
get_chart_spectrum, plot_chart_spectrum, sherpa_chart
modeling
save_model, save_source
saving
restore, save, save_all, 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 2009
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-2019. All rights reserved.