106 lines
4.3 KiB
Python
106 lines
4.3 KiB
Python
#Parameters
|
|
|
|
B1 = 10 # starting mag. field in Amps
|
|
B2 = -B1 # final mag. field in Amps
|
|
T1=150 # starting temperature in K
|
|
T2=200 # final temperature in K
|
|
TSTEP=10 # Temperature step size
|
|
ENERGIES = (708.5,705) #list of energies in eV
|
|
|
|
OFFSET1 = -9 #ID1 offset
|
|
OFFSET2 = -8 #ID2 offset
|
|
FIELD_PRECISION = 0.05 # in Amps
|
|
ENERGY_CHANGE_SLEEP = 0.1 # put the Enerrgy settling time if needed
|
|
FIELD_CHANGE_SLEEP = 0.1 # put the Field settling time if needed
|
|
TEMP_CHANGE_SLEEP = 10.0 # put the Temperature settling time if needed
|
|
ACC_TIME = 150.0 # accumulation time s
|
|
|
|
# List of scans.
|
|
STEPS =frange(T1, T2, TSTEP, True)
|
|
|
|
#Pre-actions
|
|
# Here offsets are set
|
|
|
|
caput ("X11PHS-E:OPT","PGM+ID2")
|
|
#caput(OTF_OFF1,-50) #detune ID1
|
|
caput(OTF_OFF2,OFFSET2)
|
|
wait_channel(OTF_DONE, 1, type = 'i')
|
|
#cawait("X11MA-PHS:ALL-DONE",1.0)
|
|
|
|
|
|
wait_channel(OTF_DONE, 1, type = 'i')
|
|
|
|
|
|
# setting number of samples to be averaged, which depends on the accumulation time
|
|
avg = ACC_TIME * 10
|
|
caputq("X11MA-ES1-10ADC:AVG",avg)
|
|
|
|
|
|
# plot properties
|
|
set_preference(Preference.ENABLED_PLOTS, ['field', 'tey_norm'])
|
|
set_preference(Preference.PLOT_TYPES, {'tey_norm':1})
|
|
|
|
#scan = ManualScan(['field', 'Energy'], ['TEY', 'I0', 'polarization', 'temperature', 'RingCurrent', 'tey_norm'] , [min(setpoints), min(ENERGIES)], [max(setpoints), max(ENERGIES)], [len(setpoints)-1, len(ENERGIES)-1])
|
|
scan = ManualScan(['field', 'Energy','Temperature'], ['I0', 'TEY', 'TFY', 'polarization', 'temperature', 'RingCurrent', 'tey_norm','tfy_norm'] , [min([B1,B2]), min(ENERGIES),min(STEPS)], [max([B1,B2]), max(ENERGIES),max(STEPS)], [1, len(ENERGIES)-1, len(STEPS)-1])
|
|
scan.start()
|
|
|
|
# Main loop
|
|
for T in STEPS:
|
|
# set Temperature
|
|
caputq(OTF_MODE2,1) # already set the polarization
|
|
caput("X11MA-XMCD:I-SETraw",B1)# warm in B1
|
|
caput('X11MA-ES3-LSCI:TEMP.VAL',T)
|
|
# while not caget('X11MA-ES3-LSCI:TEMP-STAT'):
|
|
#time.sleep(5)
|
|
time.sleep( TEMP_CHANGE_SLEEP ) # Settling time
|
|
#Mode loop:
|
|
for MODE in [1,2]: #polarization (CIRC+ -> 1 or CIRC- -> 2)
|
|
caput(OTF_MODE2,MODE)
|
|
#Field loop
|
|
for B in [B1,B2]:
|
|
print "Setting field = ", B
|
|
caput("X11MA-XMCD:I-SETraw",B)
|
|
time.sleep( FIELD_CHANGE_SLEEP ) # Settling time
|
|
|
|
readback1 = caget("X11MA-XMCD:Ireadout")
|
|
|
|
while abs(readback1-B) > FIELD_PRECISION:
|
|
readback1 = caget("X11MA-XMCD:Ireadout")
|
|
time.sleep(0.5)
|
|
|
|
for E in ENERGIES:
|
|
print "Setting energy = ", E
|
|
caput(OTF_ESET, E)
|
|
wait_channel(OTF_DONE, 1, type = 'i')
|
|
readback2 = energy.read()
|
|
if abs(readback2 - E) > 0.1 : # TODO: Check accuracy
|
|
raise Exception('Energy could not be set to the value ' + str(E))
|
|
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
|
caput("X11MA-ES1-10ADC:TRG.PROC",1) # accumulate
|
|
time.sleep( 0.1) # wait a bit more
|
|
detector1 = keithley_1a.read() #Keithley1
|
|
detector2 = keithley_2a.read() #Keithley2
|
|
detector3 = keithley_3a.read() #Keithley3
|
|
detector4 = caget(OTF_MODE2) #polarization in ID2
|
|
#detector5 = caget("X11MA-ID2:ALPHA-READ") # polAngle in ID2
|
|
detector6 = caget('X11MA-ES3-LSCI:TEMP_RBV') #temperature.get()
|
|
detector7 = caget("ARIDI-PCT:CURRENT")
|
|
#detector8 = signal_field_analog_x.read() # fieldAnalogX.get()
|
|
tey_norm = detector2/detector1
|
|
tfy_norm = detector3/detector1
|
|
|
|
#converting polarization strings to integer numbers: C+ -> 1 and C- -> 2
|
|
if detector4 == 'CIRC +': detector4 = 1
|
|
elif detector4 == 'CIRC -': detector4 = 2
|
|
else: detector4 = 0
|
|
readback3=caget('X11MA-ES3-LSCI:TEMP_RBV') # read temperature
|
|
#scan.append ([B, E], [readback1, readback2], [detector1, detector2, detector4, detector6, detector7, tey_norm])
|
|
scan.append ([B, E, T], [readback1, readback2, readback3], [detector1, detector2, detector3, detector4, detector6, detector7, tey_norm, tfy_norm])
|
|
|
|
scan.end()
|
|
caput("X11MA-ES1-10ADC:AVG",1)
|
|
|
|
|
|
print "Wake up its done"
|
|
print("Success")
|