def run(self): wlm = wlm_web() global data data = [[0] * data_len] * 8 count = 0 while True: count += 1 wlm_data = wlm.get_data() for i in range(8): data[i] = data[i][1:] + [round(wlm_data[i], 6)] # print('wavelength is %.6f' % wlm_data[3]) # print(T_value, P_value) time.sleep(0.1)
from scipy.optimize import curve_fit from save_data import save_file from progressbar import * import matplotlib.pyplot as plt from wlm_web import wlm_web import time from image_processing import has_ion from ttl_client import shutter from current_client import current_web # from load_ion_client import reload_ion if os.name == "nt": import msvcrt wm = wlm_web() curr = current_web() shutter_370 = shutter(com=0) flip_mirror = shutter(com=1) shutter_399 = shutter(com=2) ccd_on = flip_mirror.off pmt_on = flip_mirror.on def reload_ion(): t1 = time.time() print('RELOADING...') pmt_on() time.sleep(0.3)
def run(self): # dds_435 = dds_controller() # flip_time = 75 # microwave_fre = 400.0 self.pre_set() wm = wlm_web() init_fre = 103 lock_point = 871.034931 N = 4000 # progressbar widgets = ['Progress: ',Percentage(), ' ', Bar('#'),' ', Timer(), ' ', ETA(), ' '] pbar = ProgressBar(widgets=widgets, maxval=10*N).start() file_name = 'data\\'+str(init_fre)+'-'+str(float(init_fre+N*0.0005))+'.csv' file = open(file_name,'w+') file.close() data = np.zeros((4,N)) for i in range(N): file = open(file_name,'a') AOM_435 =init_fre+0.0005*i #- 0.001*N/2 wl_871 = wm.get_data()[0] is_871_locked = abs(wl_871-lock_point) < 0.000004 while not is_871_locked: time.sleep(5) wl_871 = wm.get_data()[0] is_871_locked = abs(wl_871-lock_point) < 0.000004 code = "conda activate base && python dds.py " + str(AOM_435) os.system(code) temp = self.run_sequence() data[0,i]=AOM_435 # accuracy data[1,i]=temp[0]*2 # count data[2,i]=temp[1] data[3,i]=wm.get_data()[0] print("Accuracy:%.1f%%" % (temp[0]*2)) print('Photon Count:%d' % temp[1]) pbar.update(10*i+1) print('\n') content =str(data[0,i])+','+str(data[1,i])+','+str(data[2,i])+','+str(data[3,i])+'\n' # print(content) file.write(content) file.close() np.save('microwave',data) file.close() save_file(data,__file__[:-3]) plt.figure(1) ax1 = plt.subplot(121) ax1.plot(data[0],data[1]) ax2 = plt.subplot(122) ax2.plot(data[0],data[2]) plt.show()