From d55bc06177c258898f3184a102a8809aafc7abf7 Mon Sep 17 00:00:00 2001 From: Leolab SDR PC <johannes.schabbauer@tuwien.ac.at> Date: Wed, 10 Apr 2024 15:31:42 +0200 Subject: [PATCH] Write index instead of time in hdf5 for Spectrum card --- SpectrumAWG/blacs_workers.py | 10 +++++----- SpectrumAWG/labscript_devices.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/SpectrumAWG/blacs_workers.py b/SpectrumAWG/blacs_workers.py index 16bc26f..2b3fcf7 100644 --- a/SpectrumAWG/blacs_workers.py +++ b/SpectrumAWG/blacs_workers.py @@ -69,10 +69,10 @@ class SpectrumAWGWorker(Worker): self.smart_cache = {} last_index = len(group[ch].attrs)-1 - times = np.sort(np.array(group[ch].attrs).astype(np.float32)) # The attribute names are strings and sorted wrong. TODO: better perfomance without sorting here? - for index,t in enumerate(times): + for index in range(len(group[ch].attrs)): + index_h5 = str(index) # The index in the h5 file is a str ### LOOP TROUGH STREAMING STEPS ### - instruction = group[ch].attrs[t] + instruction = group[ch].attrs[index_h5] instruction_hash = hash(instruction.tobytes()) if instruction_hash in self.smart_cache: memory_index = self.smart_cache[instruction_hash] @@ -95,8 +95,8 @@ class SpectrumAWGWorker(Worker): initial_values[memory_index] = f"f:{freq}, a:{ampl}, p:{phase}" else: raise RuntimeError("Instruction length does not match, what happened??") - if t in group[ch]["labels"].attrs: - initial_values[memory_index] = group[ch]["labels"].attrs[t] + if index_h5 in group[ch]["labels"].attrs: + initial_values[memory_index] = group[ch]["labels"].attrs[index_h5] self.AWG.transfer_sequence_replay_samples(memory_index,data) if index!=last_index: self.AWG.seq_set_sequence_step(index,memory_index,index+1,1,'on_trigger',last_step=False) diff --git a/SpectrumAWG/labscript_devices.py b/SpectrumAWG/labscript_devices.py index 41e83e0..4ea4fde 100644 --- a/SpectrumAWG/labscript_devices.py +++ b/SpectrumAWG/labscript_devices.py @@ -168,10 +168,10 @@ class SpectrumAWG(Device): group.require_group(output.connection) group[output.connection].require_group("labels") - for t in change_times: - group[output.connection].attrs[str(t)] = output.instructions[t][:-1] + for i,t in enumerate(np.sort(change_times)): + group[output.connection].attrs[str(i)] = output.instructions[t][:-1] if output.instructions[t][-1] is not None: - group[output.connection]["labels"].attrs[str(t)] = output.instructions[t][-1] + group[output.connection]["labels"].attrs[str(i)] = output.instructions[t][-1] -- GitLab