ModelBase#

class gammapy.modeling.models.ModelBase[source]#

Bases: object

Model base class.

Attributes Summary

covariance

frozen

Frozen status of a model, True if all parameters are frozen.

parameters

Parameters as a Parameters object.

parameters_unique_names

type

Methods Summary

copy(**kwargs)

Deep copy.

freeze()

Freeze all parameters.

from_dict(data, **kwargs)

from_parameters(parameters, **kwargs)

Create model from parameter list.

reassign(datasets_names, new_datasets_names)

Reassign a model from one dataset to another.

sample_parameters_from_covariance([...])

Create parameters samples from covariance using multivariate normal distribution.

to_dict([full_output])

Create dictionary for YAML serialisation.

unfreeze()

Restore parameters frozen status to default.

Attributes Documentation

covariance#
frozen#

Frozen status of a model, True if all parameters are frozen.

parameters#

Parameters as a Parameters object.

parameters_unique_names#
type#

Methods Documentation

copy(**kwargs)[source]#

Deep copy.

freeze()[source]#

Freeze all parameters.

classmethod from_dict(data, **kwargs)[source]#
classmethod from_parameters(parameters, **kwargs)[source]#

Create model from parameter list.

Parameters:
parametersParameters

Parameters for init.

**kwargsdict

Keyword arguments to overwrite the model class constructor.

Returns:
modelModel

Model instance.

reassign(datasets_names, new_datasets_names)[source]#

Reassign a model from one dataset to another.

Parameters:
datasets_namesstr or list

Name of the datasets where the model is currently defined.

new_datasets_namesstr or list

Name of the datasets where the model should be defined instead. If multiple names are given the two list must have the save length, as the reassignment is element-wise.

Returns:
modelModel

Reassigned model.

sample_parameters_from_covariance(n_samples=1000, random_state=42, free_only=True)#

Create parameters samples from covariance using multivariate normal distribution.

Parameters:
n_samplesint, optional

Number of samples to generate. Default is 1000.

random_state{int, ‘random-seed’, ‘global-rng’, RandomState}, optional

Defines random number generator initialisation. Passed to get_random_state. Default is 42.

free_onlybool, optional

If True, sample only free parameters (default).

Returns:
param_samplesnp.array

Array of parameters samples

to_dict(full_output=False)[source]#

Create dictionary for YAML serialisation.

unfreeze()[source]#

Restore parameters frozen status to default.

__init__(**kwargs)[source]#
classmethod __new__(*args, **kwargs)#