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

Skip the navigation links
Last modified: December 2006

URL: http://cxc.harvard.edu/ciao3.4/fit.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 3.4 fit Context: sherpa

Synopsis

Initiates fitting (optimization). The command [B]RUN is equivalent.

Syntax

sherpa> {[B]FIT | [B]RUN} [<dataset range> | ALLSETS] [ID]

FIT and RUN are used in initiate fitting of all appropriate source and
background datasets (i.e., those for which SOURCE and/or BACKGROUND
model stacks have been defined), while BFIT and BRUN are used to
initiate fitting of appropriate background datasets only.

<dataset range> = # (or more generally #:#,#:#, etc.) such that #
specifies a dataset number and #:# represents an inclusive range of
datasets; one may specify multiple inclusive ranges by separating them
with commas. The default is to fit all appropriate datasets. The ID
modifier is used if and only if the Sherpa state object variable
multiback is set to 1, i.e., if more than one background dataset is to
be associated with a single source dataset. The ID modifier may be any
unreserved string (e.g., A, foo, etc.), i.e., a string that is not a
parsable command.

In CIAO 3.1 the definition of INSTRUMENT BACK is required for fitting
PHA data if either background file or background models have been
defined. INSTRUMENT BACK is set automatically when the PHA data file is
input to Sherpa, however it is deleted if the NEW background file is
input for a given data set. Thus the new INSTRUMENT BACK has to be
defined on the command line before starting a simultaneous fit with the
new background file.

Description

Fitting may also be initiated via the Sherpa/S-Lang module function run_fit. (This is equivalent to FIT; there is no module function equivalent of BFIT in CIAO 3.0.)

Example 1

Fit a source model to one dataset:

sherpa> READ DATA 1 example1.dat
sherpa> PARAMPROMPT OFF
Model parameter prompting is off
sherpa> POLY[modela]
sherpa> SOURCE 1 = modela
sherpa> THAW modela.2 modela.3
sherpa> FIT

The fourth command, SOURCE 1 = modela, defines the Sherpa model POLY as the source model to be used for fitting dataset number 1. The last command, FIT, fits source model number 1 to its corresponding dataset. For this example, the following command is equivalent to the last command:

sherpa> FIT 1

Example 2

Fit a source model to one dataset, when multiple source models have been defined:

sherpa> ERASE ALL
sherpa> READ DATA 1 example1.dat
sherpa> POLY[modela]
sherpa> GAUSS[modelb]
sherpa> SOURCE 1 = modela
sherpa> SOURCE 2 = modelb
sherpa> THAW modela.2 modela.3
sherpa> FIT 1

The last command fits source model number 1 to its corresponding dataset. Note that source model number 2 does not have a corresponding dataset, and so no fitting for this model will be performed; thus for this example, the following command is equivalent to the last command:

sherpa> FIT

Example 3

Fit a source model to one dataset, when multiple source models have been defined and multiple datasets have been input:

sherpa> ERASE ALL
sherpa> READ DATA 1 example1.dat
sherpa> READ DATA 2 example2.dat
sherpa> POLY[modela]
sherpa> GAUSS[modelb]
sherpa> SOURCE 1 = modela
sherpa> SOURCE 2 = modelb
sherpa> THAW modela.2 modela.3
sherpa> FIT 1

The last command fits source model number 1 to its corresponding dataset. Note that source model number 2 is not fit to its corresponding dataset, because only source model number 1 is specified in the FIT command. In this example, the following commands could be issued to fit source model number 2 to its corresponding dataset:

sherpa> GUESS SOURCE 2
sherpa> FIT 2

Note that the GUESS SOURCE 2 command is issued, in order to start the initial parameter values and ranges, of source model number 2, at estimates based on the input dataset number 2. See the GUESS command for futher information.

Example 4

Independently fit the same model shape to different datasets:

sherpa> ERASE ALL
sherpa> READ DATA 1 example1.dat
sherpa> READ DATA 2 example2.dat
sherpa> POLY[modela]
sherpa> POLY[modelb]
sherpa> SOURCE 1 = modela
sherpa> SOURCE 2 = modelb
sherpa> THAW modela.2 modela.3
sherpa> THAW modelb.2 modelb.3
sherpa> GUESS SOURCE 2
sherpa> FIT

The last command fits source model number 1 to its corresponding dataset (dataset number 1), and fits source model number 2 to its corresponding dataset (dataset number 2). In this example, source models 1 and 2 are the same model, but with separate and independent parameters. The GUESS SOURCE 2 command is issued in order to start the initial parameter values and ranges, of source model number 2, at estimates based on the input dataset number 2. See the GUESS command for futher information. For this example, the following commands are equivalent to the last command:

sherpa> FIT 1,2
sherpa> FIT 1:2
sherpa> FIT ALLSETS

Example 5

Perform a joint fit of two datasets using the same source model:

sherpa> ERASE ALL
sherpa> READ DATA 1 example1.dat
sherpa> READ DATA 2 example2.dat
sherpa> POLY[modela]
sherpa> SOURCE 1:2 = modela
sherpa> THAW modela.2 modela.3
sherpa> FIT

The last command fits source model number 1 to its corresponding dataset (dataset number 1), and fits source model number 2 to its corresponding dataset (dataset number 2). In this example, source models 1 and 2 are the same model, with shared parameters. For this example, the following commands are equivalent to the last command:

sherpa> FIT 1,2
sherpa> FIT 1:2
sherpa> FIT ALLSETS

Note that in this example, the command FIT 1 would have fit the source model only to dataset number 1; the command FIT 2 would have fit the source model only to dataset number 2.

Example 6

Independently fit the same model shape to different datasets, but link one source model parameter to another:

sherpa> ERASE ALL
sherpa> READ DATA 1 example1.dat
sherpa> READ DATA 2 example2.dat
sherpa> POLY[modela]
sherpa> POLY[modelb]
sherpa> SOURCE 1 = modela
sherpa> SOURCE 2 = modelb
sherpa> modelb.c0 => modela.c0
sherpa> THAW modela.2 modela.3
sherpa> FIT

The last command fits source model number 1 to its corresponding dataset (dataset number 1), and fits source model number 2 to its corresponding dataset (dataset number 2). In this example, source models 1 and 2 are the same model, but with separate and independent parameters, for all parameters except c0. Parameter c0 is a shared parameter, as set by the parameter expression, in the eighth command (see the CREATE command for further information on model parameter expressions). For this example, the following commands are equivalent to the last command:

sherpa> FIT 1,2
sherpa> FIT 1:2
sherpa> FIT ALLSETS

Example 7

Perform a joint fit of some (but not all) input datasets using the same source model:

sherpa> ERASE ALL
sherpa> READ DATA 1 example1.dat
sherpa> READ DATA 2 example2.dat
sherpa> READ DATA 3 example3.dat
sherpa> READ DATA 4 example4.dat
sherpa> POLY[modela]
sherpa> SOURCE 1 = modela
sherpa> SOURCE 2 = modela
sherpa> SOURCE 3 = modela
sherpa> SOURCE 4 = modela
sherpa> THAW modela.2 modela.3
sherpa> FIT 2,3

The last command fits source model number 2 to its corresponding dataset (dataset number 2), and fits source model number 3 to its corresponding dataset (dataset number 3). In this example, source models 2 and 3 are the same model, with shared parameters. Note that because source models 1 through 4 are all the same model, with shared parameters, one may specify to simultaneously fit to any of the input datasets. The command

sherpa> FIT 1,4

fits the source model to datasets number 1 and 4. The command

sherpa> FIT 2:4

(or FIT 2,3,4) fits the source model to datasets number 2, 3, and 4. The command

sherpa> FIT 1:4

(or FIT 1,2,3,4, or FIT, or FIT ALLSETS) fits the source model to all of the input datasets.

Example 8

Perform a fit to a background dataset:

sherpa> READ DATA 1 example1.dat
sherpa> READ BACK 1 example1_back.dat
sherpa> SOURCE 1 = POLY[modela]
sherpa> BACKGROUND 1 = POLY[modelb]
sherpa> BFIT 1

The command BFIT instructs Sherpa to fit modelb to the input background data only, ignoring the source data and source model stack. For this example, the following commands are equivalent to the last command:

sherpa> BFIT

or

sherpa> SOURCE 1 = 
sherpa> FIT 1        # or simply FIT

Bugs

See the Sherpa bug pages online for an up-to-date listing of known bugs.

Hardcopy (PDF): A4 | Letter
Last modified: December 2006



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.