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.
\[ \begin{align}\begin{aligned}\begin{split}\epsilon_{jk} =\left\{\begin{array}{cl} 1, & \mbox{if bin k is inside the energy thresholds}\\ 0, & \mbox{otherwise} \end{array}\right.\end{split}\\\overline{\mathrm{n_{on}}}_k = \sum_{j} \mathrm{n_{on}}_{jk} \cdot \epsilon_{jk}\\\overline{\mathrm{n_{off}}}_k = \sum_{j} \mathrm{n_{off}}_{jk} \cdot \epsilon_{jk}\\\overline{\alpha}_k = \frac{\overline{{b_{on}}}_k}{\overline{{b_{off}}}_k}\\\overline{{b}_{on}}_k = 1\\\overline{{b}_{off}}_k = \frac{1}{\sum_{j}\alpha_{jk} \cdot \mathrm{n_{off}}_{jk} \cdot \epsilon_{jk}} \cdot \overline{\mathrm {n_{off}}}\end{aligned}\end{align} \]Please 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_DATA/joint-crab/spectra/hess') >>> 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
- obs_list :