def ex01(): hla.machines.use('LTB-txt') #elem = hla.getElements('P1') #print elem._field #print hla.getOrbit() #print [e.name for e in hla.getNeighbors('PH2G6C25B', 'P*C10*', 2)] #print [e.sb for e in hla.getNeighbors('PH2G6C25B', 'P*C10*', 2)] print hla.getOrbit() print hla.getOrbit('P*') print hla.getOrbit('*') print hla.getOrbit('P*C10*')
import hla import matplotlib.pylab as plt import numpy as np if __name__ == '__main__': # initialize when no real machine exists hla.initNSLS2VSR() hla.machines.use('SR') # orbit at cell 3-6 BPMs bpm = hla.getElements('P*C0[3-6]*') s1 = [b.sb for b in bpm] x1 = [b.x for b in bpm] y1 = [b.y for b in bpm] allbpms = hla.getElements('BPM') s2x = [b.sb for b in allbpms] # for each element, do data acquisition to b.x and b.y (slow) #obt = np.array([(b.x, b.y) for b in allbpms], 'd') # get the orbit and locations of BPMS: (x,y,s) obt2 = np.array(hla.getOrbit(spos = True), 'd') plt.clf() plt.plot(s1, x1, 'x-') #plt.plot(s2x, obt[:,0], '--') plt.plot(obt2[:,-1], obt2[:,0], '--') plt.savefig('orbit.png')
if __name__ == '__main__': ex04() sys.exit(0) print "reset the trims:" trim1 = [e.pv(tags=[hla.machines.HLA_TAG_X, hla.machines.HLA_TAG_EPUT]) for e in hla.getElements('HCOR')] trim2 = [e.pv(tags=[hla.machines.HLA_TAG_Y, hla.machines.HLA_TAG_EPUT]) for e in hla.getElements('VCOR')] hla.catools.caput(trim1+trim2, [0.0]*(len(trim1) + len(trim2))) time.sleep(4) v0 = hla.getOrbit('P*', spos=True) ## part #bpm = hla.getElements('P*C1[12]*') #trimx = hla.getGroupMembers(['C1[0-9]', 'HCOR'], op='intersection') #trimy = hla.getGroupMembers(['C1[0-9]', 'VCOR'], op='intersection') #hla.correctOrbit([e.name for e in bpm], [e.name for e in trimx], plane='H') #time.sleep(4) #hla.correctOrbit([e.name for e in bpm], [e.name for e in trimy], plane='V') #time.sleep(4) bpm = hla.getElements('P*') trim = hla.getGroupMembers(['*', '[HV]COR'], op='intersection') print "BPM=", len(bpm), " Trim=", len(trim) hla.correctOrbit([e.name for e in bpm], [e.name for e in trim]) time.sleep(4)