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
, andhard_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
andmax
values as the _xspec_soft_min and _xspec_soft_max attributes and thehard_min
andhard_max
values as _xspec_hard_min and _xspec_hard_max attributes;sets the underlying
min
andmax
values to the XSPEC hard limits;and sets the underlying
hard_min
andhard_max
values to the XSPEC hard limits.
Note that you can not change the hard limits; for that see
XSParameter
.See also
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
Is the parameter always frozen?
The default value of the parameter.
Is the parameter currently frozen?
The hard maximum of the parameter.
The hard minimum of the parameter.
The link expression to other parameters, if set.
The maximum value of the parameter.
The minimum value of the parameter.
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
- frozen
Is the parameter currently frozen?
Those parameters created with
alwaysfrozen
set can not be changed.See also
- link
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
Examples
>>> a = Parameter("mdl", "a", 2) >>> b = Parameter("mdl", "b", 1) >>> b.link = 10 - a >>> print(a.val) 2.0 >>> print(b.val) 8.0
- max
The maximum value of the parameter.
The maximum must lie between the hard_min and hard_max limits.
- min
The minimum value of the parameter.
The minimum must lie between the hard_min and hard_max limits.
- 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
- 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
- unlink() None [edit on github]
Remove any link to other parameters.