set_par

sherpa.astro.ui.set_par(par: str | Parameter, val: float | None = None, min: float | None = None, max: float | None = None, frozen: bool | None = None) None

Set the value, limits, or behavior of a model parameter.

Parameters:
parstr

The name of the parameter, using the format “componentname.parametername”.

valnumber, optional

Change the current value of the parameter.

minnumber, optional

Change the minimum value of the parameter (the soft limit).

maxnumber, optional

Change the maximum value of the parameter (the soft limit).

frozenbool, optional

Freeze (True) or thaw (False) the parameter.

Raises:
sherpa.utils.err.ArgumentErr

If the par argument is invalid: the model component does not exist or the given model has no parameter with that name.

See also

freeze

Fix model parameters so they are not changed by a fit.

get_par

Return a parameter of a model component.

link

Link a parameter value to an associated value.

thaw

Allow model parameters to be varied during a fit.

unlink

Unlink a parameter value.

Notes

The parameter object can be used to change these values directly, by setting the attribute with the same name as the argument - so that:

set_par('emis.flag', val=2, frozen=True)

is the same as:

emis.flag.val = 2
emis.flag.frozen = True

Examples

Change the parameter value to 23.

>>> set_par('bgnd.c0', 23)

Restrict the line.ampl parameter to be between 1e-4 and 10 and to have a value of 0.1.

>>> set_par('line.ampl', 0.1, min=1e-4, max=10)