SpectrumSimulation¶
-
class
gammapy.spectrum.SpectrumSimulation(livetime, source_model, aeff, edisp=None, background_model=None, alpha=None)[source]¶ Bases:
objectSimulate
SpectrumObservation.For a usage example see spectrum_simulation.ipynb
Parameters: livetime :
QuantityLivetime
source_model :
SpectralModelSource model
aeff :
EffectiveAreaTableEffective Area
edisp :
EnergyDispersion, optionalEnergy Dispersion
background_model :
SpectralModel, optionalBackground model
alpha : float, optional
Exposure ratio between source and background
Attributes Summary
e_recoReconstruced energy binning npred_backgroundPredicted background CountsSpectrumnpred_sourcePredicted source CountsSpectrumMethods Summary
reset()Clear all results run(seed)Simulate SpectrumObservationListsimulate_background_counts(rand)Simulate background PHACountsSpectrumsimulate_obs(obs_id[, seed])Simulate one SpectrumObservation.simulate_source_counts(rand)Simulate source PHACountsSpectrumAttributes Documentation
-
e_reco¶ Reconstruced energy binning
-
npred_background¶ Predicted background
CountsSpectrumcalls
gammapy.spectrum.utils.CountsPredictor()
-
npred_source¶ Predicted source
CountsSpectrumcalls
gammapy.spectrum.utils.CountsPredictor()
Methods Documentation
-
run(seed)[source]¶ Simulate
SpectrumObservationListThe 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(rand)[source]¶ Simulate background
PHACountsSpectrumBackground 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: `~numpy.random.RandomState`
random state
-
simulate_obs(obs_id, seed='random-seed')[source]¶ Simulate one
SpectrumObservation.The result is stored as
obsattributeParameters: obs_id : int
Observation identifier
seed : {int, ‘random-seed’, ‘global-rng’,
RandomState}see :func:~`gammapy.utils.random.get_random_state`
-
simulate_source_counts(rand)[source]¶ Simulate source
PHACountsSpectrumSource counts are added to the on vector.
Parameters: rand: `~numpy.random.RandomState`
random state
-