def speed_test(host, n_pts=1000): time_array = np.zeros(n_pts) client = load_instrument(host, instrument='oscillo') driver = Oscillo(client) driver.set_averaging(False) t0 = time.time() t_prev = t0 for i in range(n_pts): if cmd == 'get_adc': driver.get_adc() elif cmd == 'get_num_average': driver.get_num_average() t = time.time() time_array[i] = t - t_prev print host, i, time_array[i] t_prev = t print np.median(time_array) plt.plot(time_array) driver.close()
def speed_test(host, n_pts=1000): time_array = np.zeros(n_pts) client = load_instrument(host, instrument='oscillo') driver = Oscillo(client) driver.set_averaging(False) t0 = time.time() t_prev = t0 for i in range(n_pts): if cmd == 'get_adc': driver.get_adc() elif cmd == 'get_num_average': driver.get_num_average() t = time.time() time_array[i] = t - t_prev print host, i, time_array[i] t_prev = t print np.median(time_array) plt.plot(time_array) driver.close()
diff = diff_pos + diff_neg/2 data = np.roll(data, -1, axis=0) temperature = temperature + 0.015 * diff / (2*np.pi) data[-1] = temperature string = str(time.time())+','+str(temperature)+'\n' f.write(string) print(string) phase_previous_pos = phase_pos phase_previous_neg = phase_neg f.close() driver.stop_laser() driver.close() plt.show() # Plot temperature temperature_data = np.genfromtxt('temperature.csv', delimiter=',') n_pts = len(temperature_data[:,0]) time = temperature_data[:,0]-temperature_data[0,0] T = time[-1] f_fft = np.arange(n_pts/2 + 1) / T temperature = temperature_data[:,1]
driver.start_laser() # Set laser current current = 30 # mA driver.set_laser_current(current) # Modulation on DAC amp_mod = 0.2 freq_mod = 1e6 driver.dac[1, :] = amp_mod*np.sin(2 * np.pi * freq_mod * driver.sampling.t) driver.set_dac() # Signal on ADC driver.get_adc() signal = driver.adc[0, :] # Plot plt.plot(driver.sampling.t, signal) plt.show() # Plot psd_signal = np.abs(np.fft.fft(signal)) ** 2 plt.semilogy(1e-6 * np.fft.fftshift(driver.sampling.f_fft), np.fft.fftshift(psd_signal)) plt.xlabel('Frequency (MHz)') plt.show() # Disable laser driver.stop_laser() driver.close()