Parameters#
- class gammapy.modeling.Parameters(parameters=None)[source]#
Bases:
SequenceParameters container.
List of
Parameterobjects.Covariance matrix.
- Parameters:
- parameterslist of
Parameter List of parameters.
- parameterslist of
Attributes Summary
List of free parameters.
Parameter maxima as a
numpy.ndarray.Parameter minima as a
numpy.ndarray.List of parameter names.
Parameter types.
Unique parameters as a
Parametersobject.Parameter values as a
numpy.ndarray.Methods Summary
Autoscale all parameters.
Check parameter limits and emit a warning.
copy()Deep copy.
count(value)Freeze all parameters.
from_dict(data)from_stack(parameters_list)Create
Parametersby stacking a list of otherParametersobjects.index(val)Get position index for a given parameter.
restore_status([restore_values])Context manager to restore status.
select([name, type, frozen])Create a mask of models, true if all conditions are verified.
set_parameter_factors(factors)Set factor of all parameters.
to_dict()to_table()Convert parameter attributes to
Table.Unfreeze all parameters (even those frozen by default).
Attributes Documentation
- free_parameters#
List of free parameters.
- max#
Parameter maxima as a
numpy.ndarray.
- min#
Parameter minima as a
numpy.ndarray.
- names#
List of parameter names.
- prior#
- types#
Parameter types.
- unique_parameters#
Unique parameters as a
Parametersobject.
- value#
Parameter values as a
numpy.ndarray.
Methods Documentation
- autoscale()[source]#
Autoscale all parameters.
See
autoscale().
- count(value) integer -- return number of occurrences of value#
- classmethod from_stack(parameters_list)[source]#
Create
Parametersby stacking a list of otherParametersobjects.- Parameters:
- parameters_listlist of
Parameters List of
Parametersobjects.
- parameters_listlist of
- index(val)[source]#
Get position index for a given parameter.
The input can be a parameter object, parameter name (str) or if a parameter index (int) is passed in, it is simply returned.
- restore_status(restore_values=True)[source]#
Context manager to restore status.
A copy of the values is made on enter, and those values are restored on exit.
- Parameters:
- restore_valuesbool, optional
Restore values if True, otherwise restore only frozen status. Default is None.
Examples
>>> from gammapy.modeling.models import PowerLawSpectralModel >>> pwl = PowerLawSpectralModel(index=2) >>> with pwl.parameters.restore_status(): ... pwl.parameters["index"].value = 3 >>> print(pwl.parameters["index"].value)
- select(name=None, type=None, frozen=None)[source]#
Create a mask of models, true if all conditions are verified.
- Parameters:
- namestr or list, optional
Name of the parameter. Default is None.
- type{None, “spatial”, “spectral”, “temporal”}
Type of models. Default is None.
- frozenbool, optional
Select frozen parameters if True, exclude them if False. Default is None.
- Returns:
- parameters
Parameters Selected parameters.
- parameters