diff --git a/script/Sridhar/EnergyScanID2only.py b/script/Sridhar/EnergyScanID2only.py new file mode 100644 index 0000000..e68e012 --- /dev/null +++ b/script/Sridhar/EnergyScanID2only.py @@ -0,0 +1,178 @@ +import os +import traceback +import thread + +############################################################################### +# Plotting +############################################################################### + +task = None +running = False + + +def _startPlot(type): + global running + print "Starting plot: type " + str(type) + running = True + p = plot(None,name="Energy")[0] + s = p.getSeries(0) + cur = 0 + time.sleep(3.0) + while running: + try: + if otf_start.read() == 0: + break + e = energy.read() + if (abs(e-cur)) > 0.1: + v = abs((keithley_2a.read() / ((keithley_1a if (type==1) else keithley_3a).read() ))) + s.appendData(e,v) + cur = e + time.sleep(0.2) + except: + pass + print "Done Plotting" + +def startPlot(type = 1): + global task + task = fork((_startPlot,(type,)),) + +def stopPlot(): + global task, running + running = False + ret = join(task) + +############################################################################### +# Parameters +############################################################################### + +''' +E1 = 680 +E2 = 690 +TIME = 0.5 #min +DELAY = 10.0 #s +PREFIX = 'Data' +RUNTYPE = "+/-" +ROUNDS = 1 +OFFSETp = 0.0 +OFFSETm = 0.0 +PLOT_TYPE = 1 +''' + +print "\nStarting energy scan - Parameters: ", +print E1,E2,TIME,DELAY,RUNTYPE + +file_prefix = time.strftime("%y%m%d") +input_path = "/sls/X11MA/Data1/public/X11MA/temp/"+file_prefix+"/" +output_path = input_path #+file_prefix+"/" #"/sls/X11MA/Data1/public/e10989/"+file_prefix+"/" +pol_str = None +mag_str = None +fid = get_next_fid(input_path, "o" + file_prefix) +number_of_scans = 1 + +############################################################################### +#Prepare scan for PGM+ID2 +############################################################################### + +caput ("X11PHS-E:OPT","PGM+ID2") +caput(OTF_OFF1,-50) #detune ID1 +wait_channel(OTF_DONE, 1, type = 'i') + +if RUNTYPE in ["+/-", "+", "-"]: + if RUNTYPE == "+": + caput(OTF_MODE2,1) # circ+ in ID2 + caput(OTF_OFF2,OFFSETp) + number_of_scans = ROUNDS + elif RUNTYPE == "-": + caput(OTF_MODE2,2) # circ- in ID2 + caput(OTF_OFF2,OFFSETm) + number_of_scans = ROUNDS + elif RUNTYPE == "+/-": + caput(OTF_MODE2,1) # circ+ in ID2 + caput(OTF_OFF2,OFFSETp) + number_of_scans = 2 * ROUNDS + wait_channel(OTF_DONE, 1, type = 'i') + +elif RUNTYPE in ["LH/LV", "LH", "LV"]: + print "Wrong polarization selected!" + + +else: + raise Exception("Invalid run type: " + RUNTYPE) + +open_vg10() +time.sleep(0.5) +open_vg11() +time.sleep(0.5) +open_vg12() +time.sleep(0.5) +open_vg13() + +############################################################################### +#Main scan loop +############################################################################### + +for scan_no in range(number_of_scans): + suffix = ("%03d" % fid) + input_file = input_path + "o" + file_prefix + "_" + suffix + ".dat" + + caput(OTF_E1, E1) + caput(OTF_E2, E2) + caput(OTF_TIME, TIME) + caput(OTF_FTS,file_prefix) + caput(OTF_FID,fid) + time.sleep(2.0) + caput(OTF_ESET, E1) + wait_channel(OTF_DONE, 1, type = 'i') + time.sleep(DELAY) + time.sleep(2.0) + + startPlot(PLOT_TYPE) + otf_start.write(1) #Start the OTF scan + time.sleep(3.0) + print "Running scan " + str(scan_no+1) + " out of " + str(number_of_scans) + try: + #wait_channel(OTF_START, 'STOP', timeout = int(TIME*60), type = 's') + otf_start.waitValue(0, (15 + int(TIME*60)) *1000) + except: + print "******** OTF STOP TIMEOUT **********" + otf_start.write(0) + finally: + stopPlot() + + time.sleep(5.0) + #TODO: wait for file instead of sleep + #Convert file + output_file = output_path + "os" + file_prefix + "_" + suffix + ".dat" + + + + if RUNTYPE in ["+/-"]: + pol_str = caget(OTF_MODE2) + if pol_str == "CIRC +": + caput(OTF_MODE2,2) # circ- in ID2 + caput(OTF_OFF2,OFFSETm) + elif pol_str == "CIRC -": + caput(OTF_MODE2,1) # circ+ in ID2 + caput(OTF_OFF2,OFFSETp) + else: print "Check pol. change" + wait_channel(OTF_DONE, 1, type = 'i') + else: + print "running in one polarization mode, no switching" + pol_str = caget(OTF_MODE2) + + print("Converting data file: " + output_file); + mag_str = caget(MAG) + convert_file(input_file, output_file, mag_str, pol_str) + plot_file(output_file, file_prefix+"_" + suffix) #"Scan " + str(scan_no+1)) + print "Finished scan " + str(scan_no+1) + " out of " + str(number_of_scans) + + time.sleep(3.0) + fid = fid + 1 + +caput(OTF_ESET, E1) +close_vg13() + +print "Finished Energy scan" + +print("Success") + diff --git a/script/Sridhar/field_sweepID1.py b/script/Sridhar/field_sweepID1.py new file mode 100644 index 0000000..2206b31 --- /dev/null +++ b/script/Sridhar/field_sweepID1.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 = 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 +''' +# 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+ID1") +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() + diff --git a/script/Sridhar/harmonic_ID1.xml b/script/Sridhar/harmonic_ID1.xml new file mode 100644 index 0000000..29f0df0 --- /dev/null +++ b/script/Sridhar/harmonic_ID1.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + 710.0 + 730.0 + 0.5 + + + + + + + + + + + + + diff --git a/script/Sridhar/harmonic_ID2.xml b/script/Sridhar/harmonic_ID2.xml new file mode 100644 index 0000000..5af1678 --- /dev/null +++ b/script/Sridhar/harmonic_ID2.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + 710.0 + 730.0 + 0.5 + + + + + + + + + + + + + diff --git a/script/Sridhar/xmcdID1&ID2.py b/script/Sridhar/xmcdID1&ID2.py new file mode 100644 index 0000000..45ced91 --- /dev/null +++ b/script/Sridhar/xmcdID1&ID2.py @@ -0,0 +1,71 @@ + +E1 = 690 +E2 = 760 +TIME = 3 #min +DELAY = 10.0 #s +PREFIX = 'Data' +OFFSETp = -9 +OFFSETm = -8 +PLOT_TYPE = 1 + +RUNTYPE = "+" +ROUNDS = 1 +run("Sridhar/EnergyScanID1only") + +RUNTYPE = "-" +ROUNDS = 1 +run("Sridhar/EnergyScanID2only") + +RUNTYPE = "-" +ROUNDS = 1 +run("Sridhar/EnergyScanID2only") + +RUNTYPE = "+" +ROUNDS = 1 +run("Sridhar/EnergyScanID1only") + + +''' +RUNTYPE = "-" +ROUNDS = 1 +run("EnergyScanID2only") + +RUNTYPE = "+" +ROUNDS = 1 +run("EnergyScanID2only") + +RUNTYPE = "+" +ROUNDS = 1 +run("EnergyScanID2only") + +RUNTYPE = "-" +ROUNDS = 1 +run("EnergyScanID2only") + +RUNTYPE = "-" +ROUNDS = 1 +run("EnergyScanID2only") + +RUNTYPE = "+" +ROUNDS = 1 +run("EnergyScanID2only") + +''' + +''' +E1 = 690 +E2 = 700 +TIME = 0.5 #min +DELAY = 10.0 #s +OFFSET1 = -9.7 #eV +OFFSET2 = -12 #eV +PREFIX = 'Sample2_ID1ID2' +RUNTYPE = "+/-" +ROUNDS = 1 +PLOT_TYPE = 1 +SET_OFFSETS=0 +ID1=0 +ID2=0 + +run("EnergyScan") +''' \ No newline at end of file diff --git a/script/harmonic_ID2.xml b/script/harmonic_ID2.xml new file mode 100644 index 0000000..6c56b96 --- /dev/null +++ b/script/harmonic_ID2.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + 710.0 + 730.0 + 0.5 + + + + + + + + + + + + + diff --git a/script/harmonic_xtreme.xml b/script/harmonic_xtreme.xml new file mode 100644 index 0000000..8be0dce --- /dev/null +++ b/script/harmonic_xtreme.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + 570.0 + 590.0 + 0.5 + + + + + + + + + + + + + + + + + + +