90 lines
3.1 KiB
Python
Executable File
90 lines
3.1 KiB
Python
Executable File
#Parameters
|
|
|
|
B = 0.5 # starting mag. field in Amps
|
|
E1 = 750 #start energy
|
|
E2 = 800 #end energy
|
|
dE = 0.5 # energy step size
|
|
MODE = 1 #polarization (CIRC+ -> 1 or CIRC- -> 2)
|
|
OFFSET1 = -0.4 #ID1 offset
|
|
OFFSET2 = -1.9 #ID2 offset
|
|
FIELD_PRECISION = 0.5 # in Amps
|
|
ENERGY_CHANGE_SLEEP = 0.0 # put the Enerrgy settling time if needed
|
|
|
|
|
|
|
|
#Pre-actions
|
|
# Here polarization and offsets are set
|
|
|
|
caput ("X11PHS-E:OPT","PGM+ID2")
|
|
#caput(OTF_OFF1,OFFSET1) #detune ID1
|
|
caput(OTF_OFF2,OFFSET2) #detune ID2
|
|
wait_channel(OTF_DONE, 1, type = 'i')
|
|
|
|
if MODE is 1 or 2:
|
|
# caput(OTF_MODE1,MODE)
|
|
caput(OTF_MODE2,MODE)
|
|
else:
|
|
raise Exception("Invalid polarization type: " + MODE)
|
|
|
|
wait_channel(OTF_DONE, 1, type = 'i')
|
|
|
|
# Generating a list of setpoints needed for the loop
|
|
setpoints = frange(E1,E2,dE,True)
|
|
fields = [B,-B]
|
|
|
|
# plot properties
|
|
set_preference(Preference.ENABLED_PLOTS, ['energy', 'tey_norm'])
|
|
set_preference(Preference.PLOT_TYPES, {'tey_norm':1})
|
|
|
|
scan1 = ManualScan(['Energy', 'Field'], ['TEY', 'I0', 'polarization', 'RingCurrent', 'tey_norm'] , [min(setpoints), min(fields)], [max(setpoints), max(fields)], [len(setpoints)-1, len(fields)-1])
|
|
scan2 = ManualScan(['Energy', 'Field'], ['TEY', 'I0', 'polarization', 'RingCurrent', 'tey_norm'] , [min(setpoints), min(fields)], [max(setpoints), max(fields)], [len(setpoints)-1, len(fields)-1])
|
|
|
|
set_exec_pars(line_plots = ('TEY', 'I0', 'polarization', 'RingCurrent', 'tey_norm'))
|
|
|
|
scan1.start()
|
|
scan2.start()
|
|
|
|
# Main loop
|
|
for E in setpoints:
|
|
print "Setting Energy = ", E
|
|
caput("X11MA-PHS:E_SP",E)
|
|
wait_channel(OTF_DONE, 1, type = 'i') # Settling time
|
|
|
|
readback1 = caget("X11MA-PGM:rbkenergy")
|
|
if abs(readback1 - E) > 0.1 : # TODO: Check accuracy
|
|
raise Exception('Energy could not be set to the value ' + str(E))
|
|
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
|
|
|
for H in fields:
|
|
print "Setting mag. field = ", H
|
|
caput("X11MA-XMCD:I-SETraw",H)
|
|
|
|
readback2 = caget("X11MA-XMCD:Ireadout")
|
|
while abs(readback2-B) > FIELD_PRECISION:
|
|
readback2 = caget("X11MA-XMCD:Ireadout")
|
|
# time.sleep(0.5)
|
|
|
|
detector1 = keithley_1a.read() #Keithley1
|
|
detector2 = keithley_2a.read() #Keithley2
|
|
#detector3 = keithley_3a.read() #Keithley3
|
|
detector4 = caget(OTF_MODE1) #polarization in ID1
|
|
#detector5 = caget("X11MA-ID1:ALPHA-READ") # polAngle in ID1
|
|
#detector6 = caget('X11MA-ES3-LSCI:TEMP_RBV') #temperature.get()
|
|
detector7 = caget("ARIDI-PCT:CURRENT")
|
|
#detector8 = signal_field_analog_x.read() # fieldAnalogX.get()
|
|
tey_norm = detector1/detector2
|
|
#trans_norm = detector3/detector2
|
|
|
|
#converting polarization strings to integer numbers: C+ -> 1 and C- -> 2
|
|
if detector4 == 'CIRC +': detector4 = 1
|
|
elif detector4 == 'CIRC -': detector4 = 2
|
|
else: detector4 = 0
|
|
|
|
if H < 0:
|
|
scan1.append ([E, H], [readback1, readback2], [detector1, detector2, detector4, detector7, tey_norm])
|
|
if H > 0:
|
|
scan2.append ([E, H], [readback1, readback2], [detector1, detector2, detector4, detector7, tey_norm])
|
|
|
|
scan1.end()
|
|
scan2.end()
|