Changeset 27
- Timestamp:
- May 20, 2014 3:20:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/templates/skymodelplane.html
r17 r27 4 4 <% 5 5 import matplotlib.pyplot as plt 6 import numpy as np 6 7 import os.path 8 import string 9 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 7 24 8 25 plt.figure() 9 26 10 27 iwn = context['iwn'] 11 sky_image = context['data']['skygenerator']['sky model'][:,:,iwn] 12 spatial_axis = context['data']['skygenerator']['spatial axis'] 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'] 13 34 14 plt.imshow(sky_image, interpolation='nearest', origin='lower', 35 plt.subplot(211) 36 plt.imshow(sky_image.real, interpolation='nearest', origin='lower', 15 37 aspect='equal', extent=[spatial_axis[0], spatial_axis[-1], 16 spatial_axis[0], spatial_axis[-1]]) 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') 43 plt.title('Sky model real %6.4gcm-1' % wn) 18 44 19 wn = context['wn'] 20 plt.title('Sky model plane %6.4gcm-1' % wn) 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) 21 54 22 plt.colorbar(orientation='vertical') 23 plt.savefig(os.path.join(context['dirname'], 'skymodelplane%s.png' % wn)) 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) 24 60 plt.close() 25 61 %> … … 27 63 <!-- link to the plot from html --> 28 64 29 <img src=' skymodelplane${wn}.png' alt="The sky model should appear here<br>">65 <img src='${os.path.basename(filename)}' alt="The sky model should appear here<br>">
Note:
See TracChangeset
for help on using the changeset viewer.