def _update_dx(self): if len(self.corview.selectedCorrectors()) < 4: QtGui.QMessageBox.critical( self, "Local Orbit Bump", "ERROR: please select 4 correctors.", QtGui.QMessageBox.Ok) return tw = self.corview.getTwiss() try: st = float(self.loc.text()) dxt = float(self.dxi.text()) ang = float(self.ang.text()) except: return if self.rdbxbump.isChecked(): bt, at, pht = getTwissAt(st, ["betax", "alphax", "phix"]) elif self.rdbybump.isChecked(): bt, at, pht = getTwissAt(st, ["betay", "alphay", "phiy"]) tw["s"].append(st) tw["Beta"].append(bt) tw["Alpha"].append(at) tw["Phi"].append(pht) if pht > tw["Phi"][1]: tw["dPhi"].append(pht - tw["Phi"][1] + tw["dPhi"][1]) else: tw["dPhi"].append(tw["Phi"][2] - (tw["Phi"][2] - pht)) dkick = self.dx(tw, dxt, ang) self.corview.updateDbump(dkick)
def _update_dx(self): if len(self.corview.selectedCorrectors()) < 3: QtGui.QMessageBox.critical( self, "Local Orbit Bump", "ERROR: please select 3 correctors.", QtGui.QMessageBox.Ok) return tw = self.corview.getTwiss() if not self.loc.text() or not self.dxi.text(): return st = float(self.loc.text()) xt = float(self.dxi.text()) if self.rdbxbump.isChecked(): bt, at, pht = getTwissAt(st, ["betax", "alphax", "phix"]) elif self.rdbybump.isChecked(): bt, at, pht = getTwissAt(st, ["betay", "alphay", "phiy"]) tw["s"].append(st) tw["Beta"].append(bt) tw["Alpha"].append(at) tw["Phi"].append(pht) if pht > tw["Phi"][1]: tw["dPhi"].append(pht - tw["Phi"][1] + tw["dPhi"][1]) else: tw["dPhi"].append(tw["Phi"][2] - (tw["Phi"][2] - pht)) self.lblBeta.setText("{0}".format(bt)) self.lblAlfa.setText("{0}".format(at)) self.lblPhi.setText("{0}".format(pht)) vals = self.dx(tw, xt) #print "New dkick:", vals self.corview.updateDbump(vals)
m = np.zeros((2, len(quads))) betas = np.zeros((len(quads), 2)) ql1_inds = [] ql2_inds = [] ql3_inds = [] for i, q in enumerate(quads): if q.name.startswith('ql1'): ql1_inds.append(i) elif q.name.startswith('ql2'): ql2_inds.append(i) elif q.name.startswith('ql3'): ql3_inds.append(i) else: raise ValueError('Unexpected quad name: {0}'.format(q.name)) betas[i, :] = ap.getTwissAt((q.sb + q.se) / 2.0, ['betax', 'betay']) k1l = q.get('b1', handle='golden', unitsys='phy') m[0, i] = betas[i, 0] / 4.0 / np.pi m[1, i] = -betas[i, 1] / 4.0 / np.pi m_aphla = ap.calcTuneRm(quads, unitsys='phy') print 'Matrix max abs diff = ', np.max(np.abs((m_aphla - m).flatten())) #dnux = 0.001 #dnuy = 0.0 #filepath = 'dnux_1em3_dK_vec.txt' dnux = 0.0 dnuy = 0.001 filepath = 'dnuy_1em3_dK_vec.txt'