Script execution
This commit is contained in:
156
script/Electric_field_loop.py
Normal file
156
script/Electric_field_loop.py
Normal file
@@ -0,0 +1,156 @@
|
||||
import os
|
||||
import traceback
|
||||
import thread
|
||||
import time
|
||||
|
||||
#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 = 28;
|
||||
dB = Max/No_of_steps;
|
||||
|
||||
Noavg = 5;
|
||||
|
||||
|
||||
|
||||
#forward loop
|
||||
|
||||
file_prefix = time.strftime("%y%m%d")
|
||||
filename.open("data"+file_prefix,"a")
|
||||
for i in range(0,No_of_steps):
|
||||
B = -Max +2*i*dB;
|
||||
print "Setting field = ", B
|
||||
caput("X11MA-XMCD:I-SETraw",B)
|
||||
|
||||
temp_tey=[];
|
||||
temp_tey_E2 = [];
|
||||
ADC2_temp_E1=[];
|
||||
ADC1_temp_E1=[];
|
||||
ADC2_temp_E2=[];
|
||||
ADC1_temp_E2=[];
|
||||
|
||||
|
||||
for j in range(0,Noavg):
|
||||
print "Setting energy = ", E1
|
||||
caput(OTF_ESET, E1)
|
||||
wait_channel(OTF_DONE, 1, type = 'i')
|
||||
readback2 = energy.read()
|
||||
sleep(1);
|
||||
detector1 = keithley_1a.read() #Keithley1
|
||||
detector2 = keithley_2a.read() #Keithley2
|
||||
detector4 = caget(OTF_MODE2) #polarization in ID2
|
||||
M1 = detector2/detector1
|
||||
temp_tey=temp_tey+M1;
|
||||
ADC2_temp_E1=ADC2_temp_E1+detector2;
|
||||
ADC1_temp_E1=ADC1_temp_E1+detector1;
|
||||
|
||||
|
||||
print "Setting energy = ", E2
|
||||
caput(OTF_ESET, E1)
|
||||
wait_channel(OTF_DONE, 1, type = 'i')
|
||||
readback2 = energy.read()
|
||||
sleep(2);
|
||||
detector1 = keithley_1a.read() #Keithley1
|
||||
detector2 = keithley_2a.read() #Keithley2
|
||||
detector4 = caget(OTF_MODE2) #polarization in ID2
|
||||
M2 = detector2/detector1
|
||||
temp_tey_E2=temp_tey+M1;
|
||||
ADC2_temp_E2=ADC2_temp_E2+detector2;
|
||||
ADC1_temp_E2=ADC1_temp_E2+detector1;
|
||||
|
||||
|
||||
tey_norm_E1=temp_tey/Noavg;
|
||||
ADC2_E1=ADC2_temp_E1/Noavg;
|
||||
ADC1_E1=ADC1_temp_E1/Noavg;
|
||||
tey_norm_E2=tey_temp_E2/Noavg;
|
||||
ADC2_E2=ADC2_temp_E2/Noavg;
|
||||
ADC1_E2=ADC1_temp_E2/Noavg;
|
||||
tey_norm = tey_norm_E1/tey_norm_E2;#edge/preedge
|
||||
detector4 = caget(OTF_MODE2)
|
||||
filename.write(" %f %f %e %f %e %e %s \n" %(B, E1, ADC2_E1, E2, ADC2_E2, tey_norm, detector4);
|
||||
|
||||
|
||||
#reverse loop
|
||||
|
||||
for i in range(0,No_of_steps):
|
||||
B = Max -2*i*dB;
|
||||
print "Setting field = ", B
|
||||
caput("X11MA-XMCD:I-SETraw",B)
|
||||
|
||||
temp_tey=[];
|
||||
temp_tey_E2 = [];
|
||||
ADC2_temp_E1=[];
|
||||
ADC1_temp_E1=[];
|
||||
ADC2_temp_E2=[];
|
||||
ADC1_temp_E2=[];
|
||||
|
||||
|
||||
for j in range(0,Noavg):
|
||||
print "Setting energy = ", E1
|
||||
caput(OTF_ESET, E1)
|
||||
wait_channel(OTF_DONE, 1, type = 'i')
|
||||
readback2 = energy.read()
|
||||
sleep(1);
|
||||
detector1 = keithley_1a.read() #Keithley1
|
||||
detector2 = keithley_2a.read() #Keithley2
|
||||
detector4 = caget(OTF_MODE2) #polarization in ID2
|
||||
M1 = detector2/detector1
|
||||
temp_tey=temp_tey+M1;
|
||||
ADC2_temp_E1=ADC2_temp_E1+detector2;
|
||||
ADC1_temp_E1=ADC1_temp_E1+detector1;
|
||||
|
||||
|
||||
print "Setting energy = ", E2
|
||||
caput(OTF_ESET, E1)
|
||||
wait_channel(OTF_DONE, 1, type = 'i')
|
||||
readback2 = energy.read()
|
||||
sleep(2);
|
||||
detector1 = keithley_1a.read() #Keithley1
|
||||
detector2 = keithley_2a.read() #Keithley2
|
||||
detector4 = caget(OTF_MODE2) #polarization in ID2
|
||||
M2 = detector2/detector1
|
||||
temp_tey_E2=temp_tey+M1;
|
||||
ADC2_temp_E2=ADC2_temp_E2+detector2;
|
||||
ADC1_temp_E2=ADC1_temp_E2+detector1;
|
||||
|
||||
|
||||
tey_norm_E1=temp_tey/Noavg;
|
||||
ADC2_E1=ADC2_temp_E1/Noavg;
|
||||
ADC1_E1=ADC1_temp_E1/Noavg;
|
||||
tey_norm_E2=tey_temp_E2/Noavg;
|
||||
ADC2_E2=ADC2_temp_E2/Noavg;
|
||||
ADC1_E2=ADC1_temp_E2/Noavg;
|
||||
tey_norm = tey_norm_E1/tey_norm_E2;#edge/preedge
|
||||
detector4 = caget(OTF_MODE2)
|
||||
filename.write(" %f %f %e %f %e %e %s \n" %(B, E1, ADC2_E1, E2, ADC2_E2, tey_norm, detector4);
|
||||
|
||||
filename.close();
|
||||
#plot(data"+file_prefix", title = "2d", xdata = B, ydata = data_y)
|
||||
|
||||
|
||||
|
||||
# plot properties
|
||||
set_preference(Preference.ENABLED_PLOTS, ['energy', 'tey_norm'])
|
||||
set_preference(Preference.PLOT_TYPES, {'tey_norm':1})
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user