|
|
|
|
SynopsisWrite out the model spectrum in the form required by mkinstmap Syntaxsave_instmap_weights( [id=NULL,] outfile [, clobber=0]); DescriptionThe 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 routineThe routine can be loaded into Sherpa by saying:
require ("sherpa_utils");
Arguments
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 2sherpa> save_instmap_weights(3, "wgts.dat"); The weights are calculated using the model and grid defined for dataset 3. Example 3sherpa> 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. NOTESCalculating the weightsFor 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 gridThe 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");
BugsSee the bugs pages on the Sherpa website for an up-to-date listing of known bugs. See Also
|
![]() |
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. |