def load(self): positionsList=[] for scannable in self.listOfScannables: pos1 = self.config.getProperty(scannable.getName()) pos([scannable, pos1]) positionsList.append(pos1) return positionsList
def scan_fpitch(start, step, n): posns = [] izeros = [] pos(fpitch2, start) sleep(1) less = 0 for i in range(n): posn = start + step * i pos(fpitch2, posn) sleep(0.12) posns.append(posn) caput("BL11I-EA-COUNT-01.CNT", 1) sleep(0.12) izero = Io.getPosition() izeros.append(izero) if len(izeros) < 3: continue if izeros[-1] > izeros[-2]: less = 0 else: less += 1 if less > 5: break return (posns, izeros)
def returnToInitialPositions(self, initialPositionsDict): for scannable in initialPositionsDict.keys(): # to ensure nothing is moving even in case the scan is interrupted scannable.waitWhileBusy() posargs = reduce(operator.add, initialPositionsDict.items()) pos(posargs)
def __call__(self): for scannable in self.scannables: print pos(scannable)
print "Creating reffile and setting crystal" reffile('dummy_test_with_cubic') mode euler 1 latt([1,1,1,90,90,90]) print "Moving Energy..." #pos energy 12.398 #moves bragg, undulator, mirros, diffractometer, optics table print "...complete" print "Going to first 001" c2th([0,0,1]) pos delta c2th([0,0,1]) eta c2th([0,0,1])/2 pos() mu 0 gam 0 pos phi 0 saveref('001',[0,0,1]) ubm('001',[1,0,0]) # assumes [1,0,0] is in the vertical plane, and determines azimuth normallly found from or2 #array('d',[-0.9999723587733832, 0.007435165380914164, 2.2260001343412905E-6, -0.00743516540177009, -0.9999723587304612, -9.51241620544971E-6, 2.1552122170511666E-6, -9.528703949842119E-6, 0.9999999999522796]) hkl_calc([0,1,1]) print "Going to first 011" pos hkl [0 1 1] # Normaly scan phi to find reflection pos phi saveref('011',[0,1,1]) ubm('001','011')
if less > 5: break return (posns, izeros) # scan fine pitch (coarse) posns, izeros = scan_fpitch(start, step, n) # scan fine pitch (fine) step = step / 20.0 index = izeros.index(max(izeros)) start = posns[index] - (n * step * 0.8) posns, izeros = scan_fpitch(start, step, n) # move to maximum maximum = posns[izeros.index(max(izeros))] pos(fpitch2, maximum) print "Optimisation max Izero: %.1f cts" % max(izeros) print "Optimisation fpitch2 value: %.3f mDeg" % maximum ''' print "Moving slit blades in" pos s4ygap ysize diff = float(caget("BL11I-AL-SLITS-04:Y:PLUS:I")) - float(caget("BL11I-AL-SLITS-04:Y:MINUS:I")) sum = abs(float(caget("BL11I-AL-SLITS-04:Y:PLUS:I"))) + abs(float(caget("BL11I-AL-SLITS-04:Y:MINUS:I"))) / 2 while abs(diff) > 0.02: print diff / sum * 0.2 p = s4ycentre.getPosition() + (diff / sum * 0.2) pos s4ycentre p diff = float(caget("BL11I-AL-SLITS-04:Y:PLUS:I")) - float(caget("BL11I-AL-SLITS-04:Y:MINUS:I")) sum = abs(float(caget("BL11I-AL-SLITS-04:Y:PLUS:I")) + float(caget("BL11I-AL-SLITS-04:Y:MINUS:I"))) / 2 '''