Commit 916b3f680ff4ed98c0178ced805c43889dfdd052

Authored by sohm
1 parent e772d660

First version of high-level plotting script: plotutils.py for skymaps. This scri…

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