source: trunk/templates/sourcespectrum.html@ 29

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

various improvements

File size: 893 bytes
Line 
1<%inherit file="base.html"/>
2
3<!-- do the plotting -->
4<%
5import matplotlib.pyplot as plt
6import os.path
7import numpy as np
8
9plt.figure()
10
11sourceid = context['sourceid']
12spectrum = context['spectrum']
13print 'spectrum', np.shape(spectrum.data)
14
15try:
16 xaxis_data = spectrum.axis.data
17 print 'axis', len(xaxis_data)
18except:
19 xaxis_data = np.arange(len(spectrum.data))
20
21try:
22 xaxis_title = spectrum.axis.title
23except:
24 xaxis_title = None
25
26try:
27 xaxis_units = spectrum.axis.units
28except:
29 xaxis_units = None
30
31plt.plot(xaxis_data, spectrum.data)
32plt.title('Source %s' % sourceid)
33xlabel = ' '.join([v for v in [xaxis_title, xaxis_units] if v is not None])
34plt.xlabel(xlabel)
35
36plt.savefig(os.path.join(context['dirname'], 'sourcespectrum%s.png' % sourceid))
37plt.close()
38%>
39
40<!-- link to the plot from html -->
41
42<img src='sourcespectrum${sourceid}.png' alt="Source spectrum">
Note: See TracBrowser for help on using the repository browser.