XSParameter
- class sherpa.astro.xspec.XSParameter(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:
XSBaseParameter
An XSPEC parameter where you exceed the hard limits.
This parameter allows a user to change the hard limits (
hard_min
andhard_max
). XSPEC allows the hard limits to be extended, and this is used in a few models to trigger different behavior (e.g. setting the value negative). Thehard_min_changed
andhard_max_changed
methods can be used to determine if the limits have been changed.See also
Notes
Some XSPEC parameter values are documented as changing behavior when the value is outside the XSPEC hard limits from the model.dat file (normally the hard minimum is 0 and setting the parameter negative changes the model in some way). XSPEC allows a user to change the hard limits so we do the same here.
Setting the hard limit will also change the corresponding soft limit.
Setting a value outside the original hard limits can cause models to fail or even crash the interpreter. These parameters should probably be frozen.
Examples
>>> p = XSParameter('mod', 'p', 2, min=1, max=9, hard_min=0, hard_max=10) >>> p.frozen False >>> 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 >>> p.max = 30 sherpa.utils.err.ParameterErr: parameter mod.p has a hard maximum of 10 >>> p.hard_max = 30 >>> p.max 30.0 >>> p.hard_max 30.0 >>> p.val = 20 >>> p.frozen False
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.Has the hard limit (max) been changed from it's default value?
Has the hard limit (min) been changed from it's default value?
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
- hard_max
The hard maximum of the parameter.
Unlike normal parameters the
hard_max
value can be changed (and will also change the correspondingmax
value at the same time). This is needed to support the small-number of XSPEC models that use a value outside the default hard range as a way to control the model. Unfortunately some models can crash when using values like this so take care.See also
- hard_min
The hard minimum of the parameter.
Unlike normal parameters the
hard_min
value can be changed (and will also change the correspondingmin
value at the same time). This is needed to support the small-number of XSPEC models that use a value outside the default hard range as a way to control the model. Unfortunately some models can crash when using values like this so take care.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 >>> 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.
- 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 ParamaterErr in cases where the link expression falls outside the soft limits of the parameter.
See also
default_val
,link
,max
,min
Methods Documentation
- freeze() [edit on github]
Set the
frozen
attribute for the parameter.See also
- hard_max_changed()[source] [edit on github]
Has the hard limit (max) been changed from it’s default value?
- hard_min_changed()[source] [edit on github]
Has the hard limit (min) been changed from it’s default value?
- reset() [edit on github]
Reset the parameter value and limits to their default values.
- set(val=None, min=None, max=None, frozen=None, default_val=None, default_min=None, default_max=None, hard_min=None, hard_max=None)[source] [edit on github]
Change a parameter setting.
The hard limits can be changed, which will also change the matching soft limit. Note that XSPEC models can cause a crash if sent an un-supported value so use this feature carefully; it is likely that these parameters should also be frozen but this is not enforced.
- 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.
hard_min (numer or None, optional) – Changing the hard limits will also change the matching soft limit (
min
ormax
).hard_max (numer or None, optional) – Changing the hard limits will also change the matching soft limit (
min
ormax
).
- thaw() [edit on github]
Unset the
frozen
attribute for the parameter.See also
- unlink() [edit on github]
Remove any link to other parameters.