diff --git a/Python/lib/waveform.py b/Python/lib/waveform.py index 3d84b1b7562819577be3107669731f5a3a6f8eb4..74fed31d312420cf0b86092e66ea89f041228aa9 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")