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)[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 or min and max properties and consider the fact that there is a factor` and scale 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 and factor_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).

unitUnit or str, optional

Unit.

minfloat, optional

Minimum (sometimes used in fitting).

maxfloat, optional

Maximum (sometimes used in fitting).

frozenbool, optional

Frozen (used in fitting).

errorfloat

Parameter error.

scan_minfloat

Minimum value for the parameter scan. Overwrites scan_n_sigma.

scan_maxfloat

Minimum value for the parameter scan. Overwrites scan_n_sigma.

scan_n_values: int

Number of values to be used for the parameter scan.

scan_n_sigmaint

Number of sigmas to scan.

scan_values: `numpy.array`

Scan values. Overwrites all the scan keywords before.

scale_method{‘scale10’, ‘factor1’, None}

Method used to set factor and scale.

interp{“lin”, “sqrt”, “log”}

Parameter scaling to use for the scan.

priorPrior

Prior set on the parameter.

Attributes Summary

conf_max

Confidence maximum value as a float.

conf_min

Confidence minimum value as a float.

error

factor

Factor as a float.

factor_max

Factor maximum as a float.

factor_min

Factor minimum as a float.

frozen

Frozen (used in fitting) (bool).

max

Maximum as a float.

min

Minimum as a float.

name

Name as a string.

prior

Prior applied to the parameter as a Prior.

quantity

Value times unit as a Quantity.

scale

Scale as a float.

scale_method

Method used to set factor and scale.

scan_max

Stat scan maximum.

scan_min

Stat scan minimum.

scan_n_sigma

Stat scan n sigma.

scan_values

Stat scan values as a ndarray.

type

unit

Unit as a Unit object.

value

Value = factor x scale (float).

Methods Summary

autoscale()

Autoscale the parameters.

check_limits()

Emit a warning or error if value is outside the minimum/maximum range.

copy()

Deep copy.

prior_stat_sum()

to_dict()

Convert to dictionary.

update_from_dict(data)

Update parameters from a dictionary.

Attributes Documentation

conf_max#

Confidence maximum value as a float.

Return parameter maximum if defined, otherwise return the scan_max.

conf_min#

Confidence minimum value as a float.

Return parameter minimum if defined, otherwise return the scan_min.

error#
factor#

Factor as a float.

factor_max#

Factor maximum as a float.

This factor_max = max / scale is for the optimizer interface.

factor_min#

Factor minimum as a float.

This factor_min = min / scale is for the optimizer interface.

frozen#

Frozen (used in fitting) (bool).

max#

Maximum as a float.

min#

Minimum as a float.

name#

Name as a string.

prior#

Prior applied to the parameter as a Prior.

quantity#

Value times unit as a Quantity.

scale#

Scale as a float.

scale_method#

Method used to set factor and scale.

scan_max#

Stat scan maximum.

scan_min#

Stat scan minimum.

scan_n_sigma#

Stat scan n sigma.

scan_values#

Stat scan values as a ndarray.

type#
unit#

Unit as a Unit object.

value#

Value = factor x scale (float).

Methods Documentation

autoscale()[source]#

Autoscale the parameters.

Set factor and scale according to scale_method attribute.

Available scale_method.

  • scale10 sets scale to power of 10, so that abs(factor) is in the range 1 to 10

  • factor1 sets factor, scale = 1, value

In both cases the sign of value is stored in factor, i.e. the scale is always positive. If scale_method is None the scaling is ignored.

check_limits()[source]#

Emit a warning or error if value is outside the minimum/maximum range.

copy()[source]#

Deep copy.

prior_stat_sum()[source]#
to_dict()[source]#

Convert to dictionary.

update_from_dict(data)[source]#

Update parameters from a dictionary.