source: trunk/templates/cleanimageplane.html

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

almost working

File size: 1.6 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']
29
30clean_image = context['data'][stagename]['cleanimage'][:,:,iwn]
31residual_image = context['data'][stagename]['residualimage'][:,:,iwn]
32spatial_axis = context['data'][stagename]['spatial axis']
33wn = context['wn']
34
35plt.subplot(121)
36plt.imshow(clean_image, interpolation='nearest', origin='lower',
37 aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
38 spatial_axis[0], spatial_axis[-1]])
39plt.colorbar(orientation='vertical')
40plt.axis('image')
41plt.title('Clean image %6.4gcm-1' % wn)
42
43plt.subplot(122)
44plt.imshow(residual_image, interpolation='nearest', origin='lower',
45 aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
46 spatial_axis[0], spatial_axis[-1]])
47plt.colorbar(orientation='vertical')
48plt.axis('image')
49plt.title('Residual image %6.4gcm-1' % wn)
50
51filename = '%splane%s.png' % (stagename, wn)
52filename = sanitize(filename)
53filename = os.path.join(context['dirname'], filename)
54plt.savefig(filename)
55plt.close()
56%>
57
58<!-- link to the plot from html -->
59
60<img src='${os.path.basename(filename)}' alt="The clean result should appear here<br>">
Note: See TracBrowser for help on using the repository browser.