Models

class gammapy.modeling.models.Models(models=None)[source]

Bases: gammapy.modeling.models.core.DatasetModels, collections.abc.MutableSequence

Sky model collection.

Parameters
modelsSkyModel, list of SkyModel or Models

Sky models

Attributes Summary

covariance

names

parameters

parameters_unique_names

List of unique parameter names as model_name.par_type.par_name

Methods Summary

append(value)

S.append(value) – append value to the end of the sequence

clear()

copy()

A deep copy.

count(value)

extend(values)

S.extend(iterable) – extend sequence by appending elements from the iterable

from_dict(data[, path])

Create from dict.

from_yaml(yaml_str[, path])

Create from YAML string.

index(value, [start, [stop]])

Raises ValueError if the value is not present.

insert(idx, model)

S.insert(index, value) – insert value before index

pop([index])

Raise IndexError if list is empty or index is out of range.

read(filename)

Read from YAML file.

read_covariance(path[, filename])

Read covariance data from file

remove(value)

S.remove(value) – remove first occurrence of value.

reverse()

S.reverse() – reverse IN PLACE

select([dataset_name, tag, name_substring])

Select subset of models correspondiog to a given dataset

to_dict([full_output])

Convert to dict.

to_yaml([full_output])

Convert to YAML string.

write(path[, overwrite, full_output, …])

Write to YAML file.

write_covariance(filename, **kwargs)

Write covariance to file

Attributes Documentation

covariance
names
parameters
parameters_unique_names

List of unique parameter names as model_name.par_type.par_name

Methods Documentation

append(value)

S.append(value) – append value to the end of the sequence

clear() → None -- remove all items from S
copy()

A deep copy.

count(value) → integer -- return number of occurrences of value
extend(values)

S.extend(iterable) – extend sequence by appending elements from the iterable

classmethod from_dict(data, path='')

Create from dict.

classmethod from_yaml(yaml_str, path='')

Create from YAML string.

index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(idx, model)[source]

S.insert(index, value) – insert value before index

pop([index]) → item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

classmethod read(filename)

Read from YAML file.

read_covariance(path, filename='_covariance.dat', **kwargs)

Read covariance data from file

Parameters
filenamestr

Filename

**kwargsdict

Keyword arguments passed to read

remove(value)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

select(dataset_name=None, tag=None, name_substring=None)

Select subset of models correspondiog to a given dataset

Parameters
dataset_namestr

Name of the dataset

tagstr

Model tag

name_substringstr

Substring contained in the model name

Returns
dataset_modelDatasetModels

Dataset models

to_dict(full_output=False)

Convert to dict.

to_yaml(full_output=False)

Convert to YAML string.

write(path, overwrite=False, full_output=False, write_covariance=True)

Write to YAML file.

Parameters
pathpathlib.Path or str

path to write files

overwritebool

overwrite files

write_covariancebool

save covariance or not

write_covariance(filename, **kwargs)

Write covariance to file

Parameters
filenamestr

Filename

**kwargsdict

Keyword arguments passed to write