def test_noise(step_size=0.00005, tlen=1.00, max_freq=20e3): samp_rate = 1.0 / step_size nf = NoiseWaveform(samp_rate=samp_rate, max_freq=max_freq) t = np.arange(0.0, tlen, step_size) state = [] for ti in t: s = nf.next() state.append(s) state = np.array(state) play_signal(state, samp_rate)
def plot_pulse(step_size=0.00005, tlen=0.010, T0=9.0, Ee=750.0, Rg=1.0, Rk=0.40, Ra=0.05): lf = LFWaveform(step_size) lf.configure_params(T0, Ee, Rg, Rk, Ra) print lf.params t = np.arange(0.0, tlen, step_size) state = [] for ti in t: s = lf.next() state.append(s) state = np.array(state) Ufft = np.fft.fft(state[:, 0]) Ufreq = np.fft.fftfreq(len(Ufft), d=step_size) dUfft = np.fft.fft(state[:, 1]) dUfreq = np.fft.fftfreq(len(Ufft), d=step_size) ftitle = '$T_0=%0.1f, E_e=%d, R_g=%0.2f, R_k=%0.2f, R_a=%0.2f, \Delta t=%0.6f$' % (T0, Ee, Rg, Rk, Ra, step_size) twin = min(tlen, 0.075) tsamps = int(twin / step_size) plt.figure() plt.subplot(2, 1, 1) plt.plot(t[:tsamps], state[:tsamps, 0], 'g-', linewidth=2.0) plt.axhline(color='k') plt.axis('tight') plt.title('$U(t)$') plt.subplot(2, 1, 2) plt.plot(t[:tsamps], state[:tsamps, 1], 'b-', linewidth=2.0) plt.axhline(color='k') plt.title('$dU(t)$') plt.axis('tight') plt.suptitle(ftitle) plt.figure() plt.subplot(2, 1, 1) ph = (Ufreq >= 0.0) & (Ufreq <= 4000.0) plt.plot(Ufreq[ph], np.abs(Ufft[ph]), 'g-', linewidth=2.0) plt.title('$|U(\omega)|$') plt.axis('tight') plt.subplot(2, 1, 2) ph = (Ufreq >= 0.0) & (Ufreq <= 4000.0) plt.plot(dUfreq[ph], np.abs(dUfft[ph]), 'b-', linewidth=2.0) plt.title('$|dU(\omega)|$') plt.axis('tight') plt.suptitle(ftitle) play_signal(state[:, 1], 1.0 / step_size)