Note
You are not reading the most up to date version of Gammapy documentation.
Access the latest stable version v1.3 or the list of Gammapy releases.
SpectrumObservationStacker¶
-
class
gammapy.spectrum.
SpectrumObservationStacker
(obs_list)[source]¶ Bases:
object
Stack observations in a
SpectrumObservationList
.The stacking of j observations is implemented as follows. k and l denote a bin in reconstructed and true energy, respectively.
ϵjk={1,if bin k is inside the energy thresholds0,otherwise¯nonk=∑jnonjk⋅ϵjk¯noffk=∑jnoffjk⋅ϵjk¯αk=¯bonk¯boffk¯bonk=1¯boffk=1∑jαjk⋅noffjk⋅ϵjk⋅¯noffPlease refer to the
IRFStacker
for the description of how the IRFs are stacked.Parameters: obs_list :
SpectrumObservationList
Observations to stack
Examples
>>> from gammapy.spectrum import SpectrumObservationList, SpectrumObservationStacker >>> obs_list = SpectrumObservationList.read('$GAMMAPY_EXTRA/datasets/hess-crab4_pha') >>> obs_stacker = SpectrumObservationStacker(obs_list) >>> obs_stacker.run() >>> print(obs_stacker.stacked_obs) *** Observation summary report *** Observation Id: [23523-23592] Livetime: 0.879 h On events: 279 Off events: 108 Alpha: 0.037 Bkg events in On region: 3.96 Excess: 275.04 Excess / Background: 69.40 Gamma rate: 0.14 1 / min Bkg rate: 0.00 1 / min Sigma: 37.60 energy range: 681292069.06 keV - 87992254356.91 keV
Methods Summary
run
()Run all steps in the correct order. setup_counts_vectors
()Add correct attributes to stacked counts vectors. stack_aeff
()Stack effective areas (weighted by livetime). stack_backscal
()Stack backscal
for on and off vector.stack_counts_spectrum
(counts_spectrum_list)Stack PHACountsSpectrum
.stack_counts_vectors
()Stack on and off vectors. stack_edisp
()Stack energy dispersion (weighted by exposure). stack_obs
()Create stacked SpectrumObservation
stack_off_vector
()Stack the off count vector. stack_on_vector
()Stack the on count vector. Methods Documentation
-
static
stack_counts_spectrum
(counts_spectrum_list)[source]¶ Stack
PHACountsSpectrum
.- Bins outside the safe energy range are set to 0
- Attributes are set to None.
- The quality vector of the observations are combined with a logical or, such that the low (high) threshold of the stacked obs is the minimum low (maximum high) threshold of the observation list to be stacked.
-
stack_edisp
()[source]¶ Stack energy dispersion (weighted by exposure).
Calls
stack_edisp
-
stack_obs
()[source]¶ Create stacked
SpectrumObservation
-
static