Parameters

class gammapy.modeling.Parameters(parameters=None)[source]

Bases: collections.abc.Sequence

Parameters container.

  • List of Parameter objects.

  • Covariance matrix.

Parameters
parameterslist of Parameter

List of parameters

Attributes Summary

free_parameters

List of free parameters

names

List of parameter names

restore_values

Context manager to restore values.

unique_parameters

Unique parameters (Parameters).

values

Parameter values (numpy.ndarray).

Methods Summary

autoscale(self[, method])

Autoscale all parameters.

copy(self)

A deep copy

count(self, value)

freeze_all(self)

Freeze all parameters

from_dict(data)

from_stack(parameters_list)

Create Parameters by stacking a list of other Parameters objects.

index(self, val)

Get position index for a given parameter.

set_parameter_factors(self, factors)

Set factor of all parameters.

to_dict(self)

to_table(self)

Convert parameter attributes to Table.

Attributes Documentation

free_parameters

List of free parameters

names

List of parameter names

restore_values

Context manager to restore values.

A copy of the values is made on enter, and those values are restored on exit.

Examples

from gammapy.modeling.models import PowerLawSpectralModel
pwl = PowerLawSpectralModel(index=2)
with pwl.parameters.restore_values:
    pwl.parameters["index"].value = 3
print(pwl.parameters["index"].value)
unique_parameters

Unique parameters (Parameters).

values

Parameter values (numpy.ndarray).

Methods Documentation

autoscale(self, method='scale10')[source]

Autoscale all parameters.

See autoscale()

Parameters
method{‘factor1’, ‘scale10’}

Method to apply

copy(self)[source]

A deep copy

count(self, value)
freeze_all(self)[source]

Freeze all parameters

classmethod from_dict(data)[source]
classmethod from_stack(parameters_list)[source]

Create Parameters by stacking a list of other Parameters objects.

Parameters
parameters_listlist of Parameters

List of Parameters objects

index(self, 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.

set_parameter_factors(self, factors)[source]

Set factor of all parameters.

Used in the optimizer interface.

to_dict(self)[source]
to_table(self)[source]

Convert parameter attributes to Table.