Last change
on this file since 34 was 29, checked in by JohnLightfoot, 10 years ago |
various improvements
|
File size:
893 bytes
|
Rev | Line | |
---|
[17] | 1 | <%inherit file="base.html"/>
|
---|
| 2 |
|
---|
| 3 | <!-- do the plotting -->
|
---|
| 4 | <%
|
---|
| 5 | import matplotlib.pyplot as plt
|
---|
| 6 | import os.path
|
---|
[29] | 7 | import numpy as np
|
---|
[17] | 8 |
|
---|
| 9 | plt.figure()
|
---|
| 10 |
|
---|
| 11 | sourceid = context['sourceid']
|
---|
[29] | 12 | spectrum = context['spectrum']
|
---|
| 13 | print 'spectrum', np.shape(spectrum.data)
|
---|
[17] | 14 |
|
---|
[29] | 15 | try:
|
---|
| 16 | xaxis_data = spectrum.axis.data
|
---|
| 17 | print 'axis', len(xaxis_data)
|
---|
| 18 | except:
|
---|
| 19 | xaxis_data = np.arange(len(spectrum.data))
|
---|
| 20 |
|
---|
| 21 | try:
|
---|
| 22 | xaxis_title = spectrum.axis.title
|
---|
| 23 | except:
|
---|
| 24 | xaxis_title = None
|
---|
| 25 |
|
---|
| 26 | try:
|
---|
| 27 | xaxis_units = spectrum.axis.units
|
---|
| 28 | except:
|
---|
| 29 | xaxis_units = None
|
---|
| 30 |
|
---|
| 31 | plt.plot(xaxis_data, spectrum.data)
|
---|
[17] | 32 | plt.title('Source %s' % sourceid)
|
---|
[29] | 33 | xlabel = ' '.join([v for v in [xaxis_title, xaxis_units] if v is not None])
|
---|
| 34 | plt.xlabel(xlabel)
|
---|
[17] | 35 |
|
---|
| 36 | plt.savefig(os.path.join(context['dirname'], 'sourcespectrum%s.png' % sourceid))
|
---|
| 37 | plt.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.