MAVENSDC/PyTplot

Spectrograms not plotting with pyqtgraph 0.12.x

ericthewizard opened this issue · 3 comments

Here's an example:

from pytplot import store_data, tplot, options
import numpy as np

data = np.array([[0,       1,       2,       3,       4],
       [5,       6,       7,       8,       9],
      [10,      11,      12,      13,      14],
      [15,      16,      17,      18,      19],
      [20,      21,      22,      23,      24]])

store_data('bins_1', data={'x': [1, 2, 3, 4, 5], 'y': data.transpose(), 'v': [10, 20, 30, 40, 50]})

options('bins_1', 'spec', 1)
tplot('bins_1')

The plot comes out empty with pyqtgraph 0.12.0, 0.12.1 and 0.12.2; 0.11.1 seems to be the last version that works.

The latest master branch should fix this issue, and should be backwards compatible with 0.11.X pyqtgraph as well (from what I tested). Once I fix the issue with GitHub actions, it should push up

Thanks! I updated to the latest pytplot using:

pip install --upgrade git+https://github.com/MAVENSDC/PyTplot

and I updated to pyqtgraph 0.12.2.

The test case is running for me now, but now when I plot an FPI spectrogram, I see the error:

>>> import pyspedas
>>> pyspedas.mms.fpi(datatype='des-moms', trange=['2015-10-16/13:00', '2015-10-16/13:10'], data_rate='brst')
>>> tplot(['mms1_des_energyspectr_omni_brst'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\egrimes\AppData\Local\Programs\Python\Python39\lib\site-packages\pytplot\tplot.py", line 244, in tplot
    layout_orig = QtPlotter.generate_stack(name, var_label=var_label, combine_axes=combine_axes, vert_spacing=vert_spacing)
  File "C:\Users\egrimes\AppData\Local\Programs\Python\Python39\lib\site-packages\pytplot\QtPlotter\generate.py", line 81, in generate_stack
    new_fig.buildfigure()
  File "C:\Users\egrimes\AppData\Local\Programs\Python\Python39\lib\site-packages\pytplot\QtPlotter\TVarFigureSpec.py", line 156, in buildfigure
    self._visdata()
  File "C:\Users\egrimes\AppData\Local\Programs\Python\Python39\lib\site-packages\pytplot\QtPlotter\TVarFigureSpec.py", line 187, in _visdata
    x, y, data = self._format_spec_data_as_image(x_pixel_length = self.X_PIXEL_LENGTH,
  File "C:\Users\egrimes\AppData\Local\Programs\Python\Python39\lib\site-packages\pytplot\QtPlotter\TVarFigureSpec.py", line 257, in _format_spec_data_as_image
    if (self.bin_sizes.iloc[i] == prev_bins).all():
AttributeError: 'TVarFigureSpec' object has no attribute 'bin_sizes'

Thanks for catching that one, it should work now on the latest branch