1 | <%inherit file="base.html"/>
|
---|
2 |
|
---|
3 | <!-- do the plotting -->
|
---|
4 | <%
|
---|
5 | import matplotlib.pyplot as plt
|
---|
6 | import os.path
|
---|
7 | import string
|
---|
8 |
|
---|
9 | _valid_chars = "_.%s%s" % (string.ascii_letters, string.digits)
|
---|
10 | def _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 |
|
---|
18 | def sanitize(text):
|
---|
19 | filename = ''.join(_char_replacer(c) for c in text)
|
---|
20 | return filename
|
---|
21 |
|
---|
22 |
|
---|
23 | frequency_axis = context['data']['doublefourier']['frequency axis']
|
---|
24 | spatial_axis = context['data']['doublefourier']['spatial axis']
|
---|
25 | spatial_freq_axis = context['data']['doublefourier']['spatial frequency axis']
|
---|
26 | print 'spatial frequency axis', spatial_freq_axis
|
---|
27 |
|
---|
28 | #for i,wn in enumerate(frequency_axis):
|
---|
29 | print 'frequency axis', frequency_axis
|
---|
30 | for 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):
|
---|
50 | for 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):
|
---|
69 | for 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):
|
---|
88 | for 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
|
---|
107 | baseline_interferograms = context['data']['doublefourier']['baseline interferograms']
|
---|
108 | for 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
|
---|