Changeset 28


Ignore:
Timestamp:
May 20, 2014 3:20:46 PM (10 years ago)
Author:
JohnLightfoot
Message:

various debugging plots

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/templates/doublefourier.html

    r25 r28  
    33<!-- do the plotting -->
    44<%
    5 import matplotlib.pyplot as plt
    65import 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 
    226
    237frequency_axis = context['data']['doublefourier']['frequency axis']
    24 spatial_axis = context['data']['doublefourier']['spatial axis']
    25 spatial_freq_axis = context['data']['doublefourier']['spatial frequency axis']
    268
    27 #for i,wn in enumerate(frequency_axis):
    28 for i,wn in enumerate(frequency_axis[:1]):
    29     plt.figure()
     9# construct html pages with sky model plane plots
     10for iwn,wn in enumerate(frequency_axis):
     11    link = os.path.join(context['dirname'], 'skymodelt0plane%s.html' % (wn))
     12    with open(link, 'w') as f:
     13        template = mylookup.get_template('skymodelplane.html')
     14        context_copy = context.kwargs
     15        context_copy['wn'] = wn
     16        context_copy['iwn'] = iwn
     17        context_copy['stagename'] = 'doublefourier'
     18        context_copy['resultname'] = 'sky at time 0'
     19        f.write(template.render(**context_copy))
    3020
    31     sky_image = context['data']['doublefourier']['sky at time 0'][:,:,i]
    32     plt.imshow(sky_image, interpolation='nearest', origin='lower',
    33       aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
    34       spatial_axis[0], spatial_axis[-1]])
    35     plt.axis('image')
     21for iwn,wn in enumerate(frequency_axis):
     22    link = os.path.join(context['dirname'],
     23      'skymodelpbt0plane%s.html' % (wn))
     24    with open(link, 'w') as f:
     25        template = mylookup.get_template('skymodelplane.html')
     26        context_copy = context.kwargs
     27        context_copy['wn'] = wn
     28        context_copy['iwn'] = iwn
     29        context_copy['stagename'] = 'doublefourier'
     30        context_copy['resultname'] = 'sky*beams at time 0'
     31        f.write(template.render(**context_copy))
    3632
    37     plt.colorbar(orientation='vertical')
    38 ##    plt.xlabel(beam_image.axes[0].title)
    39 ##    plt.ylabel(beam_image.axes[1].title)
    40 ##    plt.title(beam_image.title)
     33for iwn,wn in enumerate(frequency_axis):
     34    link = os.path.join(context['dirname'],
     35      'skymodelfftt0plane%s.html' % (wn))
     36    with open(link, 'w') as f:
     37        template = mylookup.get_template('skymodelplane.html')
     38        context_copy = context.kwargs
     39        context_copy['wn'] = wn
     40        context_copy['iwn'] = iwn
     41        context_copy['stagename'] = 'doublefourier'
     42        context_copy['resultname'] = 'skyfft at time 0'
     43        f.write(template.render(**context_copy))
    4144
    42 ##    plt.grid()
    43     plt.savefig(os.path.join(context['dirname'], 'dbsky1%s.png' % wn))
    44     plt.close()
     45link = os.path.join(context['dirname'], 'sourcespectrumbaseline.html')
     46with open(link, 'w') as f:
     47    template = mylookup.get_template('sourcespectrum.html')
     48    context_copy = context.kwargs
     49    context_copy['sourceid'] = 'baseline'
     50    context_copy['spectrum'] = context['data']['doublefourier']\
     51      ['skyfft spectrum at time 0']
     52    print 'before'
     53    f.write(template.render(**context_copy))
     54    print 'after'
    4555
    46 
    47 #for i,wn in enumerate(frequency_axis):
    48 for i,wn in enumerate(frequency_axis[:1]):
    49     plt.figure()
    50 
    51     sky_image = context['data']['doublefourier']['sky*beams at time 0'][:,:,i]
    52     plt.imshow(sky_image, interpolation='nearest', origin='lower',
    53       aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
    54       spatial_axis[0], spatial_axis[-1]])
    55     plt.axis('image')
    56 
    57     plt.colorbar(orientation='vertical')
    58 ##    plt.xlabel(beam_image.axes[0].title)
    59 ##    plt.ylabel(beam_image.axes[1].title)
    60 ##    plt.title(beam_image.title)
    61 
    62 ##    plt.grid()
    63     plt.savefig(os.path.join(context['dirname'], 'dbskybeams1%s.png' % wn))
    64     plt.close()
    65 
    66 #for i,wn in enumerate(frequency_axis):
    67 for i,wn in enumerate(frequency_axis[:1]):
    68     plt.figure()
    69 
    70     sky_image = context['data']['doublefourier']['skyfft at time 0'][:,:,i].real
    71     plt.imshow(sky_image, interpolation='nearest', origin='lower',
    72       aspect='equal', extent=[spatial_freq_axis[0], spatial_freq_axis[-1],
    73       spatial_freq_axis[0], spatial_freq_axis[-1]])
    74     plt.axis('image')
    75 
    76     plt.colorbar(orientation='vertical')
    77 ##    plt.xlabel(beam_image.axes[0].title)
    78 ##    plt.ylabel(beam_image.axes[1].title)
    79 ##    plt.title(beam_image.title)
    80 
    81 ##    plt.grid()
    82     plt.savefig(os.path.join(context['dirname'], 'skyfft%s.png' % wn))
    83     plt.close()
    84 
    85 #for i,wn in enumerate(frequency_axis):
    86 for i,wn in enumerate(frequency_axis[:1]):
    87     plt.figure()
    88 
    89     sky_image = context['data']['doublefourier']['skyfft at time 0'][:,:,i].imag
    90     plt.imshow(sky_image, interpolation='nearest', origin='lower',
    91       aspect='equal', extent=[spatial_axis[0], spatial_axis[-1],
    92       spatial_axis[0], spatial_axis[-1]])
    93     plt.axis('image')
    94 
    95     plt.colorbar(orientation='vertical')
    96 ##    plt.xlabel(beam_image.axes[0].title)
    97 ##    plt.ylabel(beam_image.axes[1].title)
    98 ##    plt.title(beam_image.title)
    99 
    100 ##    plt.grid()
    101     plt.savefig(os.path.join(context['dirname'], 'skyfftimag%s.png' % wn))
    102     plt.close()
    103 
    104 # interferograms
    105 baseline_interferograms = context['data']['doublefourier']['baseline interferograms']
    106 for baseline,interferogram in baseline_interferograms.items():
    107     plt.figure()
    108     plt.plot(interferogram)
    109     plotfile = 'interferogram%s.png' % list(baseline)
    110     plotfile = sanitize(plotfile)
    111     plt.savefig(os.path.join(context['dirname'], plotfile))
    112     plt.close()
    113 
     56link = os.path.join(context['dirname'], 'baselineffttest.html')
     57with open(link, 'w') as f:
     58    template = mylookup.get_template('sourcespectrum.html')
     59    context_copy = context.kwargs
     60    context_copy['sourceid'] = 'testfft'
     61    context_copy['spectrum'] = context['data']['doublefourier']\
     62      ['test FTS at time 0']
     63    print 'before'
     64    f.write(template.render(**context_copy))
     65    print 'after'
    11466%>
    11567
    116 <!-- link to the plot from html -->
     68<!-- link to the plot pages from this page -->
    11769
    118 % for wn in context['data']['doublefourier']['frequency axis'][:1]:
    119     <img src='dbsky1${wn}.png' alt="The sky model should appear here<br>">
    120     <img src='dbskybeams1${wn}.png' alt="The sky*beams should appear here<br>">
    121     <img src='skyfft${wn}.png' alt="The skyfft should appear here<br>">
    122     <img src='skyfftimag${wn}.png' alt="The skyfft.imag should appear here<br>">
     70<h3>Sky Model Planes at t=0</h3>
     71<div class="row">
     72% for wn in frequency_axis:
     73    <%
     74    wnformatted = '%6.4gcm-1' % wn
     75    %>
     76  <div class="col-xs-6 col-md-3">
     77    <a href="skymodelt0plane${wn}.html" class="thumbnail">
     78      <img src="sky_at_time_0plane${wn}.png" alt="...">
     79      <div>
     80        <h4>${wnformatted}</h4>
     81      </div>
     82    </a>
     83  </div>
    12384% endfor
     85</div>
    12486
    125 % for baseline in baseline_interferograms.keys():
    126 <%
    127     plotfile = 'interferogram%s.png' % list(baseline)
    128     plotfile = sanitize(plotfile)
    129 %>
    130     <img src='${plotfile}' alt="The interferogram should appear here<br>">
     87<h3>Sky Model Planes*Pb at t=0</h3>
     88<div class="row">
     89% for wn in frequency_axis:
     90    <%
     91    wnformatted = '%6.4gcm-1' % wn
     92    %>
     93  <div class="col-xs-6 col-md-3">
     94    <a href="skymodelpbt0plane${wn}.html" class="thumbnail">
     95      <img src="sky_beams_at_time_0plane${wn}.png" alt="...">
     96      <div>
     97        <h4>${wnformatted}</h4>
     98      </div>
     99    </a>
     100  </div>
    131101% endfor
     102</div>
     103
     104<h3>Sky Model FFT at t=0</h3>
     105<div class="row">
     106% for wn in frequency_axis:
     107    <%
     108    wnformatted = '%6.4gcm-1' % wn
     109    %>
     110  <div class="col-xs-6 col-md-3">
     111    <a href="skymodelfftt0plane${wn}.html" class="thumbnail">
     112      <img src="skyfft_at_time_0plane${wn}.png" alt="...">
     113      <div>
     114        <h4>${wnformatted}</h4>
     115      </div>
     116    </a>
     117  </div>
     118% endfor
     119</div>
     120
     121<h3>Measured spectrum at t=0</h3>
     122<div class="col-xs-6 col-md-3">
     123  <a href="sourcespectrumbaseline.html" class="thumbnail">
     124    <img src="sourcespectrumbaseline.png" alt="...">
     125  </a>
     126</div>
     127
     128<h3>Measured interferogram at t=0</h3>
     129<div class="col-xs-6 col-md-3">
     130  <a href="baselineffttest.html" class="thumbnail">
     131    <img src="sourcespectrumtestfft.png" alt="...">
     132  </a>
     133</div>
Note: See TracChangeset for help on using the changeset viewer.