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', is_norm=False)#
Bases:
objectA 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,quantityorminandmaxproperties and consider the fact that there is afactor`andscalean 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_minandfactor_maxproperties, i.e. the optimiser “sees” the well-scaled problem.- Parameters
- namestr
Name
- valuefloat or
Quantity Value
- scalefloat, optional
Scale (sometimes used in fitting)
- unit
Unitor 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 of the scan keywords before.
- scale_method{‘scale10’, ‘factor1’, None}
Method used to set
factorandscale- interp{“lin”, “sqrt”, “log”}
Parameter scaling to use for the scan.
- is_normbool
Whether the parameter represents the flux norm of the model.
Attributes Summary
conf_maxConfidence max value (
float)conf_minConfidence min value (
float)errorfactorFactor (float).
factor_maxFactor max (float).
factor_minFactor min (float).
frozenFrozen? (used in fitting) (bool).
is_normWhether the parameter represents the norm of the model
maxMaximum (float).
minMinimum (float).
nameName (str).
quantityValue times unit (
Quantity).scaleScale (float).
scale_methodMethod used to set
factorandscalescan_maxStat scan max
scan_minStat scan min
scan_n_sigmaStat scan n sigma
scan_valuesStat scan values (
ndarray)typeunitUnit (
Unit).valueValue = factor x scale (float).
Methods Summary
autoscale()Autoscale the parameters.
check_limits()Emit a warning or error if value is outside the min/max range
copy()A deep copy
to_dict()Convert to dict.
update_from_dict(data)Update parameters from a dict.
Attributes Documentation
Methods Documentation
- copy()#
Generic (shallow and deep) copying operations.
Interface summary:
import copy
x = copy.copy(y) # make a shallow copy of y x = copy.deepcopy(y) # make a deep copy of y
For module specific errors, copy.Error is raised.
The difference between shallow and deep copying is only relevant for compound objects (objects that contain other objects, like lists or class instances).
A shallow copy constructs a new compound object and then (to the extent possible) inserts the same objects into it that the original contains.
A deep copy constructs a new compound object and then, recursively, inserts copies into it of the objects found in the original.
Two problems often exist with deep copy operations that don’t exist with shallow copy operations:
recursive objects (compound objects that, directly or indirectly, contain a reference to themselves) may cause a recursive loop
because deep copy copies everything it may copy too much, e.g. administrative data structures that should be shared even between copies
Python’s deep copy operation avoids these problems by:
keeping a table of objects already copied during the current copying pass
letting user-defined classes override the copying operation or the set of components copied
This version does not copy types like module, class, function, method, nor stack trace, stack frame, nor file, socket, window, nor array, nor any similar types.
Classes can use the same interfaces to control copying that they use to control pickling: they can define methods called __getinitargs__(), __getstate__() and __setstate__(). See the documentation for module “pickle” for information on these methods.