/
plot_bgcube.py
29 lines (24 loc) · 1.09 KB
/
plot_bgcube.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
from astropy.units import Quantity
from astropy.coordinates import Angle
from gammapy.background import Cube
from gammapy.datasets import gammapy_extra
filename = gammapy_extra.filename('test_datasets/background/bg_cube_model_test1.fits')
bg_cube_model = Cube.read(filename, format='table', scheme='bg_cube', hdu='BACKGROUND')
fig, axes = plt.subplots(nrows=1, ncols=3)
fig.set_size_inches(16, 5., forward=True)
# plot images
bg_cube_model.plot_image(energy=Quantity(0.5, 'TeV'), ax=axes[0],
style_kwargs=dict(norm=LogNorm()))
bg_cube_model.plot_image(energy=Quantity(50., 'TeV'), ax=axes[1],
style_kwargs=dict(norm=LogNorm()))
# plot spectra
bg_cube_model.plot_spectrum(coord=Angle([0., 0.], 'degree'), ax=axes[2],
style_kwargs=dict(label='(0, 0) deg'))
bg_cube_model.plot_spectrum(coord=Angle([2., 2.], 'degree'), ax=axes[2],
style_kwargs=dict(label='(2, 2) deg'))
axes[2].set_title('')
axes[2].legend()
plt.tight_layout()
plt.show()