guess

sherpa.ui.guess(id=None, model=None, limits=True, values=True)

Estimate the parameter values and ranges given the loaded data.

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.

Parameters:
  • 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.

See also

get_default_id()
Return the default data set identifier.
reset()
Reset the model parameters to their default settings.
set_par()
Set the value, limits, or behavior of a model parameter.

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.

Examples

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

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

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

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

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)