Datasets#
- class gammapy.datasets.Datasets(datasets=None)[source]#
Bases:
MutableSequence
Container class that holds a list of datasets.
Attributes Summary
Stat contributions.
Whether all contained datasets have aligned energy axis.
Get global energy range of datasets.
GTI table.
Whether all contained datasets have the same data shape.
Whether all contained datasets have the same data shape.
Whether all contained datasets are of the same type.
Meta table.
Unique models (
Models
).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])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
(filename[, filename_models, lazy, ...])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
(time_min, time_max[, atol])Select datasets in a given time interval.
slice_by_energy
(energy_min, energy_max)Select and slice datasets in energy range.
stack_reduce
([name, nan_to_num])Reduce the Datasets to a unique Dataset by stacking them together.
stat_sum
()Compute joint statistic function value.
to_spectrum_datasets
(region)Extract spectrum datasets for the given region.
write
(filename[, filename_models, ...])Serialize datasets to YAML and FITS files.
Attributes Documentation
- contributes_to_stat#
Stat contributions.
- Returns:
- contributions
array
Array indicating which dataset contributes to the likelihood.
- contributions
- 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:
- energy_min, energy_max
Quantity
Energy range.
- energy_min, energy_max
- 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 #
- 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)[source]#
Get info table for datasets.
- Parameters:
- cumulativebool
Cumulate information across all datasets. If True, all model-dependent information will be lost. Default is False.
- Returns:
- info_table
Table
Info table.
- info_table
- 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, filename_models=None, lazy=True, cache=True, checksum=True)[source]#
De-serialize datasets from YAML and FITS files.
- Parameters:
- filenamestr or
Path
File path or name of datasets yaml file.
- filename_modelsstr or
Path
, optional File path or name of models yaml file. Default is None.
- lazybool
Whether to lazy load data into memory. Default is True.
- cachebool
Whether to cache the data after loading. Default is True.
- checksumbool
Whether to perform checksum verification. Default is False.
- filenamestr or
- Returns:
- dataset
gammapy.datasets.Datasets
Datasets.
- dataset
- remove(value)#
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reverse()#
S.reverse() – reverse IN PLACE
- slice_by_energy(energy_min, energy_max)[source]#
Select and slice datasets in energy range.
The method keeps the current dataset names. Datasets that do not contribute to the selected energy range are dismissed.
- Parameters:
- energy_min, energy_max
Quantity
Energy bounds to compute the flux point for.
- energy_min, energy_max
- Returns:
- datasetsDatasets
Datasets.
- stack_reduce(name=None, nan_to_num=True)[source]#
Reduce the Datasets to a unique Dataset by stacking them together.
This works only if all datasets are of the same type and with aligned geometries, and if a proper in-place stack method exists for the Dataset type.
For details, see Stacking Multiple Datasets.
- Parameters:
- namestr, optional
Name of the stacked dataset. Default is None.
- nan_to_numbool
Non-finite values are replaced by zero if True. Default is True.
- Returns:
- dataset
Dataset
The stacked dataset.
- dataset
- to_spectrum_datasets(region)[source]#
Extract spectrum datasets for the given region.
To get more detailed information, see the corresponding function associated to each dataset type:
to_spectrum_dataset
orto_spectrum_dataset
.- Parameters:
- region
SkyRegion
Region definition.
- region
- Returns:
- datasets
Datasets
List of
SpectrumDataset
.
- datasets
- write(filename, filename_models=None, overwrite=False, write_covariance=True, checksum=False)[source]#
Serialize datasets to YAML and FITS files.
- Parameters:
- filenamestr or
Path
File path or name of datasets yaml file.
- filename_modelsstr or
Path
, optional File path or name of models yaml file. Default is None.
- overwritebool, optional
Overwrite existing file. Default is False.
- write_covariancebool
save covariance or not. Default is False.
- checksumbool
When True adds both DATASUM and CHECKSUM cards to the headers written to the FITS files. Default is False.
- filenamestr or