Index: trunk/templates/doublefourier.html
===================================================================
--- trunk/templates/doublefourier.html	(revision 25)
+++ trunk/templates/doublefourier.html	(revision 28)
@@ -3,129 +3,131 @@
 <!-- do the plotting -->
 <%
-import matplotlib.pyplot as plt
 import os.path
-import string
-
-_valid_chars = "_.%s%s" % (string.ascii_letters, string.digits)
-def _char_replacer(s):
-    '''A small utility function that echoes the argument or returns '_' if the
-    argument is in a list of forbidden characters.
-    '''
-    if s not in _valid_chars:
-        return '_'
-    return s
-
-def sanitize(text):
-    filename = ''.join(_char_replacer(c) for c in text)
-    return filename
-
 
 frequency_axis = context['data']['doublefourier']['frequency axis']
-spatial_axis = context['data']['doublefourier']['spatial axis']
-spatial_freq_axis = context['data']['doublefourier']['spatial frequency axis']
 
-#for i,wn in enumerate(frequency_axis):
-for i,wn in enumerate(frequency_axis[:1]):
-    plt.figure()
+# construct html pages with sky model plane plots
+for iwn,wn in enumerate(frequency_axis):
+    link = os.path.join(context['dirname'], 'skymodelt0plane%s.html' % (wn))
+    with open(link, 'w') as f:
+        template = mylookup.get_template('skymodelplane.html')
+        context_copy = context.kwargs
+        context_copy['wn'] = wn
+        context_copy['iwn'] = iwn
+        context_copy['stagename'] = 'doublefourier'
+        context_copy['resultname'] = 'sky at time 0'
+        f.write(template.render(**context_copy))
 
-    sky_image = context['data']['doublefourier']['sky at time 0'][:,:,i]
-    plt.imshow(sky_image, interpolation='nearest', origin='lower',
-      aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
-      spatial_axis[0], spatial_axis[-1]])
-    plt.axis('image')
+for iwn,wn in enumerate(frequency_axis):
+    link = os.path.join(context['dirname'],
+      'skymodelpbt0plane%s.html' % (wn))
+    with open(link, 'w') as f:
+        template = mylookup.get_template('skymodelplane.html')
+        context_copy = context.kwargs
+        context_copy['wn'] = wn
+        context_copy['iwn'] = iwn
+        context_copy['stagename'] = 'doublefourier'
+        context_copy['resultname'] = 'sky*beams at time 0'
+        f.write(template.render(**context_copy))
 
-    plt.colorbar(orientation='vertical')
-##    plt.xlabel(beam_image.axes[0].title)
-##    plt.ylabel(beam_image.axes[1].title)
-##    plt.title(beam_image.title)
+for iwn,wn in enumerate(frequency_axis):
+    link = os.path.join(context['dirname'],
+      'skymodelfftt0plane%s.html' % (wn))
+    with open(link, 'w') as f:
+        template = mylookup.get_template('skymodelplane.html')
+        context_copy = context.kwargs
+        context_copy['wn'] = wn
+        context_copy['iwn'] = iwn
+        context_copy['stagename'] = 'doublefourier'
+        context_copy['resultname'] = 'skyfft at time 0'
+        f.write(template.render(**context_copy))
 
-##    plt.grid()
-    plt.savefig(os.path.join(context['dirname'], 'dbsky1%s.png' % wn))
-    plt.close()
+link = os.path.join(context['dirname'], 'sourcespectrumbaseline.html')
+with open(link, 'w') as f:
+    template = mylookup.get_template('sourcespectrum.html')
+    context_copy = context.kwargs
+    context_copy['sourceid'] = 'baseline'
+    context_copy['spectrum'] = context['data']['doublefourier']\
+      ['skyfft spectrum at time 0']
+    print 'before'
+    f.write(template.render(**context_copy))
+    print 'after'
 
-
-#for i,wn in enumerate(frequency_axis):
-for i,wn in enumerate(frequency_axis[:1]):
-    plt.figure()
-
-    sky_image = context['data']['doublefourier']['sky*beams at time 0'][:,:,i]
-    plt.imshow(sky_image, interpolation='nearest', origin='lower',
-      aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
-      spatial_axis[0], spatial_axis[-1]])
-    plt.axis('image')
-
-    plt.colorbar(orientation='vertical')
-##    plt.xlabel(beam_image.axes[0].title)
-##    plt.ylabel(beam_image.axes[1].title)
-##    plt.title(beam_image.title)
-
-##    plt.grid()
-    plt.savefig(os.path.join(context['dirname'], 'dbskybeams1%s.png' % wn))
-    plt.close()
-
-#for i,wn in enumerate(frequency_axis):
-for i,wn in enumerate(frequency_axis[:1]):
-    plt.figure()
-
-    sky_image = context['data']['doublefourier']['skyfft at time 0'][:,:,i].real
-    plt.imshow(sky_image, interpolation='nearest', origin='lower',
-      aspect='equal', extent=[spatial_freq_axis[0], spatial_freq_axis[-1],
-      spatial_freq_axis[0], spatial_freq_axis[-1]])
-    plt.axis('image')
-
-    plt.colorbar(orientation='vertical')
-##    plt.xlabel(beam_image.axes[0].title)
-##    plt.ylabel(beam_image.axes[1].title)
-##    plt.title(beam_image.title)
-
-##    plt.grid()
-    plt.savefig(os.path.join(context['dirname'], 'skyfft%s.png' % wn))
-    plt.close()
-
-#for i,wn in enumerate(frequency_axis):
-for i,wn in enumerate(frequency_axis[:1]):
-    plt.figure()
-
-    sky_image = context['data']['doublefourier']['skyfft at time 0'][:,:,i].imag
-    plt.imshow(sky_image, interpolation='nearest', origin='lower',
-      aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
-      spatial_axis[0], spatial_axis[-1]])
-    plt.axis('image')
-
-    plt.colorbar(orientation='vertical')
-##    plt.xlabel(beam_image.axes[0].title)
-##    plt.ylabel(beam_image.axes[1].title)
-##    plt.title(beam_image.title)
-
-##    plt.grid()
-    plt.savefig(os.path.join(context['dirname'], 'skyfftimag%s.png' % wn))
-    plt.close()
-
-# interferograms
-baseline_interferograms = context['data']['doublefourier']['baseline interferograms']
-for baseline,interferogram in baseline_interferograms.items():
-    plt.figure()
-    plt.plot(interferogram)
-    plotfile = 'interferogram%s.png' % list(baseline)
-    plotfile = sanitize(plotfile)
-    plt.savefig(os.path.join(context['dirname'], plotfile))
-    plt.close()
-
+link = os.path.join(context['dirname'], 'baselineffttest.html')
+with open(link, 'w') as f:
+    template = mylookup.get_template('sourcespectrum.html')
+    context_copy = context.kwargs
+    context_copy['sourceid'] = 'testfft'
+    context_copy['spectrum'] = context['data']['doublefourier']\
+      ['test FTS at time 0']
+    print 'before'
+    f.write(template.render(**context_copy))
+    print 'after'
 %>
 
-<!-- link to the plot from html -->
+<!-- link to the plot pages from this page -->
 
-% for wn in context['data']['doublefourier']['frequency axis'][:1]:
-    <img src='dbsky1${wn}.png' alt="The sky model should appear here<br>">
-    <img src='dbskybeams1${wn}.png' alt="The sky*beams should appear here<br>">
-    <img src='skyfft${wn}.png' alt="The skyfft should appear here<br>">
-    <img src='skyfftimag${wn}.png' alt="The skyfft.imag should appear here<br>">
+<h3>Sky Model Planes at t=0</h3>
+<div class="row">
+% for wn in frequency_axis:
+    <%
+    wnformatted = '%6.4gcm-1' % wn
+    %>
+  <div class="col-xs-6 col-md-3">
+    <a href="skymodelt0plane${wn}.html" class="thumbnail">
+      <img src="sky_at_time_0plane${wn}.png" alt="...">
+      <div>
+        <h4>${wnformatted}</h4>
+      </div>
+    </a>
+  </div>
 % endfor
+</div>
 
-% for baseline in baseline_interferograms.keys():
-<%
-    plotfile = 'interferogram%s.png' % list(baseline)
-    plotfile = sanitize(plotfile)
-%>
-    <img src='${plotfile}' alt="The interferogram should appear here<br>">
+<h3>Sky Model Planes*Pb at t=0</h3>
+<div class="row">
+% for wn in frequency_axis:
+    <%
+    wnformatted = '%6.4gcm-1' % wn
+    %>
+  <div class="col-xs-6 col-md-3">
+    <a href="skymodelpbt0plane${wn}.html" class="thumbnail">
+      <img src="sky_beams_at_time_0plane${wn}.png" alt="...">
+      <div>
+        <h4>${wnformatted}</h4>
+      </div>
+    </a>
+  </div>
 % endfor
+</div>
+
+<h3>Sky Model FFT at t=0</h3>
+<div class="row">
+% for wn in frequency_axis:
+    <%
+    wnformatted = '%6.4gcm-1' % wn
+    %>
+  <div class="col-xs-6 col-md-3">
+    <a href="skymodelfftt0plane${wn}.html" class="thumbnail">
+      <img src="skyfft_at_time_0plane${wn}.png" alt="...">
+      <div>
+        <h4>${wnformatted}</h4>
+      </div>
+    </a>
+  </div>
+% endfor
+</div>
+
+<h3>Measured spectrum at t=0</h3>
+<div class="col-xs-6 col-md-3">
+  <a href="sourcespectrumbaseline.html" class="thumbnail">
+    <img src="sourcespectrumbaseline.png" alt="...">
+  </a>
+</div>
+
+<h3>Measured interferogram at t=0</h3>
+<div class="col-xs-6 col-md-3">
+  <a href="baselineffttest.html" class="thumbnail">
+    <img src="sourcespectrumtestfft.png" alt="...">
+  </a>
+</div>
