source: trunk/templates/doublefourier.html@ 17

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

initial import

File size: 4.5 KB
Line 
1<%inherit file="base.html"/>
2
3<!-- do the plotting -->
4<%
5import matplotlib.pyplot as plt
6import os.path
7import string
8
9_valid_chars = "_.%s%s" % (string.ascii_letters, string.digits)
10def _char_replacer(s):
11 '''A small utility function that echoes the argument or returns '_' if the
12 argument is in a list of forbidden characters.
13 '''
14 if s not in _valid_chars:
15 return '_'
16 return s
17
18def sanitize(text):
19 filename = ''.join(_char_replacer(c) for c in text)
20 return filename
21
22
23frequency_axis = context['data']['doublefourier']['frequency axis']
24spatial_axis = context['data']['doublefourier']['spatial axis']
25spatial_freq_axis = context['data']['doublefourier']['spatial frequency axis']
26print 'spatial frequency axis', spatial_freq_axis
27
28#for i,wn in enumerate(frequency_axis):
29print 'frequency axis', frequency_axis
30for i,wn in enumerate(frequency_axis[:1]):
31 plt.figure()
32
33 sky_image = context['data']['doublefourier']['sky at time 0'][:,:,i]
34 plt.imshow(sky_image, interpolation='nearest', origin='lower',
35 aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
36 spatial_axis[0], spatial_axis[-1]])
37 plt.axis('image')
38
39 plt.colorbar(orientation='vertical')
40## plt.xlabel(beam_image.axes[0].title)
41## plt.ylabel(beam_image.axes[1].title)
42## plt.title(beam_image.title)
43
44## plt.grid()
45 plt.savefig(os.path.join(context['dirname'], 'dbsky1%s.png' % wn))
46 plt.close()
47
48
49#for i,wn in enumerate(frequency_axis):
50for i,wn in enumerate(frequency_axis[:1]):
51 plt.figure()
52
53 sky_image = context['data']['doublefourier']['sky*beams at time 0'][:,:,i]
54 plt.imshow(sky_image, interpolation='nearest', origin='lower',
55 aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
56 spatial_axis[0], spatial_axis[-1]])
57 plt.axis('image')
58
59 plt.colorbar(orientation='vertical')
60## plt.xlabel(beam_image.axes[0].title)
61## plt.ylabel(beam_image.axes[1].title)
62## plt.title(beam_image.title)
63
64## plt.grid()
65 plt.savefig(os.path.join(context['dirname'], 'dbskybeams1%s.png' % wn))
66 plt.close()
67
68#for i,wn in enumerate(frequency_axis):
69for i,wn in enumerate(frequency_axis[:1]):
70 plt.figure()
71
72 sky_image = context['data']['doublefourier']['skyfft at time 0'][:,:,i].real
73 plt.imshow(sky_image, interpolation='nearest', origin='lower',
74 aspect='equal', extent=[spatial_freq_axis[0], spatial_freq_axis[-1],
75 spatial_freq_axis[0], spatial_freq_axis[-1]])
76 plt.axis('image')
77
78 plt.colorbar(orientation='vertical')
79## plt.xlabel(beam_image.axes[0].title)
80## plt.ylabel(beam_image.axes[1].title)
81## plt.title(beam_image.title)
82
83## plt.grid()
84 plt.savefig(os.path.join(context['dirname'], 'skyfft%s.png' % wn))
85 plt.close()
86
87#for i,wn in enumerate(frequency_axis):
88for i,wn in enumerate(frequency_axis[:1]):
89 plt.figure()
90
91 sky_image = context['data']['doublefourier']['skyfft at time 0'][:,:,i].imag
92 plt.imshow(sky_image, interpolation='nearest', origin='lower',
93 aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
94 spatial_axis[0], spatial_axis[-1]])
95 plt.axis('image')
96
97 plt.colorbar(orientation='vertical')
98## plt.xlabel(beam_image.axes[0].title)
99## plt.ylabel(beam_image.axes[1].title)
100## plt.title(beam_image.title)
101
102## plt.grid()
103 plt.savefig(os.path.join(context['dirname'], 'skyfftimag%s.png' % wn))
104 plt.close()
105
106# interferograms
107baseline_interferograms = context['data']['doublefourier']['baseline interferograms']
108for baseline,interferogram in baseline_interferograms.items():
109 plt.figure()
110 plt.plot(interferogram)
111 print 'base', baseline
112 plotfile = 'interferogram%s.png' % list(baseline)
113 print 'plotfile', plotfile
114 plotfile = sanitize(plotfile)
115 print 'plotfile', plotfile
116 plt.savefig(os.path.join(context['dirname'], plotfile))
117 plt.close()
118
119%>
120
121<!-- link to the plot from html -->
122
123% for wn in context['data']['doublefourier']['frequency axis'][:1]:
124 <img src='dbsky1${wn}.png' alt="The sky model should appear here<br>">
125 <img src='dbskybeams1${wn}.png' alt="The sky*beams should appear here<br>">
126 <img src='skyfft${wn}.png' alt="The skyfft should appear here<br>">
127 <img src='skyfftimag${wn}.png' alt="The skyfft.imag should appear here<br>">
128% endfor
129
130% for baseline in baseline_interferograms.keys():
131<%
132 print 'baseline', baseline, type(baseline)
133 plotfile = 'interferogram%s.png' % list(baseline)
134 print 'plotfile', plotfile
135 plotfile = sanitize(plotfile)
136 print 'plotfile', plotfile
137%>
138 <img src='${plotfile}' alt="The interferogram should appear here<br>">
139% endfor
Note: See TracBrowser for help on using the repository browser.