Changeset 50


Ignore:
Timestamp:
Sep 19, 2014 4:53:31 PM (10 years ago)
Author:
JohnLightfoot
Message:

almost working

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/templates/sourcespectrum.html

    r29 r50  
    1111sourceid = context['sourceid']
    1212spectrum = context['spectrum']
    13 print 'spectrum', np.shape(spectrum.data)
    1413
    1514try:
    1615    xaxis_data = spectrum.axis.data
    17     print 'axis', len(xaxis_data)
    1816except:
    1917    xaxis_data = np.arange(len(spectrum.data))
     18
     19# sometimes xaxis is not monotonic
     20xaxis_sort = np.argsort(xaxis_data)
    2021
    2122try:
     
    2930    xaxis_units = None
    3031   
    31 plt.plot(xaxis_data, spectrum.data)
     32if spectrum.data.dtype==np.complex:
     33    plt.plot(xaxis_data[xaxis_sort], spectrum.data.real[xaxis_sort],
     34      color='blue')
     35    plt.plot(xaxis_data[xaxis_sort], spectrum.data.imag[xaxis_sort],
     36      color='red')
     37    plt.figtext(0.2, 0.25, 'real', color='blue')
     38    plt.figtext(0.2, 0.2, 'imag', color='red')
     39else:
     40    plt.plot(xaxis_data[xaxis_sort], spectrum.data[xaxis_sort])
     41
    3242plt.title('Source %s' % sourceid)
    3343xlabel = ' '.join([v for v in [xaxis_title, xaxis_units] if v is not None])
Note: See TracChangeset for help on using the changeset viewer.