From 7dfbbcb42cc1b2bcd1d0510cd2e7f950fb771bc0 Mon Sep 17 00:00:00 2001 From: X11MA Date: Wed, 8 Mar 2017 11:12:42 +0100 Subject: [PATCH] Startup --- script/Sridhar/field_sweepID2.py | 93 +++++++++++++++++++++++++++++++ script/Sridhar/field_sweep_old.py | 87 +++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 script/Sridhar/field_sweepID2.py create mode 100644 script/Sridhar/field_sweep_old.py diff --git a/script/Sridhar/field_sweepID2.py b/script/Sridhar/field_sweepID2.py new file mode 100644 index 0000000..022a433 --- /dev/null +++ b/script/Sridhar/field_sweepID2.py @@ -0,0 +1,93 @@ +#Parameters +''' +B1 = 20 # starting mag. field in Amps +B2 = -20 # final mag. field in Amps +BSTEP = 0.5 # step size mag. field in Amps +ENERGIES = (707.35, 722.35) #list of energies in eV +MODE = 1 #polarization (CIRC+ -> 1 or CIRC- -> 2) +OFFSET1 = -9 #ID1 offset +OFFSET2 = -9.50 #ID2 offset +FIELD_PRECISION = 0.05 # in Amps +ENERGY_CHANGE_SLEEP = 0.0 # put the Enerrgy settling time if needed +FIELD_CHANGE_SLEEP = 0.0 # put the Field settling time if needed +ACC_TIME = 1.0 # accumulation time +''' +# List of scans. Each scan is defined as: (start,stop, step) +# to make a whole loop two scans are needed: [(B1, B2, BSTEP),(B2,B1,-BSTEP)] +# to make half of a loop one scan is needed: [(B1, B2, BSTEP),] <- don't forget to put comma before ] +RANGES = [(B1, B2, -BSTEP),(B2,B1,BSTEP)] + + +#Pre-actions +# Here polarization and offsets are set + +caput ("X11PHS-E:OPT","PGM+ID2") +caput(OTF_OFF1,OFFSET1) #detune ID1 +caput(OTF_OFF2,OFFSET2) +wait_channel(OTF_DONE, 1, type = 'i') + +if MODE is 1 or 2: + caput(OTF_MODE2,MODE) +else: + raise Exception("Invalid polarization type: " + MODE) + +wait_channel(OTF_DONE, 1, type = 'i') + + +# setting number of samples to be averaged, which depends on the accumulation time +avg = ACC_TIME * 10 +caput("X11MA-ES1-10ADC:AVG",avg) + +# Generating a list of mag. fields (setpoints) needed for the loop +setpoints = [] +for r in RANGES: + setpoints = setpoints + frange(r[0], r[1], r[2], True) + +# 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.start() + +# Main loop +for B in setpoints: + 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 + + 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 + + scan.append ([B, E], [readback1, readback2], [detector1, detector2, detector4, detector6, detector7, tey_norm]) + +scan.end() +caput("X11MA-ES1-10ADC:AVG",1) \ No newline at end of file diff --git a/script/Sridhar/field_sweep_old.py b/script/Sridhar/field_sweep_old.py new file mode 100644 index 0000000..bd709d7 --- /dev/null +++ b/script/Sridhar/field_sweep_old.py @@ -0,0 +1,87 @@ +#Parameters +''' +B1 = 20 # starting mag. field in Amps +B2 = -20 # final mag. field in Amps +BSTEP = 0.5 # step size mag. field in Amps +ENERGIES = (707.35, 722.35) #list of energies in eV +MODE = 2 #polarization (CIRC+ -> 1 or CIRC- -> 2) +OFFSET1 = -9 #ID1 offset +OFFSET2 = -9.50 #ID2 offset +FIELD_PRECISION = 0.05 # in Amps +ENERGY_CHANGE_SLEEP = 0.0 # put the Enerrgy settling time if needed +FIELD_CHANGE_SLEEP = 0.0 # put the Field settling time if needed +''' +# List of scans. Each scan is defined as: (start,stop, step) +# to make a whole loop two scans are needed: [(B1, B2, BSTEP),(B2,B1,-BSTEP)] +# to make half of a loop one scan is needed: [(B1, B2, BSTEP),] <- don't forget to put comma before ] +RANGES = [(B1, B2, -BSTEP),(B2,B1,BSTEP)] + + +#Pre-actions +# Here polarization and offsets are set + +caput ("X11PHS-E:OPT","PGM+ID2") +caput(OTF_OFF1,OFFSET1) #detune ID1 +caput(OTF_OFF2,OFFSET2) +wait_channel(OTF_DONE, 1, type = 'i') + +if MODE is 1 or 2: + caput(OTF_MODE2,MODE) +else: + raise Exception("Invalid polarization type: " + MODE) + +wait_channel(OTF_DONE, 1, type = 'i') + +# Generating a list of mag. fields (setpoints) needed for the loop +setpoints = [] +for r in RANGES: + setpoints = setpoints + frange(r[0], r[1], r[2], True) + +# 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.start() + +# Main loop +for B in setpoints: + 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 + + 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 + + scan.append ([B, E], [readback1, readback2], [detector1, detector2, detector4, detector6, detector7, tey_norm]) + +scan.end() +