Skip to content

Commit be0970a

Browse files
author
spielman
committed
Update to fix AI error that sometimes appears in nidaqmx.
1 parent 7c1c485 commit be0970a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

labscript_devices/NI_DAQmx/blacs_workers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,10 +627,16 @@ def extract_measurements(self, raw_data, waits_in_use):
627627
# We want np.floor(x) to yield the largest integer < x (not <=):
628628
if t_end - t0 - i_end / self.buffered_rate < 2e-16:
629629
i_end -= 1
630+
# IBS: we sometimes find that t_end (with waits) gives a time
631+
# after the end of acquisition. The following line
632+
# will produce return a shorter than expected array if i_end
633+
# is larger than the length of the array.
634+
values = raw_data[connection][i_start : i_end + 1]
635+
i_end = i_start + len(values) - 1 # re-measure i_end
636+
630637
t_i = t0 + i_start / self.buffered_rate
631638
t_f = t0 + i_end / self.buffered_rate
632-
times = np.linspace(t_i, t_f, i_end - i_start + 1, endpoint=True)
633-
values = raw_data[connection][i_start : i_end + 1]
639+
times = np.linspace(t_i, t_f, len(values), endpoint=True)
634640
dtypes = [('t', np.float64), ('values', np.float32)]
635641
data = np.empty(len(values), dtype=dtypes)
636642
data['t'] = times

0 commit comments

Comments
 (0)