import os import traceback #Parameters """ E1 = 680 E2 = 750 TIME = 2 #min DELAY = 10.0 #s OFFSET1 = 1.0 #eV OFFSET2 = -1.0 #eV PREFIX = 'Data' RUNTYPE = "+/-" """ print "\nStarting energy scan - Parameters: ", print E1,E2,TIME,DELAY,OFFSET1,OFFSET2,PREFIX,RUNTYPE #,ALPHA #fid = caget(OTF_FID, 'i') def switchpol(activeID): global pol_str if activeID == 1: caput(OTF_OFF1,OFFSET1) caput(OTF_OFF2,OFFSET2-40) #detune ID2 pol_str = "circ +" elif activeID == 2: caput(OTF_OFF1,OFFSET1-40) #detune ID1 caput(OTF_OFF2,OFFSET2) pol_str = "circ -" else: raise Exception("Invalid parameter") pol_str = None polswitch = 1 input_path = "/sls/X11MA/Data1/public/X11MA/temp/" output_path = input_path file_prefix = time.strftime("%y%m%d") fid = get_next_fid(input_path, "o" + file_prefix) suffix = ("%03d" % fid) input_file = input_path + "o" + file_prefix + "_" + suffix + ".dat" #Prepare scan if RUNTYPE == "+/-": caput(OTF_MODE1,1) # circ + in ID1 caput(OTF_MODE2,2) # circ - in ID2 wait_channel(OTF_DONE, 1, type = 'i') else: raise Exception("Invalid run type: " + RUNTYPE) switchpol(1) # tune ID1 --> polarization: C+ time.sleep(1.0) wait_channel(OTF_DONE, 1, type = 'i') open_vg10() for rounds in [1,2]: caput(OTF_E1, E1) caput(OTF_E2, E2) caput(OTF_TIME, TIME) #fid = fid + 1 caput(OTF_FTS,file_prefix) caput(OTF_FID,fid) time.sleep(2.0) caput(OTF_ESET, E1) wait_channel(OTF_DONE, 1, type = 'i') #??? time.sleep(DELAY) time.sleep(2.0) #Start the OTF scan caput(OTF_START, 'GO') #Wait until scan is done wait_channel(OTF_START, 'STOP', type = 's') time.sleep(3.0) #Convert file output_file = output_path+"os"+file_prefix+"_" + suffix + ".dat" print("Converting data file: " + output_file); convert_file(input_file, output_file, pol_str) plot_file(output_file, "Scan " + str(rounds)) if polswitch == 1: switchpol(2) # tune ID2 --> polarization:C- polswitch = 0 else: polswitch = 1 time.sleep(3.0) close_vg10() print "Finished Energy scan" print("Success")