Skip to content

Commit

Permalink
Improved handling for invalid data on dropped samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
mliberty1 committed Sep 7, 2019
1 parent 420f63b commit 387c57d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions joulescope_ui/oscilloscope/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,14 @@ def update(self, x, value):
# get the valid mean values regardless of shape
z_valid = np.isfinite(z_mean)
x = x[z_valid]
z_mean = z_mean[z_valid]
if not len(z_mean):
z_mean_valid = z_mean[z_valid]
if not len(z_mean_valid):
if len(z_mean):
self.log.warning('no valid data: %d -> %d', len(z_mean), len(z_mean_valid))
self.data_clear()
return

z_mean = z_mean_valid
self._most_recent_data = [x, z_mean, None, None, None]
z_var, z_min, z_max = None, None, None
if shape_len == 2 and value.shape[1] == 4:
Expand Down Expand Up @@ -323,6 +326,8 @@ def update(self, x, value):
self.curve_min.setData(d_x, self._log_bound(d_min))
self.curve_max.setData(d_x, self._log_bound(d_max))

if not np.isfinite(v_min) or not np.isfinite(v_max) or np.abs(v_min) > 1000 or np.abs(v_max) > 1000:
log.warning('signal.update(%r, %r)' % (v_min, v_max))
if self.text_item is not None:
labels = {'μ': v_mean, 'σ': v_std, 'min': v_min, 'max': v_max, 'p2p': v_max - v_min}
txt_result = si_format(labels, units=self.units)
Expand Down
2 changes: 1 addition & 1 deletion joulescope_ui/range_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ def run(self, view, statistics, x_start, x_stop):
self.sample_range = (s1, s2)
self.sample_count = s2 - s1
self.sample_frequency = view.sampling_frequency
self.calibration = view.calibration
self._view = view
self.calibration = self._view.calibration

self._range_tool_obj = self._range_tool.fn()
try:
Expand Down

0 comments on commit 387c57d

Please sign in to comment.