import os import traceback import thread import time import datetime #ID settings #Set PGM ID2 caput ("X11PHS-E:OPT","PGM+ID2") #set ID2 to C+ caput(OTF_MODE2,1) caput(OTF_OFF2,OFFSETp) E1 = 778 # Edge E2 = 770 #preedge OFFSETp = -1.9 OFFSETm = -1.9 # Voltage/magnetic field setting Max = 14; Min=-Max; No_of_steps = 10; dB = Max/No_of_steps; Noavg = 1; times = 20 V1 = 1; V2 = -14; os.chdir("/sls/X11MA/data/X11MA/beamtime_december/") #forward loop open_vg13() file_prefix = time.strftime("%y%m%d") ts=time.time(); time_prefix = datetime.datetime.fromtimestamp(ts).strftime('%H%M%S') filename=open("data"+file_prefix+time_prefix+".txt","a") #for i in range(0,No_of_steps): # B = -Max + 2*i*dB; # print "Setting field = ", B # caput("X11MA-XMCD:I-SETraw",B) for i in range(0,times): print "Setting field = ", V1 caput("X11MA-XMCD:I-SETraw",V1) print "Setting energy = ", E1 caput(OTF_ESET, E1) wait_channel(OTF_DONE, 1, type = 'i') readback2 = energy.read() sleep(3); detector1 = keithley_1a.read() #Keithley1 detector2 = keithley_2a.read() #Keithley2 detector4 = caget(OTF_MODE2) #polarization in ID2 M1 = float(detector2)/float(detector1) ADC2_E1=detector2; ADC1_E1=detector1; print "Setting energy = ", E2 caput(OTF_ESET, E2) wait_channel(OTF_DONE, 1, type = 'i') readback2 = energy.read() sleep(3); detector1 = keithley_1a.read() #Keithley1 detector2 = keithley_2a.read() #Keithley2 detector4 = caget(OTF_MODE2) #polarization in ID2 M2 = float(detector2)/float(detector1) tey_norm=M1/M2; ADC2_E2=detector2; ADC1_E2=detector1; filename.write(" %f %f %e %f %e %e %s \n" %(V1, E1, ADC2_E1, E2, ADC2_E2, tey_norm, detector4)); print "Setting field = ", V2 caput("X11MA-XMCD:I-SETraw",V2) print "Setting energy = ", E1 caput(OTF_ESET, E1) wait_channel(OTF_DONE, 1, type = 'i') readback2 = energy.read() sleep(3); detector1 = keithley_1a.read() #Keithley1 detector2 = keithley_2a.read() #Keithley2 detector4 = caget(OTF_MODE2) #polarization in ID2 M1 = float(detector2)/float(detector1) ADC2_E1=detector2; ADC1_E1=detector1; print "Setting energy = ", E2 caput(OTF_ESET, E2) wait_channel(OTF_DONE, 1, type = 'i') readback2 = energy.read() sleep(3); detector1 = keithley_1a.read() #Keithley1 detector2 = keithley_2a.read() #Keithley2 detector4 = caget(OTF_MODE2) #polarization in ID2 M2 = float(detector2)/float(detector1) temp_norm=M1/M2; ADC2_E2=detector2; ADC1_E2=detector1; filename.write(" %f %f %e %f %e %e %s \n" %(V2, E1, ADC2_E1, E2, ADC2_E2, tey_norm, detector4)); filename.close(); # plot properties set_preference(Preference.ENABLED_PLOTS, ['energy', 'tey_norm']) set_preference(Preference.PLOT_TYPES, {'tey_norm':1}) print "Data saved in data "+file_prefix+time_prefix+""