About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: August 2009

URL: http://cxc.harvard.edu/ciao4.1/save_instmap_weights.sl.html
AHELP for CIAO 4.1

save_instmap_weights

Context: sl.sherpa_contrib

Synopsis

Write out the model spectrum in the form required by mkinstmap

Syntax

save_instmap_weights( [id=NULL,] outfile [, clobber=0]);

Description

The save_instmap_weights() command writes out the current model values in the form expected by the CIAO mkinstmap tool. Please see the Calculating Spectral Weights thread for further information on how to use this routine.

Loading the routine

The routine can be loaded into Sherpa by saying:

require ("sherpa_utils");

Arguments

Name Default value Description
id NULL (which means use the value of get_default_id) Which dataset to use.
outfile The name of the file to create.
clobber 1 Should the file be overwritten if it already exists: 0 means yes, otherwise no.

Example 1

sherpa> dataspace1d(0.5,7,0.1);
sherpa> set_source(xsphabs.abs1 * powlaw1d.p1);
sherpa> abs1.nh = 0.07;
sherpa> p1.gamma = 1.7;
sherpa> plot_instmap_weights();
sherpa> save_instmap_weights("imap.dat");

We want to create a weights file for the energy range 0.5 to 7 keV, using an absorbed power law as the model.

The dataspace1d command is used to set the grid over which the model is evaluated; in this case we go from 0.5 to 7 keV with a step size of 0.1 keV. The next lines set the source model and set the relevant parameters. In this case we do not need to change the amplitude/normalization of the power law since the weights are normalized to a value of 1.0. If you had multiple source terms in your model expression then you would need to set the relative normalizations of the various components.

Finally we plot the weights and then save them to the ASCII file "imap.dat". This file can then be used as input to the spectrumfile parameter of mkinstmap.

Example 2

sherpa> save_instmap_weights(3, "wgts.dat");

The weights are calculated using the model and grid defined for dataset 3.

Example 3

sherpa> save_instmap_weights(3, "wgts.dat", 0);

As in the previous example, the weights are calculated using the model and grid defined for dataset 3, but this time the routine will not overwrite wgts.dat if it already exists.

Example 4

sherpa> save_instmap_weights("wgts.dat", 0);

The weights are calculated using the model and grid defined for the default dataset, and written to wgts.dat only if the file does not already exist.

NOTES

Calculating the weights

For a model spectrum which has units of photon/cm^2/s as a function of energy (i.e. the model is integrated across each bin, as is the case with X-Spec and Sherpa models), then the weights are calculated using the formula

weight_i = y_i / sum(y_i)

where sum(y_i) is the sum of the model spectrum over all the bins being used.

Creating the energy grid

The simplest way to create the grid is to use the dataspace1d command: if you want an instrument map created over the energy range e1 to e2 (in keV), then say

sherpa> dataspace1d(e1, e2, edelta);

where edelta is the width of each bin. The idea is to select a bin width over which the combination of effective area and detector sensitivity is approximately flat; too large a step size may result in an incorrect result, whereas too small a step size will result in increasing the processing time of mkinstmap. See the "Introduction to Exposure Maps" document for more information.

You can also use the energy grid defined by a PHA file, for example the following will use the energy bins in the range 0.5 to 7 keV:

sherpa> load_pha("src.pha");
sherpa> notice(0.5,7);
sherpa> set_source(xsphabs.gal * xspowerlaw.pl);
sherpa> gal.nh = 0.23;
sherpa> pl.phoindex = 1.5;
sherpa> save_instmap_weights("wgt.txt");

Bugs

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

Last modified: August 2009



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