Models

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

Bases: collections.abc.MutableSequence

Sky model collection.

Parameters
modelsSkyModel, list of SkyModel or Models

Sky models

Attributes Summary

covariance

names

parameters

parameters_unique_names

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

to_dict()

Convert to dict.

to_yaml()

Convert to YAML string.

write(path[, overwrite, write_covariance])

Write to YAML file.

write_covariance(filename, **kwargs)

Write covariance to file

Attributes Documentation

covariance
names
parameters
parameters_unique_names

Methods Documentation

append(value)

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

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

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='')[source]

Create from dict.

classmethod from_yaml(yaml_str, path='')[source]

Create from YAML string.

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

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)[source]

Read from YAML file.

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

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

to_dict()[source]

Convert to dict.

to_yaml()[source]

Convert to YAML string.

write(path, overwrite=False, write_covariance=True)[source]

Write to YAML file.

Parameters
pathpathlib.Path

path to write files

overwritebool

overwrite files

write_covariancebool

save covariance or not

write_covariance(filename, **kwargs)[source]

Write covariance to file

Parameters
filenamestr

Filename

**kwargsdict

Keyword arguments passed to write