From be0970a7f79363144cc0b261aaf63b3e4dc303e1 Mon Sep 17 00:00:00 2001 From: spielman Date: Tue, 22 Jun 2021 11:13:50 -0400 Subject: [PATCH] Update to fix AI error that sometimes appears in nidaqmx. --- labscript_devices/NI_DAQmx/blacs_workers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/labscript_devices/NI_DAQmx/blacs_workers.py b/labscript_devices/NI_DAQmx/blacs_workers.py index d9bc2509..7e12047f 100644 --- a/labscript_devices/NI_DAQmx/blacs_workers.py +++ b/labscript_devices/NI_DAQmx/blacs_workers.py @@ -627,10 +627,16 @@ def extract_measurements(self, raw_data, waits_in_use): # We want np.floor(x) to yield the largest integer < x (not <=): if t_end - t0 - i_end / self.buffered_rate < 2e-16: i_end -= 1 + # IBS: we sometimes find that t_end (with waits) gives a time + # after the end of acquisition. The following line + # will produce return a shorter than expected array if i_end + # is larger than the length of the array. + values = raw_data[connection][i_start : i_end + 1] + i_end = i_start + len(values) - 1 # re-measure i_end + t_i = t0 + i_start / self.buffered_rate t_f = t0 + i_end / self.buffered_rate - times = np.linspace(t_i, t_f, i_end - i_start + 1, endpoint=True) - values = raw_data[connection][i_start : i_end + 1] + times = np.linspace(t_i, t_f, len(values), endpoint=True) dtypes = [('t', np.float64), ('values', np.float32)] data = np.empty(len(values), dtype=dtypes) data['t'] = times