XSBaseParameter

class sherpa.astro.xspec.XSBaseParameter(modelname, name, val, min=-3.4028234663852886e+38, max=3.4028234663852886e+38, hard_min=-3.4028234663852886e+38, hard_max=3.4028234663852886e+38, units='', frozen=False, alwaysfrozen=False, hidden=False, aliases=None)[source] [edit on github]

Bases: Parameter

An XSPEC parameter.

XSPEC has soft and hard parameter limits, which are the ones sent in as the min, max, hard_min, and hard_max parameters. However, Sherpa’s soft limits are more-like the XSPEC hard limits, and it is possible in XSPEC to change a model’s hard limits. This class therefore:

  • stores the input min and max values as the _xspec_soft_min and _xspec_soft_max attributes and the hard_min and hard_max values as _xspec_hard_min and _xspec_hard_max attributes;

  • sets the underlying min and max values to the XSPEC hard limits;

  • and sets the underlying hard_min and hard_max values to the XSPEC hard limits.

Note that you can not change the hard limits; for that see XSParameter.

See also

XSParameter

Examples

>>> p = XSBaseParameter('mod', 'p', 2, min=1, max=9, hard_min=0, hard_max=10)
>>> p.min
0.0
>>> p.hard_min
0.0
>>> p.max
10.0
>>> p.hard_max
10.0
>>> p.val = 20
sherpa.utils.err.ParameterErr: parameter mod.p has a maximum of 10

Attributes Summary

alwaysfrozen

Is the parameter always frozen?

default_max

default_min

default_val

The default value of the parameter.

frozen

Is the parameter currently frozen?

hard_max

The hard maximum of the parameter.

hard_min

The hard minimum of the parameter.

link

The link expression to other parameters, if set.

max

The maximum value of the parameter.

min

The minimum value of the parameter.

val

The current value of the parameter.

Methods Summary

freeze()

Set the frozen attribute for the parameter.

reset()

Reset the parameter value and limits to their default values.

set([val, min, max, frozen, default_val, ...])

Change a parameter setting.

thaw()

Unset the frozen attribute for the parameter.

unlink()

Remove any link to other parameters.

Attributes Documentation

alwaysfrozen

Is the parameter always frozen?

default_max
default_min
default_val

The default value of the parameter.

See also

val

frozen

Is the parameter currently frozen?

Those parameters created with alwaysfrozen set can not be changed.

See also

alwaysfrozen

hard_max

The hard maximum of the parameter.

See also

hard_min

hard_min

The hard minimum of the parameter.

See also

hard_max

The link expression to other parameters, if set.

The link expression defines if the parameter is not a free parameter but is actually defined in terms of other parameters.

See also

val

Examples

>>> a = Parameter("mdl", "a", 2)
>>> b = Parameter("mdl", "b", 1)
>>> b.link = 10 - a
>>> a.val
2.0
>>> b.val
8.0
max

The maximum value of the parameter.

The maximum must lie between the hard_min and hard_max limits.

See also

min, val

min

The minimum value of the parameter.

The minimum must lie between the hard_min and hard_max limits.

See also

max, val

val

The current value of the parameter.

If the parameter is a link then it is possible that accessing the value will raise a ParameterErr in cases where the link expression falls outside the soft limits of the parameter.

See also

default_val, link, max, min

Methods Documentation

freeze() None [edit on github]

Set the frozen attribute for the parameter.

See also

thaw

reset() None [edit on github]

Reset the parameter value and limits to their default values.

set(val: SupportsFloat | None = None, min: SupportsFloat | None = None, max: SupportsFloat | None = None, frozen: bool | None = None, default_val: SupportsFloat | None = None, default_min: SupportsFloat | None = None, default_max: SupportsFloat | None = None) None [edit on github]

Change a parameter setting.

Parameters:
  • val (number or None, optional) – The new parameter value.

  • min (number or None, optional) – The new parameter range.

  • max (number or None, optional) – The new parameter range.

  • frozen (bool or None, optional) – Should the frozen flag be set?

  • default_val (number or None, optional) – The new default parameter value.

  • default_min (number or None, optional) – The new default parameter limits.

  • default_max (number or None, optional) – The new default parameter limits.

thaw() None [edit on github]

Unset the frozen attribute for the parameter.

Raises:

ParameterErr – The parameter is marked as always frozen.

See also

frozen

Remove any link to other parameters.