[55] | 1 | <%inherit file="base.html"/>
|
---|
| 2 |
|
---|
| 3 | <!-- do the plotting -->
|
---|
| 4 | <%
|
---|
| 5 | import os.path
|
---|
| 6 | import numpy as np
|
---|
| 7 | import common.commonobjects as co
|
---|
| 8 |
|
---|
| 9 | observed_framework = context['data']['observe']['observed_framework']
|
---|
| 10 |
|
---|
| 11 | scans = []
|
---|
| 12 | data = []
|
---|
| 13 |
|
---|
| 14 | for config in observed_framework:
|
---|
| 15 | if config.fts_start:
|
---|
| 16 |
|
---|
| 17 | if data:
|
---|
| 18 | # finish previous scan
|
---|
| 19 | # construct Spectrum object
|
---|
| 20 | axis = co.Axis(data=np.array(opd),
|
---|
| 21 | title='optical path difference', units='cm')
|
---|
| 22 | scan = co.Spectrum(data=np.array(data), flag=np.array(flag),
|
---|
| 23 | axis=axis, title='Detected interferogram',
|
---|
| 24 | units='W sr-1 m-2 Hz-1')
|
---|
| 25 | scans.append((scan, baseline))
|
---|
| 26 |
|
---|
| 27 | # ready for next scan
|
---|
| 28 | data = []
|
---|
| 29 | flag = []
|
---|
| 30 | opd = []
|
---|
| 31 |
|
---|
| 32 | if config.data is not None:
|
---|
| 33 | data.append(config.data)
|
---|
| 34 | flag.append(False)
|
---|
| 35 | else:
|
---|
| 36 | data.append(0.0)
|
---|
| 37 | flag.append(True)
|
---|
| 38 | opd.append(2.0 * 100.0 * config.fts_position)
|
---|
| 39 | baseline = (config.baseline_x, config.baseline_y)
|
---|
| 40 |
|
---|
| 41 | # deal with last scan
|
---|
| 42 | if data:
|
---|
| 43 | axis = co.Axis(data=np.array(opd), title='optical path difference',
|
---|
| 44 | units='cm')
|
---|
| 45 | scan = co.Spectrum(data=np.array(data), flag=np.array(flag),
|
---|
| 46 | axis=axis, title='Detected interferogram', units='W sr-1 m-2 Hz-1')
|
---|
| 47 | scans.append((scan, baseline))
|
---|
| 48 |
|
---|
| 49 | # do plots
|
---|
| 50 | baseline_link = {}
|
---|
| 51 |
|
---|
| 52 | for scan in scans:
|
---|
| 53 | # construct a page with the plot
|
---|
| 54 | data,baseline = scan
|
---|
| 55 |
|
---|
| 56 | filename = 'interferogram_%s_%s.html' % baseline
|
---|
| 57 | filename = filename.replace('-', 'm')
|
---|
| 58 | baseline_link[baseline] = filename
|
---|
| 59 | link = os.path.join(context['dirname'], filename)
|
---|
| 60 | with open(link, 'w') as f:
|
---|
| 61 | template = mylookup.get_template('sourcespectrum.html')
|
---|
| 62 | context_copy = context.kwargs
|
---|
| 63 | context_copy['sourceid'] = '_%s_%s_fft' % (baseline)
|
---|
| 64 | context_copy['spectrum'] = data
|
---|
| 65 | f.write(template.render(**context_copy))
|
---|
| 66 | %>
|
---|
| 67 |
|
---|
| 68 | # write html links
|
---|
| 69 |
|
---|
| 70 | <h3>Baseline Interferograms</h3>
|
---|
| 71 | % for baseline in baseline_link.keys():
|
---|
| 72 | <div class="col-xs-6 col-md-3">
|
---|
| 73 | <a href="${baseline_link[baseline]}" class="thumbnail">
|
---|
| 74 | <img src="sourcespectrum_${baseline[0]}_${baseline[1]}_fft.png" alt="...">
|
---|
| 75 | </a>
|
---|
| 76 | </div>
|
---|
| 77 | % endfor
|
---|