[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']
|
---|
[47] | 30 |
|
---|
[27] | 31 | sky_image = context['data'][stagename][resultname][:,:,iwn]
|
---|
| 32 | spatial_axis = context['data'][stagename]['spatial axis']
|
---|
| 33 | wn = context['wn']
|
---|
[17] | 34 |
|
---|
[47] | 35 | if sky_image.dtype==np.complex:
|
---|
| 36 | plt.subplot(211)
|
---|
| 37 | plt.imshow(sky_image.real, interpolation='nearest', origin='lower',
|
---|
| 38 | aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
|
---|
| 39 | spatial_axis[0], spatial_axis[-1]])
|
---|
| 40 | # vmax=np.max(sky_image.real)*1.1,
|
---|
| 41 | # vmin=np.min(sky_image.real)*0.9)
|
---|
| 42 | plt.colorbar(orientation='vertical')
|
---|
| 43 | plt.axis('image')
|
---|
| 44 | plt.title('Sky model real %6.4gcm-1' % wn)
|
---|
[17] | 45 |
|
---|
[47] | 46 | plt.subplot(212)
|
---|
| 47 | plt.imshow(sky_image.imag, interpolation='nearest', origin='lower',
|
---|
| 48 | aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
|
---|
| 49 | spatial_axis[0], spatial_axis[-1]])
|
---|
| 50 | # vmax=np.max(sky_image.imag)*1.1,
|
---|
| 51 | # vmin=np.min(sky_image.imag)*0.9)
|
---|
| 52 | plt.colorbar(orientation='vertical')
|
---|
| 53 | plt.axis('image')
|
---|
| 54 | plt.title('Sky model imag %6.4gcm-1' % wn)
|
---|
[17] | 55 |
|
---|
[47] | 56 | else:
|
---|
| 57 | plt.imshow(sky_image, interpolation='nearest', origin='lower',
|
---|
| 58 | aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
|
---|
| 59 | spatial_axis[0], spatial_axis[-1]])
|
---|
| 60 | # vmax=np.max(sky_image)*1.1,
|
---|
| 61 | # vmin=np.min(sky_image)*0.9)
|
---|
| 62 | plt.colorbar(orientation='vertical')
|
---|
| 63 | plt.axis('image')
|
---|
| 64 | plt.title('Sky model real %6.4gcm-1' % wn)
|
---|
| 65 |
|
---|
[27] | 66 | filename = '%splane%s.png' % (resultname, wn)
|
---|
| 67 | filename = sanitize(filename)
|
---|
| 68 | filename = os.path.join(context['dirname'], filename)
|
---|
| 69 | plt.savefig(filename)
|
---|
[17] | 70 | plt.close()
|
---|
| 71 | %>
|
---|
| 72 |
|
---|
| 73 | <!-- link to the plot from html -->
|
---|
| 74 |
|
---|
[27] | 75 | <img src='${os.path.basename(filename)}' alt="The sky model should appear here<br>">
|
---|