#
# Next we're going to look at the overall source statistics in our signal region. For more info about what debug plots you can create check out the [ObservationSummary](https://docs.gammapy.org/0.10/api/gammapy.data.ObservationSummary.html#gammapy.data.ObservationSummary) class.

# In[ ]:

stats = []
for obs, bkg in zip(observations, background_estimator.result):
    stats.append(ObservationStats.from_observation(obs, bkg))

print(stats[1])

obs_summary = ObservationSummary(stats)
fig = plt.figure(figsize=(10, 6))
ax1 = fig.add_subplot(121)

obs_summary.plot_excess_vs_livetime(ax=ax1)
ax2 = fig.add_subplot(122)
obs_summary.plot_significance_vs_livetime(ax=ax2)

# ## Extract spectrum
#
# Now, we're going to extract a spectrum using the [SpectrumExtraction](https://docs.gammapy.org/0.10/api/gammapy.spectrum.SpectrumExtraction.html) class. We provide the reconstructed energy binning we want to use. It is expected to be a Quantity with unit energy, i.e. an array with an energy unit. We use a utility function to create it. We also provide the true energy binning to use.

# In[ ]:

e_reco = EnergyBounds.equal_log_spacing(0.1, 40, 40, unit="TeV")
e_true = EnergyBounds.equal_log_spacing(0.05, 100.0, 200, unit="TeV")

# Instantiate a [SpectrumExtraction](https://docs.gammapy.org/0.10/api/gammapy.spectrum.SpectrumExtraction.html) object that will do the extraction. The containment_correction parameter is there to allow for PSF leakage correction if one is working with full enclosure IRFs. We also compute a threshold energy and store the result in OGIP compliant files (pha, rmf, arf). This last step might be omitted though.

# In[ ]:
Beispiel #2
0
bkg_estimator.plot()

# we’re going to look at the overall source statistics in our signal region.

# In[40]:

from gammapy.data import ObservationStats, ObservationSummary
stats = []
for obs, bkg in zip(obs_list, bkg_estimator.result):
    stats.append(ObservationStats.from_obs(obs, bkg))
print(stats[0], stats[1], stats[2])

# In[41]:

obs_summary = ObservationSummary(stats)
obs_summary.plot_excess_vs_livetime()

# In[42]:

obs_summary.plot_significance_vs_livetime()

# Now, we’re going to extract a spectrum using the SpectrumExtraction class.
# Thus, we instantiate a SpectrumExtraction object that will do the extraction.

# In[43]:

extract = SpectrumExtraction(
    obs_list=obs_list,
    bkg_estimate=bkg_estimate,
)