STScI Logo

fit xray.xspectral



fit -- finds best-fit model parameter values using a simplex minimization.




This task computes the best predicted fit to the observed data spectrum, after manipulating the free parameters in the models according to the Simplex minimization method. (See the help file on pkgpars for some quantities which can be set prior to execution.)


observed = "" prompt = observed spectrum []

This is a package wide parameter, found in the pkgpars parameter file.

The file names of one or more observed data sets on which the fit is to be performed. Multiple observation data sets can be specified by entering the file names, separated by semicolons, e.g. "foo1; foo2; foo3", etc. Normally these files have a "" extension. This extension need not be input explicitly; if the files do not follow this convention the explicit name should be typed.

Channels to fit for a given data set may be selected by appending a bracket notation to the file name. Thus "foo[3:11,15]" will cause channels 3 to 11 (inclusive) and 15 to be fit. If channels are not explicitly specified, the default channels for the given instrument are retrieved from the pkgpars parameter file.

model = "" prompt = model descriptor or ? for help

This is a package wide parameter, found in the pkgpars parameter file.

The ASCII model descriptor. If "?" is input a short help file appears, and the model prompt reappears. A null string ("") will cause the previously determined best model to be taken from the file. Type help models_spectral from the CL for further information.

The spectral model descriptor is the sum of individual model components with the option of applying absorption.

The general syntax for applying absorption to a component is:
    absorption(params) * component(params)

The general syntax for multiple model components is:
    abs(params) * compnt1(params) + abs(params) * compnt2(params) + ...

Possible components and arguments are:
powerlaw         log(normalization), energy index
bremsstrahlung   log(normalization), temperature [keV]
exponential      log(normalization), temperature [keV]
blackbody        log(normalization), temperature [keV]
raymond          log(normalization), temperature [keV], abundance table,
                                        abundance percent
line model       log(normalization), line-energy [keV],
                                        line-width [FWHM, in keV]

Absorption is applied as follows:
	absorption(galactic_Nh (log))
	absorption(intrinsic_Nh (log), redshift)
	absorption(galactic_Nh (log), intrinsic_Nh (log), redshift)

Unique abbreviations are recognized (e.g. pow). Parameters are specified by entering a single value (fixed) or a range (free) separated by ":". For free normalization of the first component, this parameter may be omitted. The normalization of a second component is linked to that of the first, other parameters may also be linked.
(pkgpars = "") [pset]

The name of the file containing the xspectral package wide parameters. If the name is null ("") then the parameters found for the pkgpars task will be used.

(max_iterations = 400) [int]

The maximum number of iterations allowed for the minimization technique.

(verbose = no) [boolean]

If set to "yes", then intermediate computational results are printed out to standard output.

(tolerance = 1.0E-3) [real]

The convergence tolerance for the fit. For more accurate results, this value should be reduced, e.g. 5.0E-6.

(rebin = no) [boolean]

For PSPC sources with only a few counts rebin should be set to yes and all the data will be binned into one channel. In this case, all paramaters in the chosen model must be given except for the first normalization.

Parameters from pkgpars .
The following are some of the parameters that can be found in the pkgpars parameter set that are used by this task.

(predicted = "new") [string]

Each input observed data file that is fit to a model results in an output predicted data file with the same root as the input file, and the extension "" instead of the input files "" extension. Since more than one input file can be used in a fit, more than one predicted file can be created as output.

The predicted data file contains all of the information contained in the input observed data files. In addition, three columns are added detailing the results of the fit. These are: "pred" (containing the predicted spectrum), "chisq" (containing the chi-square contribution for each channel) and "chans" (containing a "*" if that channel was used in the fit). The table may contain more than one set of predicted data, so the names of these columns are actually "pred_<N>", "chisq_<N>", and "chans_<N>", where <N> distinguishes the predicted data sets within the file (see below).

The predicted data set also contains header parameters that describe the model used in the fit (the best fit parameters), the total chi-square of the fit, and the file names of all observed data sets used in the fit.

This predicted parameter controls the creation of the predicted files. The parameter takes three possible values: "nothing", "new", or "append". If predicted is "nothing", no predicted data files are created. If the parameter value is "new", then the predicted data files are overwritten (if the clobber parameter is set to true). If the value is "append", then the predicted data columns are appended to the current predicted data file. In this case, the <N> number appended to the "pred", "chisq", and "chans" column names in incremented so that successive runs of a fit result, for example, in the successive predicted column names "pred_1", "pred_2", etc.

(clobber = YES) [boolean]

This flag determines whether the predicted data file can be over-written, assuming that the value of the predicted parameter is "new".

(chisquare = ".") [string]

The name of the table file containing accumulated chisquare results. The file will contain one row of the following columns for each fit performed: "date" (the time and date of the run), "chisq" (the total chisq of the fit), "chans" (the number of channels used in the fit), "free" (the number of free parameters used in the fit), "files" (a list of predicted data files generated by the fit, along with the <N> column number within each file - see above), "model" (the best fit model).

(absorption_type = "morrison") [string]

The type of absorption to be used. The options are "morrison mccammon" or "brown gould".

There are more parameters in pkgpars. See the pkgpars help file for a complete description.


Perform a fit on the input observed data set The source region is a circle of radius 3 arcmin (22.5 pixels) centered on pixel (503, 513); the background is a concentric annulus of inner radius 24 pixels and outer radius 40 pixels. The model consists of Galactic absorption ranging from 20.0 to 23.0, no redshift and a power law with energy index from 4.0 to 7.0.

xs> fit
Performing the Simplex minimization fit.
observed spectrum []: snr
model descriptor or ? for help: abs(20.0:23.0)*pow(4.0:7.0)
Found 3 free parameter(s).
Simplex 1
Found 1 dataset(s).

 Data set #1 from file:

 PHA energy range   observed     error   predicted (pred-obs)/error
 --- ------------   --------     -----   --------- ----------------
   1  0.06->0.19        16.3       8.8        20.5        0.5
   2  0.19->0.39        41.4      11.4        65.7        2.1
   3  0.39->0.64       191.1 *    19.1       178.4       -0.7
   4  0.64->0.91       377.4 *    26.5       375.1       -0.0
   5  0.91->1.21       543.1 *    32.4       581.8        1.2
   6  1.21->1.54       690.9 *    36.6       689.8       -0.0
   7  1.54->1.93       698.7 *    36.2       650.7       -1.3
   8  1.93->2.41       497.1 *    29.4       504.4        0.3
   9  2.41->3.12       319.8 *    22.5       329.0        0.4
  10  3.12->4.01       188.2 *    16.7       183.9       -0.3
  11  4.01->5.16        84.7 *    12.1        89.4        0.4
  12  5.16->6.91        35.7       9.3        38.2        0.3
  13  6.91->9.19        21.1       7.7        14.5       -0.9
  14  9.19->12.0        -0.8       7.2         4.9        0.8
  15 11.98->15.4         3.6       6.4         1.5       -0.3
               * indicates use in Chi-square calculation.

The fitted net counts are: 3591.01; with error: 80.99.

Chi-square =      4.084
Predicted Data file:
Intermediate Spectra file: ./

Model: abs(20.000:23.000)*pow(4.000:7.000)

Model Component 1: Power Law
          energy index = 5.981 (free)
    normalization (log) = 0.0956 (calculated)
    galactic Nh (log) = 22.399 (free)
    intrinsic Nh (log) = 0.000 (fixed)
          redshift = 0.000 (fixed)


Execution time is dependent upon the number of "free" parameters defined.


The file name must not begin with a numeral. The same is true for the model input file, if one is used. Beginning the file names of these files with a numeral causes the parser to attempt to process the numeral, resulting in an error.

Use of rebin=yes and predicted=append will cause uncertain results to be added to file.


Documentation on spectral models (help models_spectral ) for a description of the spectral model user interface.

singlefit, search_grid, pspc_fitting

Source Code · Search Form · STSDAS