Last modified: April 2019

URL: https://cxc.cfa.harvard.edu/sherpa/ahelp/save_marx_spectrum.html
AHELP for CIAO 4.17 Sherpa

save_marx_spectrum

Context: contrib

Synopsis

Write out the model spectrum in the form required by MARX

Syntax

save_marx_spectrum(outfile, clobber=True, verbose=True, id=None,
elow=None, ehigh=None, ewidth=None, norm=None)

Description

The save_marx_spectrum() command writes out the current model values in the form expected by MARX (the Chandra simulator). Please see the MARX documentation of the spectrum format for further information on how to use this routine.

Loading the routine

The routine can be loaded into Sherpa by saying:

from sherpa_contrib.marx import *

Arguments

Name Default value Description
outfile The name of the file to create.
clobber True Determines the behavior if the output file already exists: a value of True (the default) means that the file will be overwritten, otherwise an error will be raised.
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 dataset to use: if None then the value returned by get_default_id() will be used.
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 MARX spectral model ten times brighter than the input model.

Examples

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_marx_spectrum("marx.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_marx_spectrum() routine is used to write out the best-fit model - in a format usable by MARX - to the text file "marx.dat".

Example 2

sherpa> save_marx_spectrum("marx.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.


Changes in the scripts 4.11.2 (April 2019) release

Fixes to save_marx_spectrum

The sherpa_contrib.marx.save_marx_spectrum() function now normalizes the output by the bin width, as expected by MARX.


Bugs

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

See Also

contrib
get_marx_spectrum, plot_marx_spectrum, save_chart_spectrum, sherpa_marx
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