示例#1
0
文件: _gui_tmp.py 项目: BD75/mpsrad
    def setTabs(self, spec_names):
        self.sp = [
            SpectrometerPanel(self.parent, name=name) for name in spec_names
        ]
        for sp in self.sp:
            vBoxlayout = QVBoxLayout()
            vBoxlayout.addWidget(sp)
            tab = QWidget()
            tab.setLayout(vBoxlayout)
            self.addTab(tab, sp.name)

            sp.curves['Antenna'][0].setPen(QPen(Qt.black, 1))
            sp.curves['Antenna'][1].setPen(QPen(Qt.red, 1))
示例#2
0
文件: styles.py 项目: gyenney/Tools
 def test_update(self):
     obj = QPen(Qt.red, 2, Qt.SolidLine)
     ls = LineStyleParam(_("Line style"))
     ls.update_param(obj)
     self.assertEqual(ls.width, 2)
     self.assertEqual(ls.style, "SolidLine")
     self.assertEqual(ls.color, "#ff0000")
示例#3
0
 def paintEvent(self, evt):
     painter = QPainter(self)
     if self.color is not None:
         painter.setPen(QPen(self.color))
     painter.rotate(self.angle)
     transform = painter.transform().inverted()[0]
     rct = transform.mapRect(self.rect())
     painter.drawText(rct, self.alignment(), self.text())
示例#4
0
文件: styles.py 项目: gyenney/Tools
 def test_update(self):
     obj = QwtSymbol(QwtSymbol.Rect, QBrush(Qt.black), QPen(Qt.yellow),
                     QSize(3, 3))
     sym = SymbolParam(_("Symbol"))
     sym.update_param(obj)
     self.assertEqual(sym.marker, "Rect")
     self.assertEqual(sym.size, 3)
     self.assertEqual(sym.edgecolor, "#ffff00")
     self.assertEqual(sym.facecolor, "#000000")
示例#5
0
    def __init__(self, parent):
        tabs = parent.sp
        r = range(len(tabs))

        # Prepare unique names in ugly manner
        self.names = [n.spec.name
                      for n in tabs] if tabs[0].spec is not None else ['']
        test = []
        for n in r:
            if self.names.count(self.names[n]) > 1 or self.names[n] in test:
                test.append(self.names[n])
                self.names[n] += ' {}'.format(test.count(self.names[n]))

        plots = [[
            {
                'name': 'Calibrated',
                'curves': ['Calibrated ' + self.names[n] for n in r]
            },
            {
                'name': 'Integrated',
                'curves': ['Integrated ' + self.names[n] for n in r]
            },
            {
                'name': 'System noise',
                'curves': ['Noise ' + self.names[n] for n in r]
            },
        ]]

        df = [n.axisLimits[1] - n.axisLimits[0] for n in tabs]
        df2 = max(df) / 2

        axisLimits = [
            -df2, df2,
            min([n.axisLimits[2] for n in tabs]),
            max([n.axisLimits[3] for n in tabs])
        ]

        PlotPanel.__init__(self,
                           parent=parent,
                           plots=plots,
                           axisLimits=axisLimits)
        self.tabs = tabs
        cmap = get_cmap('tab10', len(tabs))
        self.colors = [
            QPen(QColor(x[0] * 255, x[1] * 255, x[2] * 255), 1)
            for x in cmap.colors
        ]

        cPanel = self.curves['Calibrated ' + self.names[0]].parent
        cPanel.add_item(make.legend("BL"))
        cPanel.setActive()
        cPanel = self.curves['Integrated ' + self.names[0]].parent
        cPanel.add_item(make.legend("BL"))
        cPanel.setActive()
        cPanel = self.curves['Noise ' + self.names[0]].parent
        cPanel.add_item(make.legend("BL"))
        cPanel.setActive()
示例#6
0
    def __init__(self,
                 parent,
                 spec=None,
                 count=0,
                 plots=[[{
                     'name': 'Raw spectra',
                     'curves': ['Cold', 'Hot', 'Antenna']
                 }, {
                     'name': 'System noise',
                     'curves': ['Noise']
                 }],
                        [{
                            'name': 'Calibrated',
                            'curves': ['Calibrated']
                        }, {
                            'name': 'Integrated',
                            'curves': ['Integrated']
                        }]]):
        try:
            axisLimits = spec.frequency[count] + [0, 400]
        except:
            axisLimits = [0, 40, 0, 400]
        PlotPanel.__init__(self,
                           parent=parent,
                           plots=plots,
                           axisLimits=axisLimits)
        self.spec = spec
        self.count = count
        self.name = self.spec.name if self.spec else 'Spectrometer'

        self.Pc = self.Ph = self.Pa = self.Ta = self.Ti = self.Tr = None
        self._mean = {'count': 0, 'mean': 0}
        self.chopper_pos = None

        self.curves['Cold'].setPen(QPen(Qt.blue, 1))
        self.curves['Hot'].setPen(QPen(Qt.red, 1))

        self.curves['Calibrated'].parent.set_titles(ylabel=u'Temperature')
        self.curves['Integrated'].parent.set_titles(ylabel=u'Temperature')
        self.curves['Noise'].parent.set_titles(ylabel=u'Temperature')

        cPanel = self.curves['Cold'].parent
        cPanel.add_item(make.legend("BL"))
        cPanel.setActive()
示例#7
0
文件: styles.py 项目: gyenney/Tools
 def test_changeconfig(self):
     obj = QPen(Qt.red, 2, Qt.SolidLine)
     ls = LineStyleParam(_("Line style"))
     ls.update_param(obj)
     ls.write_config(CONF, "ls", "")
     ls = LineStyleParam(_("Line style"))
     ls.read_config(CONF, "ls", "")
     self.assertEqual(ls.width, 2)
     self.assertEqual(ls.style, "SolidLine")
     self.assertEqual(ls.color, "#ff0000")
示例#8
0
文件: label.py 项目: mindw/guiqwt
 def draw(self, painter, xMap, yMap, canvasRect):
     self.update_text()
     x, y = self.get_top_left(xMap, yMap, canvasRect)
     x0, y0 = self.get_origin(xMap, yMap, canvasRect)
     painter.save()
     self.marker.drawSymbols(painter, [QPointF(x0, y0)])
     painter.restore()
     sz = self.text.size()
     self.draw_frame(painter, x, y, sz.width(), sz.height())
     painter.setPen(QPen(QColor(self.labelparam.color)))
     painter.translate(x, y)
     self.text.drawContents(painter)
示例#9
0
文件: styles.py 项目: gyenney/Tools
 def test_changeconfig(self):
     obj = QwtSymbol(QwtSymbol.Rect, QBrush(Qt.black), QPen(Qt.yellow),
                     QSize(3, 3))
     sym = SymbolParam(_("Symbol"))
     sym.update_param(obj)
     sym.write_config(CONF, "sym", "")
     sym = SymbolParam(_("Symbol"))
     sym.read_config(CONF, "sym", "")
     self.assertEqual(sym.marker, "Rect")
     self.assertEqual(sym.size, 3)
     self.assertEqual(sym.edgecolor, "#ffff00")
     self.assertEqual(sym.facecolor, "#000000")
     sym.build_symbol()
示例#10
0
def get_pen(conf, section, option="",
            color="black", width=1, style='SolidLine'):
    """
    Construct a QPen from the specified configuration file entry
    conf: UserConfig instance
    section [, option]: configuration entry
    [color]: default color
    [width]: default width
    [style]: default style
    """
    if 'pen' not in option:
        option += '/pen'
    color = conf.get(section, option+"/color", color)
    color = QColor(color)
    width = conf.get(section, option+"/width", width)
    style_name = conf.get(section, option+"/style", style)
    style = getattr(Qt, style_name)
    return QPen(color, width, style)
示例#11
0
    def __init__(self,
                 parent,
                 axisLimits=None,
                 plots=[[{
                     'name': 'P1',
                     'curves': ['C1', 'C2']
                 }]]):
        QSplitter.__init__(self, parent)
        self.parent = parent

        self.plots = [p for c in plots for r in c for p in r['curves']]
        self.active = None
        self.axisLimits = axisLimits

        self.xylim = XYlim()
        Filter = FilterWidget()

        # Curve panels (plots)
        Hsplit = QSplitter(self)
        self.curves = None
        self.panels = []

        for columns in plots:
            column = QSplitter(self)
            column.setOrientation(Qt.Vertical)
            column.setChildrenCollapsible(False)

            for rows in columns:
                panel = cPlot(column,
                              title=rows['name'],
                              xlabel="\u0394f [MHz]",
                              ylabel="Count",
                              updateWidgets=self.xylim.updateWidgets)
                panel.name = rows['name']
                panel.setDefaultAxis(self.axisLimits)
                panel.curves = {
                    p: cItem(filterfun=Filter.filterfun)
                    for p in rows['curves']
                }

                if self.curves is None: self.curves = panel.curves
                else: self.curves.update(panel.curves)

                for n in panel.curves:
                    p = panel.curves[n]
                    p.title().setText(n)
                    p.set_data([0], [0])
                    p.setPen(QPen(Qt.black, 1))
                    p.parent = panel
                    panel.add_item(p)

                column.addWidget(panel)
                self.panels.append(panel)

            Hsplit.addWidget(column)

        self.addWidget(Hsplit)

        Hsplit = QSplitter(self)
        Hsplit.addWidget(self.xylim)
        Hsplit.addWidget(Filter)
        self.addWidget(Hsplit)
        self.setOrientation(Qt.Vertical)
示例#12
0
文件: _gui_tmp.py 项目: BD75/mpsrad
    def __init__(self,
                 parent,
                 name='Panel',
                 plots=[[['Cold', 1], ['Hot', 1]],
                        [['Antenna', 2], ['Reference', 1]]]):
        QSplitter.__init__(self, parent)
        self.parent = parent
        self.name = name
        self.plots = [i[0] for o in plots
                      for i in o]  # make the name's list flat

        self.active = None
        self.evnt = None

        self.xylim = self.XYlim()

        # Curve panels (plots)
        Hsplit = QSplitter(self)
        plotColumns = [QSplitter(self) for n in plots]

        for rows, c in zip(plots, plotColumns):
            c.setOrientation(Qt.Vertical)
            c.setChildrenCollapsible(False)

            c.cwidgets = [
                self.cplot(c,
                           xlabel=u"\u0394f [MHz]",
                           ylabel="Count",
                           updateWidgets=self.xylim.updateWidgets)
                for i in rows
            ]
            c.plots = [[CurveItem(CurveParam()) for j in range(i[1])]
                       for i in rows]

            for m, cw in enumerate(c.cwidgets):
                cw.set_title(rows[m][0])
                for p in c.plots[m]:
                    p.set_data([0], [0])
                    p.parent = cw
                    cw.add_item(p)
#				cw.set_axis_limits(BasePlot.Y_LEFT,0,1)
#				cw.set_axis_limits(BasePlot.X_BOTTOM,-750,750)
                cw.setDefaultAxis([-750, 750, 0, 1])
                c.addWidget(cw)

            Hsplit.addWidget(c)

        self.addWidget(Hsplit)
        self.addWidget(self.xylim)
        self.setOrientation(Qt.Vertical)

        self.curvePanels = dict(
            zip(self.plots, sum([c.cwidgets for c in plotColumns], [])))
        self.curves = dict(
            zip(self.plots, [i for o in plotColumns for i in o.plots]))

        for nm in self.plots:
            for p in self.curves[nm]:
                p.setPen(QPen(Qt.blue, 1))

        plotColumns[0].cwidgets[0].setActive()
示例#13
0
    def __init__(self,
                 parent,
                 spec=None,
                 axisLimits=[0, 40, 0, 400],
                 plots=[[{
                     'name': 'Raw spectra',
                     'curves': ['Cold', 'Hot', 'Antenna']
                 }, {
                     'name': 'System noise',
                     'curves': ['Noise']
                 }],
                        [{
                            'name': 'Calibrated',
                            'curves': ['Calibrated']
                        }, {
                            'name': 'Integrated',
                            'curves': ['Integrated']
                        }]]):
        QSplitter.__init__(self, parent)
        self.parent = parent
        self.spec = spec
        self.name = self.spec.name if self.spec else 'Spectrometer'

        self.plots = [p for c in plots for r in c for p in r['curves']]

        self.Pc = self.Ph = self.Pa = self.Ta = self.Ti = self.Tr = None
        self._mean = {'count': 0, 'mean': 0}
        self.chopper_pos = None

        self.active = None
        self.axisLimits = axisLimits

        self.xylim = XYlim()

        Filter = FilterWidget()

        # Curve panels (plots)
        Hsplit = QSplitter(self)
        self.curves = None
        self.panels = []

        for columns in plots:
            column = QSplitter(self)
            column.setOrientation(Qt.Vertical)
            column.setChildrenCollapsible(False)

            for rows in columns:
                panel = cPlot(column,
                              title=rows['name'],
                              xlabel="\u0394f [MHz]",
                              ylabel="Count",
                              updateWidgets=self.xylim.updateWidgets)
                panel.name = rows['name']
                panel.setDefaultAxis(self.axisLimits)
                panel.curves = {
                    p: cItem(filterfun=Filter.filterfun)
                    for p in rows['curves']
                }

                if self.curves is None: self.curves = panel.curves
                else: self.curves.update(panel.curves)

                for n in panel.curves:
                    p = panel.curves[n]
                    p.title().setText(n)
                    p.set_data([0], [0])
                    p.setPen(QPen(Qt.black, 1))
                    p.parent = panel
                    panel.add_item(p)

                column.addWidget(panel)
                self.panels.append(panel)

            Hsplit.addWidget(column)

        self.addWidget(Hsplit)

        Hsplit = QSplitter(self)
        Hsplit.addWidget(self.xylim)
        Hsplit.addWidget(Filter)
        self.addWidget(Hsplit)
        self.setOrientation(Qt.Vertical)

        self.curves['Cold'].setPen(QPen(Qt.blue, 1))
        self.curves['Hot'].setPen(QPen(Qt.red, 1))

        self.curves['Calibrated'].parent.set_titles(ylabel=u'Temperature')
        self.curves['Integrated'].parent.set_titles(ylabel=u'Temperature')
        self.curves['Noise'].parent.set_titles(ylabel=u'Temperature')

        cPanel = self.curves['Cold'].parent
        cPanel.add_item(make.legend("BL"))
        cPanel.setActive()
示例#14
0
    def __init__(self, parent):
        n = len(parent.sp)
        cmap = get_cmap('tab10', n * 2 + 3)
        self.colors = [
            QPen(QColor(x[0] * 255, x[1] * 255, x[2] * 255), 1)
            for x in cmap.colors
        ]


        plots=\
         [[
          {'name':'Average Signal and Retrieved Signal','curves':[]},
          {'name':'Residual Signal','curves':[]}],
         [
        #				{'name':'Averaging kernel for OEM retrieval','curves':['Averaging']},
          {'name':'Measurement response to OEM retrieval','curves':[]}],
         [
          {'name':'Altitude vs. H2O VMR','curves':['Prior']}],
         ]

        for i in range(n):
            plots[0][0]['curves'].append('Data' + str(i))
            plots[0][0]['curves'].append('Retrieval' + str(i))
            plots[0][1]['curves'].append('Residual' + str(i))
            plots[1][0]['curves'].append('Response' + str(i))
            plots[2][0]['curves'].append('OEM Retrieval' + str(i))

        PlotPanel.__init__(self, parent=parent,
                           plots=plots)  #,axisLimits=axisLimits)

        self.colors[2 * n + 2].setWidth(3)
        self.curves['Prior'].setPen(self.colors[2 * n + 2])

        for i in range(n):
            self.curves['OEM Retrieval' + str(i)].setPen(self.colors[2 * i])
            self.curves['Data' + str(i)].setPen(self.colors[2 * i])
            self.curves['Residual' + str(i)].setPen(self.colors[2 * i])
            self.curves['Response' + str(i)].setPen(self.colors[2 * i])
            self.colors[2 * i + 1].setWidth(3)
            self.curves['Retrieval' + str(i)].setPen(self.colors[2 * i + 1])

            pDaRe = self.curves['Data' + str(i)].parent
            pResi = self.curves['Residual' + str(i)].parent
            #		pAver=self.curves['Averaging'].parent
            pResp = self.curves['Response' + str(i)].parent
            pPOEM = self.curves['Prior'].parent

            pPOEM.set_titles(ylabel='Altitude [m]', xlabel='Retrieval')
            pDaRe.set_titles(ylabel='Brightness Temperature [K]',
                             xlabel='Frequency [GHz]')
            pResi.set_titles(ylabel='Residual [K]', xlabel='Frequency [GHz]')
            #		pAver.set_titles(ylabel='Altitude [m]',xlabel='')
            pResp.set_titles(ylabel='Altitude [m]', xlabel='')

            pDaRe.add_item(make.legend("TR"))
            pDaRe.setActive()

            pPOEM.add_item(make.legend("TR"))
            pPOEM.setActive()

            pDaRe.setDefaultAxis(axis=[142.1, 142.2, 100., 200.])
            pResi.setDefaultAxis(axis=[142.1, 142.2, -.5, .5])
            #		pAver.setDefaultAxis(axis=[xmin,xmax,0.,1e5])
            pResp.setDefaultAxis(axis=[-.1, 2., 0., 1e5])
            pPOEM.setDefaultAxis(axis=[-.1, 12., 0., 1e5])