def openTunePlot(self): mach, lat = self.getCurrentMachLattice() nu = lat.getElementList('tune') pvs = [(e.pv(field="x", handle="readback")[0], e.pv(field="y", handle="readback")[0]) for e in nu] labels = [e.name for e in nu] twiss = lat.getElementList("VA") pvs.extend([(e.pv(field="nux", handle="readback")[0], e.pv(field="nuy", handle="readback")[0]) for e in twiss]) labels.extend([e.name for e in twiss]) p = ApMdiSubPlot(pvs=pvs, labels=labels, dtype="Tunes") #QObject.installEventFilter(p.aplot) #p.data = ManagedPvData(pvm, s, pvs, element=elemnames, # label="{0}.{1}".format(elem,field)) p.setAttribute(Qt.WA_DeleteOnClose) p.setWindowTitle("[%s.%s] Tunes" % (mach, lat.name)) self.connect(p, SIGNAL("elementSelected(PyQt_PyObject)"), self.elementSelected) self.connect(p, SIGNAL("destroyed()"), self.subPlotDestroyed) #p.updatePlot() # set the zoom stack #p.aplot.setErrorBar(self.error_bar) #p.wid.autoScaleXY() #p.aplot.replot() self.mdiarea.addSubWindow(p) #print "Show" p.show()
def openTunePlot(self): mach, lat = self.getCurrentMachLattice() nu = lat.getElementList('tune') pvs = [(e.pv(field="x", handle="readback")[0], e.pv(field="y", handle="readback")[0]) for e in nu] labels = [e.name for e in nu] twiss = lat.getElementList("VA") pvs.extend([(e.pv(field="nux", handle="readback")[0], e.pv(field="nuy", handle="readback")[0]) for e in twiss]) labels.extend([e.name for e in twiss]) p = ApMdiSubPlot(pvs=pvs, labels=labels, dtype = "Tunes") #QObject.installEventFilter(p.aplot) #p.data = ManagedPvData(pvm, s, pvs, element=elemnames, # label="{0}.{1}".format(elem,field)) p.setAttribute(Qt.WA_DeleteOnClose) p.setWindowTitle("[%s.%s] Tunes" % (mach, lat.name)) self.connect(p, SIGNAL("elementSelected(PyQt_PyObject)"), self.elementSelected) self.connect(p, SIGNAL("destroyed()"), self.subPlotDestroyed) #p.updatePlot() # set the zoom stack #p.aplot.setErrorBar(self.error_bar) #p.wid.autoScaleXY() #p.aplot.replot() self.mdiarea.addSubWindow(p) #print "Show" p.show()
def measDispersion(self): p = ApMdiSubPlot(live=False) p.setAttribute(Qt.WA_DeleteOnClose) curves = [ p.aplot.curve1, p.aplot.addCurve(), # x and xref p.aplot.addCurve(), p.aplot.addCurve() # y and yref ] for curv in curves: curv.setStyle(Qwt.QwtPlotCurve.Lines) curves[0].setPen(QPen(Qt.red, 1.3, Qt.DashLine)) curves[1].setPen(QPen(Qt.red, 1.5)) curves[2].setPen(QPen(Qt.blue, 1.3, Qt.DashLine)) curves[3].setPen(QPen(Qt.blue, 1.5)) curves[2].setSymbol( Qwt.QwtSymbol(Qwt.QwtSymbol.Triangle, QBrush(Qt.blue), QPen(Qt.black, 1), QSize(8, 8))) #p.aplot.curve1.setStyle(Qwt.QwtPlotCurve.) #p.setWindowTitle("[%s.%s] %s %s" % (mach, lat, title, fld)) self.mdiarea.addSubWindow(p) #print "Show" p.show() #plots.append(p) #bpms = ap.getGroupMembers(['C20', 'BPM']) + \ # ap.getGroupMembers(['C21', 'BPM']) bpms = ap.getElements('BPM') xl = min([q.sb for q in bpms]) xr = max([q.se for q in bpms]) s, btx, bty = [], [], [] try: etaref = ap.getEta([q.name for q in bpms], spos=True) curves[1].setData(etaref[:, -1], etaref[:, 0], None) curves[3].setData(etaref[:, -1], etaref[:, 1], None) fullmagprof = ap.machines.getLattice().getBeamlineProfile() magprof = [v for v in fullmagprof if max(v[0]) > xl \ and min(v[0]) < xr] p.aplot.setMagnetProfile(magprof) #p.wid.autoScaleXY() p.aplot.replot() disp = ap.measDispersion(bpms, verbose=2) curves[0].setData(disp[:, -1], disp[:, 0], None) curves[2].setData(disp[:, -1], disp[:, 1], None) p.wid.autoScaleXY() p.aplot.replot() _logger.info("dispersion eta measured") except: _logger.error("error at measEta") raise _logger.info("finished eta measurement.")
def measDispersion(self): p = ApMdiSubPlot(live=False) p.setAttribute(Qt.WA_DeleteOnClose) curves = [p.aplot.curve1, p.aplot.addCurve(), # x and xref p.aplot.addCurve(), p.aplot.addCurve() # y and yref ] for curv in curves: curv.setStyle(Qwt.QwtPlotCurve.Lines) curves[0].setPen(QPen(Qt.red, 1.3, Qt.DashLine)) curves[1].setPen(QPen(Qt.red, 1.5)) curves[2].setPen(QPen(Qt.blue, 1.3, Qt.DashLine)) curves[3].setPen(QPen(Qt.blue, 1.5)) curves[2].setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Triangle, QBrush(Qt.blue), QPen(Qt.black, 1), QSize(8, 8))) #p.aplot.curve1.setStyle(Qwt.QwtPlotCurve.) #p.setWindowTitle("[%s.%s] %s %s" % (mach, lat, title, fld)) self.mdiarea.addSubWindow(p) #print "Show" p.show() #plots.append(p) #bpms = ap.getGroupMembers(['C20', 'BPM']) + \ # ap.getGroupMembers(['C21', 'BPM']) bpms = ap.getElements('BPM') xl = min([q.sb for q in bpms]) xr = max([q.se for q in bpms]) s, btx, bty = [], [], [] try: etaref = ap.getEta([q.name for q in bpms], spos=True) curves[1].setData(etaref[:,-1], etaref[:,0], None) curves[3].setData(etaref[:,-1], etaref[:,1], None) fullmagprof = ap.machines.getLattice().getBeamlineProfile() magprof = [v for v in fullmagprof if max(v[0]) > xl \ and min(v[0]) < xr] p.aplot.setMagnetProfile(magprof) #p.wid.autoScaleXY() p.aplot.replot() disp = ap.measDispersion(bpms, verbose=2) curves[0].setData(disp[:,-1], disp[:,0], None) curves[2].setData(disp[:,-1], disp[:,1], None) p.wid.autoScaleXY() p.aplot.replot() _logger.info("dispersion eta measured") except: _logger.error("error at measEta") raise _logger.info("finished eta measurement.")
def newElementPlots(self, elem, fields, **kw): self.logger.info("new plots: %s %s" % (elem, fields)) _mach, _lat, _pvm = self.getCurrentMachLattice(cadata=True) mach, lat = kw.get("machlat", (_mach, _lat)) handle = kw.get("handle", "readback") elems = lat.getElementList(elem) x, pvs = [], [] field_list = re.findall(r'[^ ,]+', fields) for fld in field_list: si, pvsi = [], [] for e in elems: if not e.isEnabled(): continue epv = e.pv(field=fld, handle=handle) if not epv: continue pvsi.append(epv[0]) si.append(e.sb) x.append(si) pvs.append(pvsi) if not pvs: self.logger.error("no data found for elements '{0}' " "and field '{1}'".format(elem, field)) return p = ApMdiSubPlot(pvs=pvs, x=x, labels=["%s.%s" % (elem, fld) for fld in field_list], magprof=lat.getBeamlineProfile(), iqt=self.iqtApp, **kw) #QObject.installEventFilter(p.aplot) #p.data = ManagedPvData(pvm, s, pvs, element=elemnames, # label="{0}.{1}".format(elem,field)) p.setAttribute(Qt.WA_DeleteOnClose) str_elem = "{0}".format(elem) if len(str_elem) > 12: str_elem = str_elem[:9] + "..." str_field = "{0}".format(fields) if len(str_field) > 12: str_field = str_field[:9] + "..." p.setWindowTitle("[%s.%s] %s %s" % (mach, lat.name, str_elem, str_field)) self.connect(p, SIGNAL("elementSelected(PyQt_PyObject)"), self.elementSelected) self.connect(p, SIGNAL("destroyed()"), self.subPlotDestroyed) #p.updatePlot() # set the zoom stack #p.aplot.setErrorBar(self.error_bar) #p.wid.autoScaleXY() #p.aplot.replot() self.mdiarea.addSubWindow(p) #print "Show" p.show()
def newElementPlots(self, elem, fields, **kw): self.logger.info("new plots: %s %s" % (elem, fields)) _mach, _lat, _pvm = self.getCurrentMachLattice(cadata=True) mach, lat = kw.get("machlat", (_mach, _lat)) handle = kw.get("handle", "readback") elems = lat.getElementList(elem) x, pvs = [], [] field_list = re.findall(r'[^ ,]+', fields) for fld in field_list: si, pvsi = [], [] for e in elems: if not e.isEnabled(): continue epv = e.pv(field=fld, handle=handle) if not epv: continue pvsi.append(epv[0]) si.append(e.sb) x.append(si) pvs.append(pvsi) if not pvs: self.logger.error("no data found for elements '{0}' " "and field '{1}'".format(elem, field)) return p = ApMdiSubPlot(pvs=pvs, x = x, labels=["%s.%s" % (elem,fld) for fld in field_list], magprof = lat.getBeamlineProfile(), iqt = self.iqtApp, **kw) #QObject.installEventFilter(p.aplot) #p.data = ManagedPvData(pvm, s, pvs, element=elemnames, # label="{0}.{1}".format(elem,field)) p.setAttribute(Qt.WA_DeleteOnClose) str_elem = "{0}".format(elem) if len(str_elem) > 12: str_elem = str_elem[:9] + "..." str_field = "{0}".format(fields) if len(str_field) > 12: str_field = str_field[:9] + "..." p.setWindowTitle("[%s.%s] %s %s" % ( mach, lat.name, str_elem, str_field)) self.connect(p, SIGNAL("elementSelected(PyQt_PyObject)"), self.elementSelected) self.connect(p, SIGNAL("destroyed()"), self.subPlotDestroyed) #p.updatePlot() # set the zoom stack #p.aplot.setErrorBar(self.error_bar) #p.wid.autoScaleXY() #p.aplot.replot() self.mdiarea.addSubWindow(p) #print "Show" p.show()
def measBeta(self): p = ApMdiSubPlot(live=False) p.setAttribute(Qt.WA_DeleteOnClose) curves = [p.aplot.curve1, p.aplot.addCurve(), # x and xref p.aplot.addCurve(), p.aplot.addCurve() # y and yref ] for curv in curves: curv.setStyle(Qwt.QwtPlotCurve.Lines) curves[0].setPen(QPen(Qt.red, 1.3, Qt.DashLine)) curves[0].setZ(curves[1].z() + 2) curves[1].setPen(QPen(Qt.red, 1.5)) curves[2].setPen(QPen(Qt.blue, 1.3, Qt.DashLine)) curves[2].setZ(curves[3].z() + 2) curves[2].setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Triangle, QBrush(Qt.blue), QPen(Qt.black, 1), QSize(8, 8))) curves[3].setPen(QPen(Qt.blue, 1.5)) #p.aplot.curve1.setStyle(Qwt.QwtPlotCurve.) #p.setWindowTitle("[%s.%s] %s %s" % (mach, lat, title, fld)) self.mdiarea.addSubWindow(p) #print "Show" p.show() #plots.append(p) qs = ap.getGroupMembers(['C20', 'QUAD']) + \ ap.getGroupMembers(['C21', 'QUAD']) xl = min([q.sb for q in qs]) xr = max([q.se for q in qs]) s, btx, bty = [], [], [] try: betaref = ap.getBeta([q.name for q in qs], spos=True) curves[1].setData(betaref[:,-1], betaref[:,0], None) curves[3].setData(betaref[:,-1], betaref[:,1], None) fullmagprof = ap.machines.getLattice().getBeamlineProfile() magprof = [v for v in fullmagprof if max(v[0]) > xl \ and min(v[0]) < xr] p.aplot.setMagnetProfile(magprof) p.wid.autoScaleXY() p.aplot.replot() for q in qs[:3]: tbeta, tk1, tnu = ap.measBeta(q, full=True) #print tk1, tnu, tbeta QApplication.processEvents() s.append(tbeta[0,-1]) btx.append(tbeta[0,0]) bty.append(tbeta[0,1]) curves[0].setData(s, btx, None) curves[2].setData(s, bty, None) p.wid.autoScaleXY() p.aplot.replot() _logger.info("beta measured for {0} " \ "(s={1}, btx={2}, bty={3})".format( q.name, s[-1], btx[-1], bty[-1])) except: _logger.error("error at measBeta") raise _logger.info("finished beta measurement.")
def measBeta(self): p = ApMdiSubPlot(live=False) p.setAttribute(Qt.WA_DeleteOnClose) curves = [ p.aplot.curve1, p.aplot.addCurve(), # x and xref p.aplot.addCurve(), p.aplot.addCurve() # y and yref ] for curv in curves: curv.setStyle(Qwt.QwtPlotCurve.Lines) curves[0].setPen(QPen(Qt.red, 1.3, Qt.DashLine)) curves[0].setZ(curves[1].z() + 2) curves[1].setPen(QPen(Qt.red, 1.5)) curves[2].setPen(QPen(Qt.blue, 1.3, Qt.DashLine)) curves[2].setZ(curves[3].z() + 2) curves[2].setSymbol( Qwt.QwtSymbol(Qwt.QwtSymbol.Triangle, QBrush(Qt.blue), QPen(Qt.black, 1), QSize(8, 8))) curves[3].setPen(QPen(Qt.blue, 1.5)) #p.aplot.curve1.setStyle(Qwt.QwtPlotCurve.) #p.setWindowTitle("[%s.%s] %s %s" % (mach, lat, title, fld)) self.mdiarea.addSubWindow(p) #print "Show" p.show() #plots.append(p) qs = ap.getGroupMembers(['C20', 'QUAD']) + \ ap.getGroupMembers(['C21', 'QUAD']) xl = min([q.sb for q in qs]) xr = max([q.se for q in qs]) s, btx, bty = [], [], [] try: betaref = ap.getBeta([q.name for q in qs], spos=True) curves[1].setData(betaref[:, -1], betaref[:, 0], None) curves[3].setData(betaref[:, -1], betaref[:, 1], None) fullmagprof = ap.machines.getLattice().getBeamlineProfile() magprof = [v for v in fullmagprof if max(v[0]) > xl \ and min(v[0]) < xr] p.aplot.setMagnetProfile(magprof) p.wid.autoScaleXY() p.aplot.replot() for q in qs[:3]: tbeta, tk1, tnu = ap.measBeta(q, full=True) #print tk1, tnu, tbeta QApplication.processEvents() s.append(tbeta[0, -1]) btx.append(tbeta[0, 0]) bty.append(tbeta[0, 1]) curves[0].setData(s, btx, None) curves[2].setData(s, bty, None) p.wid.autoScaleXY() p.aplot.replot() _logger.info("beta measured for {0} " \ "(s={1}, btx={2}, bty={3})".format( q.name, s[-1], btx[-1], bty[-1])) except: _logger.error("error at measBeta") raise _logger.info("finished beta measurement.")