Parameter#
- class gammapy.modeling.Parameter(name, value, unit='', scale=1, min=nan, max=nan, frozen=False, error=0, scan_min=None, scan_max=None, scan_n_values=11, scan_n_sigma=2, scan_values=None, scale_method='scale10', interp='lin', prior=None, scale_transform='lin')[source]#
Bases:
object
A model parameter.
Note that the parameter value has been split into a factor and scale like this:
value = factor x scale
Users should interact with the
value
,quantity
ormin
andmax
properties and consider the fact that there is afactor
andscale
an implementation detail.That was introduced for numerical stability in parameter and error estimation methods, only in the Gammapy optimiser interface do we interact with the
factor
,factor_min
andfactor_max
properties, i.e. the optimiser “sees” the well-scaled problem.- Parameters:
- namestr
Name.
- valuefloat or
Quantity
Value.
- scalefloat, optional
Scale (sometimes used in fitting).
- unit
Unit
or str, optional Unit. Default is “”.
- minfloat, str or
quantity
, optional Minimum (sometimes used in fitting). If
None
, set tonumpy.nan
. Default is None.- maxfloat, str or
quantity
, optional Maximum (sometimes used in fitting). Default is
numpy.nan
.- frozenbool, optional
Frozen (used in fitting). Default is False.
- errorfloat, optional
Parameter error. Default is 0.
- scan_minfloat, optional
Minimum value for the parameter scan. Overwrites scan_n_sigma. Default is None.
- scan_maxfloat, optional
Maximum value for the parameter scan. Overwrites scan_n_sigma. Default is None.
- scan_n_values: int, optional
Number of values to be used for the parameter scan. Default is 11.
- scan_n_sigmaint, optional
Number of sigmas to scan. Default is 2.
- scan_values: `numpy.array`, optional
Scan values. Overwrites all the scan keywords before. Default is None.
- scale_method{‘scale10’, ‘factor1’, None}, optional
Method used to set
factor
andscale
. Default is “scale10”.- interp{“lin”, “sqrt”, “log”}, optional
Parameter scaling to use for the scan. Default is “lin”.
- prior
Prior
, optional Prior set on the parameter. Default is None.
Attributes Summary
Confidence maximum value as a
float
.Confidence minimum value as a
float
.Factor as a float.
Factor maximum as a float (used by the optimizer).
Factor minimum as a float (used by the optimizer).
Frozen (used in fitting) (bool).
Maximum as a float.
Minimum as a float.
Name as a string.
Prior applied to the parameter as a
Prior
.Value times unit as a
Quantity
.Scale as a float.
Method used to set
factor
andscale
.scale interp : {"lin", "sqrt", "log"}
Stat scan maximum.
Stat scan minimum.
Stat scan n sigma.
Stat scan values as a
numpy.ndarray
.Unit as a
Unit
object.Value = factor x scale (float).
Methods Summary
Apply
interpolation_scale
andscale_method
to the parameter.Emit a warning or error if value is outside the minimum/maximum range.
copy
()Deep copy.
inverse_transform
(factor)Inverse transform from factor (used by the optimizer) to value.
Reset scaling such as factor=value, scale=1.
set_lim
([min, max])Set the min and/or max value for the parameter.
to_dict
()Convert to dictionary.
transform
(value[, update_scale])Transform from value to factor (used by the optimizer).
update_from_dict
(data)Update parameters from a dictionary.
update_scale
(value)Update the parameter scale.
Attributes Documentation
- conf_max#
Confidence maximum value as a
float
. Return parameter maximum if defined, otherwise a default is estimated from value and error.
- conf_min#
Confidence minimum value as a
float
. Return parameter minimum if defined, otherwise a default is estimated from value and error.
- error#
- factor#
Factor as a float.
- factor_max#
Factor maximum as a float (used by the optimizer).
By default, when no transform is applied,
factor_max = max / scale
, otherwisefactor_max = transform(max)
.
- factor_min#
Factor minimum as a float (used by the optimizer).
By default, when no transform is applied,
factor_min = min / scale
, otherwisefactor_min = transform(min)
.
- frozen#
Frozen (used in fitting) (bool).
- max#
Maximum as a float.
- min#
Minimum as a float.
- name#
Name as a string.
- scale#
Scale as a float.
- scale_method#
Method used to set
factor
andscale
.
- scale_transform#
scale interp : {“lin”, “sqrt”, “log”}
- scan_max#
Stat scan maximum.
- scan_min#
Stat scan minimum.
- scan_n_sigma#
Stat scan n sigma.
- scan_values#
Stat scan values as a
numpy.ndarray
.
- type#
- value#
Value = factor x scale (float).
Methods Documentation
- autoscale()[source]#
Apply
interpolation_scale
andscale_method
to the parameter.
- inverse_transform(factor)[source]#
Inverse transform from factor (used by the optimizer) to value.
- Parameters:
- factorfloat
Parameter factor.
- transform(value, update_scale=False)[source]#
Transform from value to factor (used by the optimizer).
- Parameters:
- valuefloat
Parameter value.
- update_scalebool, optional
Update the scaling (used by the autoscale). Default is False.
- update_scale(value)[source]#
Update the parameter scale.
Set
factor
andscale
according toscale_method
attribute.Available
scale_method
.scale10
setsscale
to power of 10, so that abs(factor) is in the range 1 to 10factor1
setsfactor, scale = 1, value
In both cases the sign of value is stored in
factor
, i.e. thescale
is always positive. Ifscale_method
is None the scaling is ignored.