def call_apply(self): #print "apply the orbit" obt = [] jx, jy = 7, 8 for i in range(self.table.rowCount()): x1,err = self.table.item(i, jx).data(Qt.DisplayRole).toFloat() y1,err = self.table.item(i, jy).data(Qt.DisplayRole).toFloat() obt.append([x1, y1]) self.correctOrbitBtn.setEnabled(False) nrepeat = self.repeatbox.value() kw = { "scale": float(self.scalebox.text()), "rcond": float(self.rcondbox.text()) } self.progress.setValue(0) QApplication.processEvents() for i in range(nrepeat): err, msg = setLocalBump(self.bpms, self.cors, obt, **kw) self.progress.setValue(i+1) QApplication.processEvents() if err != 0: QtGui.QMessageBox.critical( self, "Local Orbit Bump", "ERROR: {0}\nAbort.".format(msg), QtGui.QMessageBox.Ok) #self.progress.setValue(0) break self.correctOrbitBtn.setEnabled(True)
def test_local_bump(self): hcor = ap.getElements("HCOR") hcor_v0 = [e.x for e in hcor] vcor = ap.getElements("VCOR") vcor_v0 = [e.y for e in vcor] bpm = ap.getElements("BPM") bpm_v0 = [[e.x, e.y] for e in bpm] bpm_v1 = [[e.x, e.y] for e in bpm] bpm_v1[0] = [0, 0] bpm_v1[1] = [0, 1e-4] bpm_v1[2] = [2e-4, 1e-4] bpm_v1[3] = [5e-7, 1e-4] bpm_v1[4] = [0, 1e-4] bpm_v1[5] = [0, 1e-4] for i in range(6, len(bpm)): bpm_v1[i] = [0, 0] ap.setLocalBump(bpm, hcor + vcor, bpm_v1)
def test_local_bump(self): hcor = ap.getElements('HCOR') hcor_v0 = [e.x for e in hcor] vcor = ap.getElements('VCOR') vcor_v0 = [e.y for e in vcor] bpm = ap.getElements('BPM') bpm_v0 = [[e.x, e.y] for e in bpm] bpm_v1 = [[e.x, e.y] for e in bpm] bpm_v1[0] = [0, 0] bpm_v1[1] = [0, 1e-4] bpm_v1[2] = [2e-4, 1e-4] bpm_v1[3] = [5e-7, 1e-4] bpm_v1[4] = [0, 1e-4] bpm_v1[5] = [0, 1e-4] for i in range(6, len(bpm)): bpm_v1[i] = [0, 0] ap.setLocalBump(bpm, hcor+vcor, bpm_v1)
def test_local_bump(self): hcor = ap.getElements('HCOR') hcor_v0 = [e.x for e in hcor] vcor = ap.getElements('VCOR') vcor_v0 = [e.y for e in vcor] bpm = ap.getElements('BPM') bpm_v0 = [[e.x, e.y] for e in bpm] bpm_v1 = [[e.x, e.y] for e in bpm] for i in range(0, len(bpm)): bpm_v1[i] = [0, 0] x1, x2 = 1e-4, 2e-4 bpm_v1[20][0] = x1 bpm_v1[21][0] = x1 bpm_v1[22][0] = x1 bpm_v1[23][0] = x2 bpm_v1[24][0] = x2 bpm_v1[25][0] = x1 bpm_v1[26][0] = x1 bpm_v1[100][1] = x2 bpm_v1[101][1] = x2 bpm_v1[102][1] = x1 bpm_v1[103][1] = x1 bpm_v1[104][1] = x2 bpm_v1[105][1] = x2 ap.setLocalBump(bpm, hcor+vcor, bpm_v1, repeat=10, verbose=3) import matplotlib.pylab as plt plt.clf() v = ap.getOrbit(spos=True) plt.plot(v[:,-1], v[:,0], '-.') plt.plot(v[:,-1], v[:,1], '--') plt.savefig(figname("test_localbump.png"))
import numpy as np import matplotlib.pylab as plt import time print ap.__path__ ap.initNSLS2V1() bpms = ap.getElements('BPM') #trims = ap.getGroupMembers(['*', '[HV]COR'], op='intersection') trims = ap.getElements('HCOR') + ap.getElements('VCOR') print "Bpms x Trims: (%d, %d)" % (len(bpms), len(trims)) v0 = ap.getOrbit(spos=True) n1, n2 = 130, 150 ap.setLocalBump([e.name for e in bpms[n1:n2]], [e.name for e in trims], np.ones((n2 - n1, 2), 'd') * 1e-5, scale=0.7, repeat=6) #Euclidian norm: ... time.sleep(4) v1 = ap.getOrbit(spos=True) time.sleep(4) v2 = ap.getOrbit(spos=True) # plotting plt.clf() ax = plt.subplot(211) ax.annotate("H orbit before/after correction", (0.03, 0.9), xycoords='axes fraction') ax.plot(v0[:, -1], v0[:, 0], 'r-') ax.plot(v1[:, -1], v1[:, 0], 'g--') ax.plot(v2[n1:n2, -1], v2[n1:n2, 0], 'g-o')
import aphla as ap import numpy as np import matplotlib.pylab as plt import time print ap.__path__ ap.initNSLS2V1() bpms = ap.getElements('BPM') #trims = ap.getGroupMembers(['*', '[HV]COR'], op='intersection') trims = ap.getElements('HCOR') + ap.getElements('VCOR') print "Bpms x Trims: (%d, %d)" % (len(bpms), len(trims) ) v0 = ap.getOrbit(spos=True) n1, n2 = 130, 150 ap.setLocalBump([e.name for e in bpms[n1:n2]], [e.name for e in trims], np.ones((n2-n1, 2), 'd')*1e-5, scale=0.7, repeat=6) #Euclidian norm: ... time.sleep(4) v1 = ap.getOrbit(spos=True) time.sleep(4) v2 = ap.getOrbit(spos=True) # plotting plt.clf() ax = plt.subplot(211) ax.annotate("H orbit before/after correction", (0.03, 0.9), xycoords='axes fraction') ax.plot(v0[:,-1], v0[:,0], 'r-') ax.plot(v1[:,-1], v1[:,0], 'g--') ax.plot(v2[n1:n2,-1], v2[n1:n2,0], 'g-o') #ax.legend()