RANGES = [(B1, B2, BSTEP),(B2,B1,-BSTEP)] Bpoints = [] for r in RANGES: Bpoints = Bpoints + frange(r[0], r[1], r[2], True) scan = ManualScan(['Energy', 'Mag.'], ['I0', 'TEY', 'TFY'] , [min(ENERGIES), min(Bpoints)], [max(ENERGIES), max(Bpoints)], [len(ENERGIES)-1, len(Bpoints)-1]) scan.start() for E in ENERGIES: print "Setting energy = ", E caput(OTF_ESET, E) wait_channel(OTF_DONE, 1, type = 'i') readback1 = energy.read() if abs(readback1 - E) > 0.1 : # TODO: Check accuracy raise Exception('Energy could not be set to the value ' + str(E)) sleep( 1 ) # Settling time for B in Bpoints: print "Setting field = ", B caput("X11MA-XMCD:I-SETraw",B) time.sleep( FIELD_CHANGE_SLEEP ) # Settling time 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 scan.append ([E, B], [readback1, readback2], [detector1, detector2, detector3]) scan.end()