diff --git a/Python/lib/waveform.py b/Python/lib/waveform.py index 0bc592e7b8ca6e3f3fc5437ce6e2c52e588d7099..45d5ee2d26ec6e4c04f12064a345c5577016b634 100644 --- a/Python/lib/waveform.py +++ b/Python/lib/waveform.py @@ -38,7 +38,7 @@ class Waveform: # formula for minimum sample length # sample_len_min = 512 * m # m * 512 * freq_resolution / sampling_rate = k, k % 2 == 0 - self.sample_len_min = 2 * sample_rate / freq_res / 10 # !!! this only works for sample_rate = 614.4e6 !!! + self.sample_len_min = 2 * sample_rate / freq_res # !!! this only works for sample_rate = 614.4e6 !!! def set_amplitudes(self, amps: np.ndarray) -> bool: @@ -72,8 +72,13 @@ def create_static_array(wfm: Waveform, full=False) -> np.ndarray: :return: either a 1D or 2D np array :rtype: np.ndarray """ + # wfm.sample_len_min *= 10 + length_check = wfm.sample_len_min * 512 * 50e3 / wfm.sample_rate % 2 == 0 + if not length_check: + raise Exception("static waveform length requirement not met.") + # construct time axis, t_total(s) = sample_len / sample_rate, dt = t_total / sample_len - t = np.arange(wfm.sample_len_min) / wfm.sample_rate + t = np.arange(wfm.sample_len_min * 10) / wfm.sample_rate # calculate individual sin waves, sig_mat[i] corresponds to data for ith tweezer # sin_mat = wfm.amplitude * np.sin(np.outer(wfm.omega,t) + np.expand_dims(wfm.phi, axis=1)) # shape=(number of tweezers x sample_len) @@ -448,19 +453,19 @@ def create_moving_signal_single( def create_static_signal_single( - omega, sample_rate, signal_time, amp=2 ** 12, phi=0 + omega, sample_rate, sample_len, amp=2 ** 12, phi=0 ): - min_len = 2 * sample_rate / (1e3) - sample_len = sample_rate * signal_time - sample_len += min_len - sample_len % min_len - sample_len = int(sample_len) + # min_len = 2 * sample_rate / (1e3) + # sample_len = sample_rate * signal_time + # sample_len += min_len - sample_len % min_len + # sample_len = int(sample_len) t = np.arange(sample_len) / sample_rate t += t[1] signal = phi + omega * t phi_end = signal[-1] signal = amp * np.sin(signal) - return signal.astype(np.int16), phi_end + return signal.astype(np.int16) def create_move_then_back(omega_i, omega_f, sample_rate, move_time, stay_time):