plotutils.py
2.11 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# ==========================================================================
# This script provides a number of functions that are useful for handling
# CTA observations.
#
# Copyright (C) 2011-2014 Juergen Knoedlseder
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ==========================================================================
import ctools
import gammalib
try:
import matplotlib.pyplot as plt
has_matplotlib = True
except:
has_matplotlib = False
try:
import aplpy
has_aplpy = True
except:
has_aplpy = False
# ===================== #
# Plot skymaps #
# ===================== #
def plotskymaps(modelmap, countmap):
"""
Plot the model map
Keywords:
modname - model input name
evtname - events input name
"""
# load model map
fig = plt.figure()
f1 = aplpy.FITSFigure(countmap, figure=fig, subplot=[0.1,0.1,0.35,0.8])
f1.set_tick_labels_font(size='small')
f1.set_axis_labels_font(size='small')
f1.show_colorscale()
f1.tick_labels.set_yformat('dd:mm:ss')
f1.tick_labels.set_xformat('hh:mm:ss')
f1.axis_labels.set_xtext('Right Ascension (J2000)')
f1.axis_labels.set_ytext('Declination (J2000)')
f1.ticks.set_length(10.5, minor_factor=0.5)
f2 = aplpy.FITSFigure(modelmap, figure=fig, subplot=[0.5,0.1,0.35,0.8])
f2.set_tick_labels_font(size='small')
f2.set_axis_labels_font(size='small')
f2.show_colorscale()
f2.hide_yaxis_label()
f2.hide_ytick_labels()
fig.canvas.draw()
fig.show()