Skip to content

Commit

Permalink
WIP support for downsampling large vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWrigley committed Apr 6, 2022
1 parent 65f9619 commit 8485c45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/dependabot/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ karabo-bridge==0.6.1
kiwisolver==1.4.0
libcst==0.4.1
locket==0.2.1
lttbc==0.2.1
MarkupSafe==2.1.1
matplotlib==3.5.1
mistune==2.0.2
Expand Down
15 changes: 12 additions & 3 deletions extra_foam/special_suite/correlator_w.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from enum import Enum
from collections import defaultdict

import lttbc
import libcst as cst
import libcst.matchers as m
import libcst.metadata as cstmeta
Expand Down Expand Up @@ -353,6 +354,9 @@ def _resize_buffers(self):
if buf.capacity() != self._max_points:
buf.resize(self._max_points)

def downsample(self, x, y):
return lttbc.downsample(x, y, 2000)

def updateF(self, all_data):
if self._current_view not in all_data:
return
Expand Down Expand Up @@ -405,7 +409,9 @@ def handle_rich_output():
# it's the Y axis data and generate the X axis.
if data.values.shape[0] == 1:
y_data = data.values[0]
self._xs.extend(np.arange(len(y_data)))
x_data = np.arange(len(y_data))
x_data, y_data = self.downsample(x_data, y_data)
self._xs.extend(x_data)
self._ys[y_series_labels[0]].extend(y_data)

# Otherwise, we treat the first vector slice as the X axis,
Expand Down Expand Up @@ -448,8 +454,11 @@ def handle_rich_output():
self._clearData()

if is_ndarray:
self._xs.extend(range(len(data)))
self._ys["y0"].extend(data)
x_data = np.arange(len(data))
x_data, y_data = self.downsample(x_data, data)

self._xs.extend(x_data)
self._ys["y0"].extend(y_data)
elif is_xarray:
handle_rich_output()
else:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def has_ext_modules(self):
"metropc @ git+ssh://git@git.xfel.eu:10022/karaboDevices/metropc.git@high_high_water_mark",
"qscintilla",
"libcst",
"lttbc",
# These dependencies are not directly used, but are needed to satisfy
# pip's resolver:
'pygments',
Expand Down

0 comments on commit 8485c45

Please sign in to comment.