[17] | 1 | <%inherit file="base.html"/>
|
---|
| 2 |
|
---|
| 3 | <!-- do the plotting -->
|
---|
| 4 | <%
|
---|
| 5 | import matplotlib.pyplot as plt
|
---|
[27] | 6 | import numpy as np
|
---|
[17] | 7 | import os.path
|
---|
[27] | 8 | import string
|
---|
[17] | 9 |
|
---|
[27] | 10 | _valid_chars = "_.%s%s" % (string.ascii_letters, string.digits)
|
---|
| 11 |
|
---|
| 12 | def _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 |
|
---|
| 20 | def sanitize(text):
|
---|
| 21 | filename = ''.join(_char_replacer(c) for c in text)
|
---|
| 22 | return filename
|
---|
| 23 |
|
---|
| 24 |
|
---|
[17] | 25 | plt.figure()
|
---|
| 26 |
|
---|
| 27 | iwn = context['iwn']
|
---|
[27] | 28 | stagename = context['stagename']
|
---|
| 29 | resultname = context['resultname']
|
---|
| 30 | print 'resultname', resultname
|
---|
| 31 | sky_image = context['data'][stagename][resultname][:,:,iwn]
|
---|
| 32 | spatial_axis = context['data'][stagename]['spatial axis']
|
---|
| 33 | wn = context['wn']
|
---|
[17] | 34 |
|
---|
[27] | 35 | plt.subplot(211)
|
---|
| 36 | plt.imshow(sky_image.real, interpolation='nearest', origin='lower',
|
---|
[17] | 37 | aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
|
---|
[27] | 38 | spatial_axis[0], spatial_axis[-1]],
|
---|
| 39 | vmax=np.max(sky_image.real)*1.1,
|
---|
| 40 | vmin=np.min(sky_image.real)*0.9)
|
---|
| 41 | plt.colorbar(orientation='vertical')
|
---|
[17] | 42 | plt.axis('image')
|
---|
[27] | 43 | plt.title('Sky model real %6.4gcm-1' % wn)
|
---|
[17] | 44 |
|
---|
[27] | 45 | plt.subplot(212)
|
---|
| 46 | plt.imshow(sky_image.imag, interpolation='nearest', origin='lower',
|
---|
| 47 | aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
|
---|
| 48 | spatial_axis[0], spatial_axis[-1]],
|
---|
| 49 | vmax=np.max(sky_image.imag)*1.1,
|
---|
| 50 | vmin=np.min(sky_image.imag)*0.9)
|
---|
| 51 | plt.colorbar(orientation='vertical')
|
---|
| 52 | plt.axis('image')
|
---|
| 53 | plt.title('Sky model imag %6.4gcm-1' % wn)
|
---|
[17] | 54 |
|
---|
[27] | 55 | filename = '%splane%s.png' % (resultname, wn)
|
---|
| 56 | filename = sanitize(filename)
|
---|
| 57 | filename = os.path.join(context['dirname'], filename)
|
---|
| 58 | print 'filename', filename
|
---|
| 59 | plt.savefig(filename)
|
---|
[17] | 60 | plt.close()
|
---|
| 61 | %>
|
---|
| 62 |
|
---|
| 63 | <!-- link to the plot from html -->
|
---|
| 64 |
|
---|
[27] | 65 | <img src='${os.path.basename(filename)}' alt="The sky model should appear here<br>">
|
---|