SpectrumSimulation¶
-
class
gammapy.spectrum.
SpectrumSimulation
(livetime, source_model, aeff=None, edisp=None, e_true=None, background_model=None, alpha=None)[source]¶ Bases:
object
Simulate
SpectrumObservation
.For a usage example see spectrum_simulation.html
Parameters: - livetime :
Quantity
Livetime
- source_model :
SpectralModel
Source model
- aeff :
EffectiveAreaTable
, optional Effective Area
- edisp :
EnergyDispersion
, optional Energy Dispersion
- e_true :
Quantity
, optional Desired energy axis of the prediced counts vector if no IRFs are given
- background_model :
SpectralModel
, optional Background model
- alpha : float, optional
Exposure ratio between source and background
Attributes Summary
e_reco
Reconstructed energy binning. npred_background
Predicted background ( CountsSpectrum
).npred_source
Predicted source CountsSpectrum
.Methods Summary
reset
(self)Clear all results. run
(self, seed)Simulate list of SpectrumDatasetOnOff
.simulate_background_counts
(self, rand)Simulate background PHACountsSpectrum
.simulate_obs
(self, obs_id[, seed])Simulate one SpectrumObservation
.simulate_source_counts
(self, rand)Simulate source PHACountsSpectrum
.Attributes Documentation
-
e_reco
¶ Reconstructed energy binning.
-
npred_background
¶ Predicted background (
CountsSpectrum
).Calls
gammapy.spectrum.utils.SpectrumEvaluator()
.
-
npred_source
¶ Predicted source
CountsSpectrum
.Calls
gammapy.spectrum.utils.SpectrumEvaluator()
.
Methods Documentation
-
run
(self, seed)[source]¶ Simulate list of
SpectrumDatasetOnOff
.The seeds will be set as observation ID. Previously produced results will be overwritten.
Parameters: - seed : array of ints
Random number generator seeds
-
simulate_background_counts
(self, rand)[source]¶ Simulate background
PHACountsSpectrum
.Background counts are added to the on vector. Furthermore background counts divided by alpha are added to the off vector.
TODO: At the moment the source IRFs are used. Make it possible to pass dedicated background IRFs.
Parameters: - rand :
RandomState
random state
- rand :
-
simulate_obs
(self, obs_id, seed='random-seed')[source]¶ Simulate one
SpectrumObservation
.The result is stored as
obs
attributeParameters: - obs_id : int
Observation identifier
- seed : {int, ‘random-seed’, ‘global-rng’,
RandomState
} see :func:~`gammapy.utils.random.get_random_state`
-
simulate_source_counts
(self, rand)[source]¶ Simulate source
PHACountsSpectrum
.Source counts are added to the on vector.
Parameters: - rand :
RandomState
random state
- rand :
- livetime :