Skip to content

Commit 1da4f0f

Browse files
Merged in dihm/labscript_devices/AcqAfterWait (pull request labscript-suite#11)
Fixes issue labscript-suite#19, where acquisition after wait is not handled properly Approved-by: Chris Billington <chrisjbillington@gmail.com> Approved-by: Philip Starkey <philip.starkey@monash.edu>
2 parents 7d65d5e + 2e70c9f commit 1da4f0f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

NI_PCIe_6363.py

+11
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,13 @@ def extract_measurements(self, device_name):
561561
# There were waits in this shot. We need to wait until the other process has
562562
# determined their durations before we proceed:
563563
self.wait_durations_analysed.wait(self.h5_file)
564+
564565
with h5py.File(self.h5_file,'a') as hdf5_file:
566+
if waits_in_use:
567+
# get the wait start times and durations
568+
waits = hdf5_file['/data/waits']
569+
wait_times = waits['time']
570+
wait_durations = waits['duration']
565571
try:
566572
acquisitions = hdf5_file['/devices/'+device_name+'/ACQUISITIONS']
567573
except:
@@ -573,6 +579,11 @@ def extract_measurements(self, device_name):
573579
# Group doesn't exist yet, create it:
574580
measurements = hdf5_file.create_group('/data/traces')
575581
for connection,label,start_time,end_time,wait_label,scale_factor,units in acquisitions:
582+
if waits_in_use:
583+
# add durations from all waits that start prior to start_time of acquisition
584+
start_time += wait_durations[(wait_times < start_time)].sum()
585+
# compare wait times to end_time to allow for waits during an acquisition
586+
end_time += wait_durations[(wait_times < end_time)].sum()
576587
start_index = numpy.ceil(self.buffered_rate*(start_time-self.ai_start_delay))
577588
end_index = numpy.floor(self.buffered_rate*(end_time-self.ai_start_delay))
578589
# numpy.ceil does what we want above, but float errors can miss the equality

NI_USB_6343.py

+11
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,13 @@ def extract_measurements(self, device_name):
551551
# There were waits in this shot. We need to wait until the other process has
552552
# determined their durations before we proceed:
553553
self.wait_durations_analysed.wait(self.h5_file)
554+
554555
with h5py.File(self.h5_file,'a') as hdf5_file:
556+
if waits_in_use:
557+
# get the wait start times and durations
558+
waits = hdf5_file['/data/waits']
559+
wait_times = waits['time']
560+
wait_durations = waits['duration']
555561
try:
556562
acquisitions = hdf5_file['/devices/'+device_name+'/ACQUISITIONS']
557563
except:
@@ -563,6 +569,11 @@ def extract_measurements(self, device_name):
563569
# Group doesn't exist yet, create it:
564570
measurements = hdf5_file.create_group('/data/traces')
565571
for connection,label,start_time,end_time,wait_label,scale_factor,units in acquisitions:
572+
if waits_in_use:
573+
# add durations from all waits that start prior to start_time of acquisition
574+
start_time += wait_durations[(wait_times < start_time)].sum()
575+
# compare wait_times to end_time to allow for waits during an acquisition
576+
end_time += wait_durations[(wait_times < end_time)].sum()
566577
start_index = numpy.ceil(self.buffered_rate*(start_time-self.ai_start_delay))
567578
end_index = numpy.floor(self.buffered_rate*(end_time-self.ai_start_delay))
568579
# numpy.ceil does what we want above, but float errors can miss the equality

0 commit comments

Comments
 (0)