Commit 216c27103e223ad4a338ddcb524d1c608c96e457

Authored by mer0m
Committed by GitHub
1 parent b629599168
Exists in master

Add files via upload

Showing 3 changed files with 159 additions and 68 deletions Side-by-side Diff

... ... @@ -2,8 +2,7 @@
2 2 # -*- coding: utf-8 -*-
3 3  
4 4 from PyQt4 import QtGui, QtCore
5   -import sys, Gnuplot, csv, numpy, allantools
6   -
  5 +import sys, csv, numpy, allantools, pyqtgraph
7 6 import allanplotUI
8 7  
9 8 class allanplot(QtGui.QMainWindow, allanplotUI.Ui_MainWindow):
10 9  
... ... @@ -11,7 +10,18 @@
11 10 super(allanplot, self).__init__(parent)
12 11 self.setupUi(self)
13 12 self.connectActions()
  13 + self.pqg_widget(self.frame)
14 14  
  15 + def pqg_widget(self, frame):
  16 + pyqtgraph.setConfigOption('background', 'w')
  17 + pyqtgraph.setConfigOption('foreground', 'k')
  18 + self.plot_widget = pyqtgraph.PlotWidget()
  19 + self.layout_pqg = QtGui.QVBoxLayout(frame)
  20 + self.layout_pqg.addWidget(self.plot_widget)
  21 + self.plot_widget.showGrid(True, True, 0.5)
  22 + self.plot_widget.addLegend()
  23 + self.plot_widget.getViewBox().setMouseMode(pyqtgraph.ViewBox.RectMode)
  24 +
15 25 def connectActions(self):
16 26 self.pushQuit.clicked.connect(QtGui.qApp.quit)
17 27 self.pushOpen.clicked.connect(self.openDat)
18 28  
19 29  
20 30  
21 31  
22 32  
23 33  
24 34  
... ... @@ -40,40 +50,46 @@
40 50 self.textValue.setText(str(self.data[:]))
41 51  
42 52 def timePlot(self):
43   - g = Gnuplot.Gnuplot(persist = 1)
44   - g('set grid')
45   - g.xlabel('t (s)')
46   - g.ylabel('y (unit)')
  53 + self.plot_widget.clear()
  54 + self.plot_widget.setTitle('time plot')
  55 + self.plot_widget.setLabel('bottom', "Time", "s")
  56 + self.plot_widget.setLabel('left', "y")
  57 + self.plot_widget.setLogMode(False, False)
47 58 for i in range(2, self.data.shape[1]):
48   - g.replot(Gnuplot.Data(self.data[:,0], self.data[:,i], with_='l', title='#%s'%str(i)))
  59 + self.curve = self.plot_widget.plot()
  60 + self.curve.setData(self.data[:,0], self.data[:,i], pen=5*i, name='#%s'%i)
49 61  
50 62 def relativeTimePlot(self):
51   - g = Gnuplot.Gnuplot(persist = 1)
52   - g('set grid')
53   - g.xlabel('t (s)')
54   - g.ylabel('y (unit)')
  63 + self.plot_widget.clear()
  64 + self.plot_widget.setTitle('relative time plot')
  65 + self.plot_widget.setLabel('bottom', "Time", "s")
  66 + self.plot_widget.setLabel('left', "y")
  67 + self.plot_widget.setLogMode(False, False)
55 68 for i in range(2, self.data.shape[1]):
56   - g.replot(Gnuplot.Data(self.data[:,0], self.data[:,i]/self.data[:,i].mean(), with_='l', title='#%s'%str(i)))
  69 + self.curve = self.plot_widget.plot()
  70 + self.curve.setData(self.data[:,0], self.data[:,i]/self.data[:,i].mean(), pen=5*i, name='#%s'%i)
57 71  
58 72 def adevPlot(self):
59   - g = Gnuplot.Gnuplot(persist = 1)
60   - g('set logscale xy')
61   - g('set grid')
62   - g.xlabel('Tau (s)')
63   - g.ylabel('Adev')
  73 + self.plot_widget.clear()
  74 + self.plot_widget.setTitle('adev plot')
  75 + self.plot_widget.setLabel('bottom', "Tau", "s")
  76 + self.plot_widget.setLabel('left', "adev")
  77 + self.plot_widget.setLogMode(True, True)
64 78 for i in range(2, self.data.shape[1]):
65 79 (tau2, ad, ade, adn) = allantools.adev(self.data[:,i], rate=1, data_type="freq", taus='decade')
66   - g.replot(Gnuplot.Data(tau2, ad, ade, with_='yerrorbars', title='#%s'%str(i)))
  80 + self.curve = self.plot_widget.plot()
  81 + self.curve.setData(tau2, ad, pen=5*i, name='#%s'%i)
67 82  
68 83 def relativeAdevPlot(self):
69   - g = Gnuplot.Gnuplot(persist = 1)
70   - g('set logscale xy')
71   - g('set grid')
72   - g.xlabel('Tau (s)')
73   - g.ylabel('Adev')
  84 + self.plot_widget.clear()
  85 + self.plot_widget.setTitle('relative adev plot')
  86 + self.plot_widget.setLabel('bottom', "Tau", "s")
  87 + self.plot_widget.setLabel('left', "relative adev")
  88 + self.plot_widget.setLogMode(True, True)
74 89 for i in range(2, self.data.shape[1]):
75 90 (tau2, ad, ade, adn) = allantools.adev(self.data[:,i]/self.data[:,i].mean(), rate=1, data_type="freq", taus='decade')
76   - g.replot(Gnuplot.Data(tau2, ad, ade, with_='yerrorbars', title='#%s'%str(i)))
  91 + self.curve = self.plot_widget.plot()
  92 + self.curve.setData(tau2, ad, pen=5*i, name='#%s'%i)
77 93  
78 94 def main(self):
79 95 self.show()
... ... @@ -2,7 +2,7 @@
2 2  
3 3 # Form implementation generated from reading ui file 'allanplotUI.ui'
4 4 #
5   -# Created: Wed Jul 6 15:05:06 2016
  5 +# Created: Thu Jul 7 17:46:05 2016
6 6 # by: PyQt4 UI code generator 4.11.2
7 7 #
8 8 # WARNING! All changes made in this file will be lost!
9 9  
10 10  
... ... @@ -26,18 +26,20 @@
26 26 class Ui_MainWindow(object):
27 27 def setupUi(self, MainWindow):
28 28 MainWindow.setObjectName(_fromUtf8("MainWindow"))
29   - MainWindow.resize(903, 240)
  29 + MainWindow.resize(766, 780)
30 30 self.centralwidget = QtGui.QWidget(MainWindow)
31 31 self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
32 32 self.gridLayout = QtGui.QGridLayout(self.centralwidget)
33 33 self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
34   - self.textFileList = QtGui.QTextBrowser(self.centralwidget)
35   - self.textFileList.setObjectName(_fromUtf8("textFileList"))
36   - self.gridLayout.addWidget(self.textFileList, 1, 3, 4, 1)
37 34 self.pushOpen = QtGui.QPushButton(self.centralwidget)
38 35 self.pushOpen.setObjectName(_fromUtf8("pushOpen"))
39 36 self.gridLayout.addWidget(self.pushOpen, 1, 1, 1, 1)
40 37 self.groupBox = QtGui.QGroupBox(self.centralwidget)
  38 + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum)
  39 + sizePolicy.setHorizontalStretch(0)
  40 + sizePolicy.setVerticalStretch(0)
  41 + sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth())
  42 + self.groupBox.setSizePolicy(sizePolicy)
41 43 self.groupBox.setObjectName(_fromUtf8("groupBox"))
42 44 self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox)
43 45 self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
44 46  
... ... @@ -53,15 +55,40 @@
53 55 self.pushRelativeAdevPlot = QtGui.QPushButton(self.groupBox)
54 56 self.pushRelativeAdevPlot.setObjectName(_fromUtf8("pushRelativeAdevPlot"))
55 57 self.verticalLayout_2.addWidget(self.pushRelativeAdevPlot)
56   - self.gridLayout.addWidget(self.groupBox, 5, 1, 1, 1)
57   - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
58   - self.gridLayout.addItem(spacerItem, 3, 1, 1, 1)
  58 + self.gridLayout.addWidget(self.groupBox, 4, 1, 1, 1)
  59 + self.textValue = QtGui.QTextBrowser(self.centralwidget)
  60 + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
  61 + sizePolicy.setHorizontalStretch(0)
  62 + sizePolicy.setVerticalStretch(0)
  63 + sizePolicy.setHeightForWidth(self.textValue.sizePolicy().hasHeightForWidth())
  64 + self.textValue.setSizePolicy(sizePolicy)
  65 + self.textValue.setMinimumSize(QtCore.QSize(600, 150))
  66 + self.textValue.setMaximumSize(QtCore.QSize(16777215, 150))
  67 + self.textValue.setObjectName(_fromUtf8("textValue"))
  68 + self.gridLayout.addWidget(self.textValue, 4, 2, 1, 1)
59 69 self.pushQuit = QtGui.QPushButton(self.centralwidget)
60 70 self.pushQuit.setObjectName(_fromUtf8("pushQuit"))
61 71 self.gridLayout.addWidget(self.pushQuit, 2, 1, 1, 1)
62   - self.textValue = QtGui.QTextBrowser(self.centralwidget)
63   - self.textValue.setObjectName(_fromUtf8("textValue"))
64   - self.gridLayout.addWidget(self.textValue, 5, 3, 1, 1)
  72 + self.textFileList = QtGui.QTextBrowser(self.centralwidget)
  73 + self.textFileList.setEnabled(True)
  74 + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
  75 + sizePolicy.setHorizontalStretch(0)
  76 + sizePolicy.setVerticalStretch(0)
  77 + sizePolicy.setHeightForWidth(self.textFileList.sizePolicy().hasHeightForWidth())
  78 + self.textFileList.setSizePolicy(sizePolicy)
  79 + self.textFileList.setMinimumSize(QtCore.QSize(600, 100))
  80 + self.textFileList.setMaximumSize(QtCore.QSize(16777215, 100))
  81 + self.textFileList.setObjectName(_fromUtf8("textFileList"))
  82 + self.gridLayout.addWidget(self.textFileList, 1, 2, 3, 1)
  83 + self.frame = QtGui.QFrame(self.centralwidget)
  84 + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
  85 + sizePolicy.setHorizontalStretch(0)
  86 + sizePolicy.setVerticalStretch(0)
  87 + sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth())
  88 + self.frame.setSizePolicy(sizePolicy)
  89 + self.frame.setMinimumSize(QtCore.QSize(700, 500))
  90 + self.frame.setObjectName(_fromUtf8("frame"))
  91 + self.gridLayout.addWidget(self.frame, 5, 1, 1, 2)
65 92 MainWindow.setCentralWidget(self.centralwidget)
66 93 self.actionOpen = QtGui.QAction(MainWindow)
67 94 self.actionOpen.setObjectName(_fromUtf8("actionOpen"))
68 95  
69 96  
... ... @@ -74,24 +101,24 @@
74 101 QtCore.QMetaObject.connectSlotsByName(MainWindow)
75 102  
76 103 def retranslateUi(self, MainWindow):
77   - MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
78   - self.textFileList.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
79   -"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
80   -"p, li { white-space: pre-wrap; }\n"
81   -"</style></head><body style=\" font-family:\'DejaVu Sans\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
82   -"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">.dat files</p></body></html>", None))
  104 + MainWindow.setWindowTitle(_translate("MainWindow", "allanplot-gui", None))
83 105 self.pushOpen.setText(_translate("MainWindow", "Open", None))
84 106 self.groupBox.setTitle(_translate("MainWindow", "Plotting tools", None))
85 107 self.pushTimePlot.setText(_translate("MainWindow", "Time Plot", None))
86 108 self.pushRelativeTimePlot.setText(_translate("MainWindow", "Relative Time Plot", None))
87 109 self.pushAdevPlot.setText(_translate("MainWindow", "Adev Plot", None))
88 110 self.pushRelativeAdevPlot.setText(_translate("MainWindow", "Relative Adev Plot", None))
89   - self.pushQuit.setText(_translate("MainWindow", "Quit", None))
90 111 self.textValue.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
91 112 "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
92 113 "p, li { white-space: pre-wrap; }\n"
93 114 "</style></head><body style=\" font-family:\'DejaVu Sans\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
94 115 "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None))
  116 + self.pushQuit.setText(_translate("MainWindow", "Quit", None))
  117 + self.textFileList.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
  118 +"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
  119 +"p, li { white-space: pre-wrap; }\n"
  120 +"</style></head><body style=\" font-family:\'DejaVu Sans\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
  121 +"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">.dat files</p></body></html>", None))
95 122 self.actionOpen.setText(_translate("MainWindow", "Open", None))
96 123 self.actionPlot.setText(_translate("MainWindow", "Plot", None))
97 124 self.actionQuit.setText(_translate("MainWindow", "Quit", None))
... ... @@ -6,26 +6,15 @@
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9   - <width>903</width>
10   - <height>240</height>
  9 + <width>766</width>
  10 + <height>780</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
14   - <string>MainWindow</string>
  14 + <string>allanplot-gui</string>
15 15 </property>
16 16 <widget class="QWidget" name="centralwidget">
17 17 <layout class="QGridLayout" name="gridLayout">
18   - <item row="1" column="3" rowspan="4">
19   - <widget class="QTextBrowser" name="textFileList">
20   - <property name="html">
21   - <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
22   -&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
23   -p, li { white-space: pre-wrap; }
24   -&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
25   -&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;.dat files&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
26   - </property>
27   - </widget>
28   - </item>
29 18 <item row="1" column="1">
30 19 <widget class="QPushButton" name="pushOpen">
31 20 <property name="text">
32 21  
... ... @@ -33,8 +22,14 @@
33 22 </property>
34 23 </widget>
35 24 </item>
36   - <item row="5" column="1">
  25 + <item row="4" column="1">
37 26 <widget class="QGroupBox" name="groupBox">
  27 + <property name="sizePolicy">
  28 + <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
  29 + <horstretch>0</horstretch>
  30 + <verstretch>0</verstretch>
  31 + </sizepolicy>
  32 + </property>
38 33 <property name="title">
39 34 <string>Plotting tools</string>
40 35 </property>
41 36  
42 37  
43 38  
... ... @@ -70,18 +65,34 @@
70 65 </layout>
71 66 </widget>
72 67 </item>
73   - <item row="3" column="1">
74   - <spacer name="verticalSpacer">
75   - <property name="orientation">
76   - <enum>Qt::Vertical</enum>
  68 + <item row="4" column="2">
  69 + <widget class="QTextBrowser" name="textValue">
  70 + <property name="sizePolicy">
  71 + <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
  72 + <horstretch>0</horstretch>
  73 + <verstretch>0</verstretch>
  74 + </sizepolicy>
77 75 </property>
78   - <property name="sizeHint" stdset="0">
  76 + <property name="minimumSize">
79 77 <size>
80   - <width>20</width>
81   - <height>40</height>
  78 + <width>600</width>
  79 + <height>150</height>
82 80 </size>
83 81 </property>
84   - </spacer>
  82 + <property name="maximumSize">
  83 + <size>
  84 + <width>16777215</width>
  85 + <height>150</height>
  86 + </size>
  87 + </property>
  88 + <property name="html">
  89 + <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
  90 +&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
  91 +p, li { white-space: pre-wrap; }
  92 +&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
  93 +&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
  94 + </property>
  95 + </widget>
85 96 </item>
86 97 <item row="2" column="1">
87 98 <widget class="QPushButton" name="pushQuit">
88 99  
... ... @@ -90,14 +101,51 @@
90 101 </property>
91 102 </widget>
92 103 </item>
93   - <item row="5" column="3">
94   - <widget class="QTextBrowser" name="textValue">
  104 + <item row="1" column="2" rowspan="3">
  105 + <widget class="QTextBrowser" name="textFileList">
  106 + <property name="enabled">
  107 + <bool>true</bool>
  108 + </property>
  109 + <property name="sizePolicy">
  110 + <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
  111 + <horstretch>0</horstretch>
  112 + <verstretch>0</verstretch>
  113 + </sizepolicy>
  114 + </property>
  115 + <property name="minimumSize">
  116 + <size>
  117 + <width>600</width>
  118 + <height>100</height>
  119 + </size>
  120 + </property>
  121 + <property name="maximumSize">
  122 + <size>
  123 + <width>16777215</width>
  124 + <height>100</height>
  125 + </size>
  126 + </property>
95 127 <property name="html">
96 128 <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
97 129 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
98 130 p, li { white-space: pre-wrap; }
99 131 &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
100   -&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
  132 +&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;.dat files&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
  133 + </property>
  134 + </widget>
  135 + </item>
  136 + <item row="5" column="1" colspan="2">
  137 + <widget class="QFrame" name="frame">
  138 + <property name="sizePolicy">
  139 + <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
  140 + <horstretch>0</horstretch>
  141 + <verstretch>0</verstretch>
  142 + </sizepolicy>
  143 + </property>
  144 + <property name="minimumSize">
  145 + <size>
  146 + <width>700</width>
  147 + <height>500</height>
  148 + </size>
101 149 </property>
102 150 </widget>
103 151 </item>