source: trunk/templates/skymodelplane.html@ 36

Last change on this file since 36 was 36, checked in by JohnLightfoot, 10 years ago

debug statements removed

File size: 1.7 KB
Line 
1<%inherit file="base.html"/>
2
3<!-- do the plotting -->
4<%
5import matplotlib.pyplot as plt
6import numpy as np
7import os.path
8import string
9
10_valid_chars = "_.%s%s" % (string.ascii_letters, string.digits)
11
12def _char_replacer(s):
13 '''A small utility function that echoes the argument or returns '_' if the
14 argument is in a list of forbidden characters.
15 '''
16 if s not in _valid_chars:
17 return '_'
18 return s
19
20def sanitize(text):
21 filename = ''.join(_char_replacer(c) for c in text)
22 return filename
23
24
25plt.figure()
26
27iwn = context['iwn']
28stagename = context['stagename']
29resultname = context['resultname']
30sky_image = context['data'][stagename][resultname][:,:,iwn]
31spatial_axis = context['data'][stagename]['spatial axis']
32wn = context['wn']
33
34plt.subplot(211)
35plt.imshow(sky_image.real, interpolation='nearest', origin='lower',
36 aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
37 spatial_axis[0], spatial_axis[-1]],
38 vmax=np.max(sky_image.real)*1.1,
39 vmin=np.min(sky_image.real)*0.9)
40plt.colorbar(orientation='vertical')
41plt.axis('image')
42plt.title('Sky model real %6.4gcm-1' % wn)
43
44plt.subplot(212)
45plt.imshow(sky_image.imag, interpolation='nearest', origin='lower',
46 aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
47 spatial_axis[0], spatial_axis[-1]],
48 vmax=np.max(sky_image.imag)*1.1,
49 vmin=np.min(sky_image.imag)*0.9)
50plt.colorbar(orientation='vertical')
51plt.axis('image')
52plt.title('Sky model imag %6.4gcm-1' % wn)
53
54filename = '%splane%s.png' % (resultname, wn)
55filename = sanitize(filename)
56filename = os.path.join(context['dirname'], filename)
57plt.savefig(filename)
58plt.close()
59%>
60
61<!-- link to the plot from html -->
62
63<img src='${os.path.basename(filename)}' alt="The sky model should appear here<br>">
Note: See TracBrowser for help on using the repository browser.