From b9127665cca2e15abb941b48a0a66d27ba4dcbdc Mon Sep 17 00:00:00 2001 From: xiyehu2 <xiyehu2@illinois.edu> Date: Thu, 19 Oct 2023 17:58:21 -0500 Subject: [PATCH] added save_csv for compatibility with cpp version --- Python/lib/waveform.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Python/lib/waveform.py b/Python/lib/waveform.py index 3d84b1b..74fed31 100644 --- a/Python/lib/waveform.py +++ b/Python/lib/waveform.py @@ -54,6 +54,18 @@ class Waveform: self.phi = data['phi'] self.sample_rate = data['sample_rate'] + def save_csv(self, filename: str): + with open(filename, "w") as file: + file.write(f"{self.sample_rate}\n") + file.write(f"{int(self.freq_res)}\n") + with open(filename, "a") as file: + np.savetxt(file, np.round(self.omega / 2 / np.pi), fmt="%d", delimiter='', newline=",") + file.write("\n") + np.savetxt(file, self.phi, fmt="%d", delimiter='', newline=",") + file.write("\n") + np.savetxt(file, self.amplitude, fmt="%d", delimiter='', newline=",") + file.write("\n") + def create_static_array( wfm: Waveform, @@ -81,7 +93,6 @@ def create_static_array( # shape=(number of tweezers x sample_len) ) sin_mat = (wfm.amplitude * sin_mat.T).T # this works, trust me - # sum up all rows to get final signal sig = np.sum(sin_mat, axis=0) if np.max(sig) >= 2 ** 15 - 1: @@ -394,7 +405,7 @@ def tricky_trick( n += 1 tau_stay = n / df - tau_move else: - n = np.ceil(tau_move + tau_stay) * df + n = np.ceil((tau_move + tau_stay) * df) tau_stay = n / df - tau_move print(f"stay = {tau_stay*1e6:.1f} us") print(f"move = {tau_move*1e6:.1f} us") -- GitLab