SpectrumDataset

class gammapy.spectrum.SpectrumDataset(model=None, counts=None, livetime=None, mask_fit=None, aeff=None, edisp=None, background=None, mask_safe=None)[source]

Bases: gammapy.utils.fitting.Dataset

Compute spectral model fit statistic on a CountsSpectrum.

Parameters:
model : SpectralModel

Fit model

counts : CountsSpectrum

Counts spectrum

livetime : float

Livetime

mask_fit : ndarray

Mask to apply to the likelihood for fitting.

aeff : EffectiveAreaTable

Effective area

edisp : EnergyDispersion

Energy dispersion

background : CountsSpectrum

Background to use for the fit.

mask_safe : ndarray

Mask defining the safe data range.

Attributes Summary

data_shape Shape of the counts data
energy_range Energy range defined by the safe mask
mask Combined fit and safe mask
model
parameters

Methods Summary

copy(self) A deep copy.
fake(self[, random_state]) Simulate a fake CountsSpectrum.
likelihood(self) Total likelihood given the current model parameters.
likelihood_per_bin(self) Likelihood per bin given the current model parameters
npred(self) Returns npred map (model + background)

Attributes Documentation

data_shape

Shape of the counts data

energy_range

Energy range defined by the safe mask

mask

Combined fit and safe mask

model
parameters

Methods Documentation

copy(self)

A deep copy.

fake(self, random_state='random-seed')[source]

Simulate a fake CountsSpectrum.

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

Defines random number generator initialisation. Passed to get_random_state.

Returns:
spectrum : CountsSpectrum

the fake count spectrum

likelihood(self)

Total likelihood given the current model parameters.

likelihood_per_bin(self)[source]

Likelihood per bin given the current model parameters

npred(self)[source]

Returns npred map (model + background)