Datasets

class gammapy.datasets.Datasets(datasets=None)[source]

Bases: collections.abc.MutableSequence

Dataset collection.

Parameters
datasetsDataset or list of Dataset

Datasets

Attributes Summary

energy_axes_are_aligned

Whether all contained datasets have aligned energy axis

energy_ranges

Get global energy range of datasets.

gti

GTI table

is_all_same_energy_shape

Whether all contained datasets have the same data shape

is_all_same_shape

Whether all contained datasets have the same data shape

is_all_same_type

Whether all contained datasets are of the same type

meta_table

Meta table

models

Unique models (Models).

names

parameters

Unique parameters (Parameters).

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

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

Raises ValueError if the value is not present.

info_table([cumulative, region])

Get info table for datasets.

insert(idx, dataset)

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

pop([index])

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

read(path[, filedata, filemodel, lazy, cache])

De-serialize datasets from YAML and FITS files.

remove(value)

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

reverse()

S.reverse() – reverse IN PLACE

select_time(t_min, t_max[, atol])

Select datasets in a given time interval.

slice_energy(e_min, e_max)

Select and slice datasets in energy range

stack_reduce([name])

Reduce the Datasets to a unique Dataset by stacking them together.

stat_sum()

Compute joint likelihood

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

Serialize datasets to YAML and FITS files.

Attributes Documentation

energy_axes_are_aligned

Whether all contained datasets have aligned energy axis

energy_ranges

Get global energy range of datasets.

The energy range is derived as the minimum / maximum of the energy ranges of all datasets.

Returns
e_min, e_maxQuantity

Energy range.

gti

GTI table

is_all_same_energy_shape

Whether all contained datasets have the same data shape

is_all_same_shape

Whether all contained datasets have the same data shape

is_all_same_type

Whether all contained datasets are of the same type

meta_table

Meta table

models

Unique models (Models).

Duplicate model objects have been removed. The order of the unique models remains.

names
parameters

Unique parameters (Parameters).

Duplicate parameter objects have been removed. The order of the unique parameters remains.

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

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.

info_table(cumulative=False, region=None)[source]

Get info table for datasets.

Parameters
cumulativebool

Cumulate info across all observations

Returns
info_tableTable

Info table.

insert(idx, dataset)[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(path, filedata='_datasets.yaml', filemodel='_models.yaml', lazy=True, cache=True)[source]

De-serialize datasets from YAML and FITS files.

Parameters
pathstr, Path

Base directory of the datasets files.

filedatastr

file path or name of yaml datasets file

filemodelstr

file path or name of yaml models file

lazybool

Whether to lazy load data into memory

cachebool

Whether to cache the data after loading.

Returns
datasetgammapy.datasets.Datasets

Datasets

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_time(t_min, t_max, atol='1e-6 s')[source]

Select datasets in a given time interval.

Parameters
t_min, t_maxTime

Time interval

atolQuantity

Tolerance value for time comparison with different scale. Default 1e-6 sec.

Returns
datasetsDatasets

Datasets in the given time interval.

slice_energy(e_min, e_max)[source]

Select and slice datasets in energy range

Parameters
e_min, e_maxQuantity

Energy bounds to compute the flux point for.

Returns
datasetsDatasets

Datasets

stack_reduce(name=None)[source]

Reduce the Datasets to a unique Dataset by stacking them together.

This works only if all Dataset are of the same type and if a proper in-place stack method exists for the Dataset type.

Returns
dataset~gammapy.utils.Dataset

the stacked dataset

stat_sum()[source]

Compute joint likelihood

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

Serialize datasets to YAML and FITS files.

Parameters
pathpathlib.Path

path to write files

prefixstr

common prefix of file names

overwritebool

overwrite datasets FITS files

write_covariancebool

save covariance or not