Last modified: December 2024

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

guess

Context: modeling

Synopsis

Estimate the parameter values and ranges given the loaded data.

Syntax

guess(id=None, model=None, limits=True, values=True)

Description

The guess function can change the parameter values and limits to match the loaded data. This is generally limited to changing the amplitude and position parameters (sometimes just the values and sometimes just the limits). The parameters that are changed depend on the type of model.


Examples

Example 1

Since the source expression contains only one component, guess can be called with no arguments:

>>> set_source(polynom1d.poly)
>>> guess()

Example 2

Both components - that is, gal and pl - will be passed to the guess routine, but not all models can have their parameters guessed, and there is no attempt to recognize that the models are combined (in this case by multiplication):

>>> set_source(xsphabs.gal * powlaw1d.pl)
>>> guess()

Example 3

In this case, guess is called on each component separately.

>>> set_source(gauss1d.line + powlaw1d.cont)
>>> guess(line)
>>> guess(cont)

Example 4

In this example, the values of the src model component are guessed from the "src" data set, whereas the bgnd component is guessed from the "bgnd" data set.

>>> set_source("src", gauss2d.src + const2d.bgnd)
>>> set_source("bgnd", bgnd)
>>> guess("src", src)
>>> guess("bgnd", bgnd)

Example 5

The above could also have been written as:

>>> guess("src", src)
>>> guess("bgnd")

Example 6

Set the source model for the default dataset. Guess is run to determine the values of the model component "p1" and the limits of the model component "g1":

>>> set_source(powlaw1d.p1 + gauss1d.g1)
>>> guess(p1, limits=False)
>>> guess(g1, values=False)

PARAMETERS

The parameters for this function are:

Parameter Type information Definition
id int or str, optional The data set that provides the data. If not given then the default identifier is used, as returned by `get_default_id` .
model Change the parameters of this model component. If none , then the source expression is assumed to consist of a single component, and that component is used.
limits bool Should the parameter limits be changed? The default is True .
values bool Should the parameter values be changed? The default is True .

Notes

The function does not follow the normal Python standards for parameter use, since it is designed for easy interactive use. When called with a single un-named argument, it is taken to be the `model` parameter. If given two un-named arguments, then they are interpreted as the `id` and `model` parameters, respectively.

The guess function can reduce the time required to fit a data set by moving the parameters closer to a realistic solution. It can also be useful because it can set bounds on the parameter values based on the data: for instance, many two-dimensional models will limit their xpos and ypos values to lie within the data area. This can be done manually, but `guess` simplifies this, at least for those parameters that are supported. Instrument models - such as an ARF and RMF - should be set up before calling guess.

Changes in CIAO

Changed in CIAO 4.17

The guess routine will now work with composite models and those which include an instrumental response, such as an ARF. It only works on individual models, so the values, and limits, guessed are only approximate.


Bugs

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

See Also

contrib
renorm
modeling
freeze, link, paramprompt, reset, set_par, thaw, unlink