From b5169fa8ed0ff56d121c751d96ae6d25d665dcfb Mon Sep 17 00:00:00 2001
From: Leolab SDR PC <johannes.schabbauer@tuwien.ac.at>
Date: Wed, 5 Mar 2025 14:16:15 +0100
Subject: [PATCH] Added time offset from waits also to ADwin AOUT trace (for
 plotting in lyse)

---
 ADwinProII/ADwin_utils.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ADwinProII/ADwin_utils.py b/ADwinProII/ADwin_utils.py
index 3ac371e..33f1284 100644
--- a/ADwinProII/ADwin_utils.py
+++ b/ADwinProII/ADwin_utils.py
@@ -206,5 +206,10 @@ def get_aout_trace(h5file, output):
         data = f["devices/ADwin/ANALOG_OUT/VALUES"][:]
         mask = (data["channel"] == port)
         t = np.round(PROCESSDELAY / CLOCK_T12 * data["n_cycles"][mask], 9)
+        if "data" in f and "waits" in f["data"]:
+                # There was a wait in the experiment, let's offset the times such that they are accurate
+                waits = f["data/waits"][:]
+                for i in range(len(waits)):
+                    t[t > waits["time"][i]] += waits["duration"][i]
         values = DAC(data["value"][mask])
     return t, values
\ No newline at end of file
-- 
GitLab