Skip to content

Commit

Permalink
fixe fft from pyqtgraph
Browse files Browse the repository at this point in the history
wrap _fourierTransform to fixe pyqtgraph/issues/3018 before patch pyqtgraph/pull/3070
  • Loading branch information
Python-simulation committed Jul 1, 2024
1 parent 05f14c8 commit 01e4e67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 17 additions & 0 deletions autolab/core/gui/GUI_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,24 @@

from ..config import get_GUI_config


# Fixes pyqtgraph/issues/3018 for pg<=0.13.7 (before pyqtgraph/pull/3070)
from pyqtgraph.graphicsItems.PlotDataItem import PlotDataItem

if hasattr(PlotDataItem, '_fourierTransform'):

_fourierTransform_bugged = PlotDataItem._fourierTransform

def _fourierTransform_fixed(self, x, y):
if len(x) == 1: return np.array([0]), abs(y)
return _fourierTransform_bugged(self, x, y)

PlotDataItem._fourierTransform = _fourierTransform_fixed


ONCE = False


def get_font_size() -> int:
GUI_config = get_GUI_config()
if GUI_config['font_size'] != 'default':
Expand Down Expand Up @@ -189,6 +205,7 @@ def update_img(self, x, y, z):
self.img = img
self.ax.addItem(self.img)


def pyqtgraph_fig_ax() -> Tuple[MyGraphicsLayoutWidget, pg.PlotItem]:
""" Return a formated fig and ax pyqtgraph for a basic plot """
fig = MyGraphicsLayoutWidget()
Expand Down
1 change: 0 additions & 1 deletion autolab/core/gui/scanning/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ def reloadData(self):
alpha = (true_nbtraces - (len(data) - 1 - i)) / true_nbtraces

# Plot
# OPTIMIZE: known issue but from pyqtgraph, error if use FFT on one point
# careful, now that can filter data, need .values to avoid pyqtgraph bug
curve = self.ax.plot(x.values, y.values, symbol='x',
symbolPen=color, symbolSize=10,
Expand Down

0 comments on commit 01e4e67

Please sign in to comment.