From 216c27103e223ad4a338ddcb524d1c608c96e457 Mon Sep 17 00:00:00 2001 From: mer0m Date: Fri, 8 Jul 2016 12:28:41 +0200 Subject: [PATCH] Add files via upload --- allanplot-gui.py | 64 ++++++++++++++++++++++------------- allanplotUI.py | 63 +++++++++++++++++++++++++---------- allanplotUI.ui | 100 ++++++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 159 insertions(+), 68 deletions(-) diff --git a/allanplot-gui.py b/allanplot-gui.py index 6b133b5..62417d7 100644 --- a/allanplot-gui.py +++ b/allanplot-gui.py @@ -2,8 +2,7 @@ # -*- coding: utf-8 -*- from PyQt4 import QtGui, QtCore -import sys, Gnuplot, csv, numpy, allantools - +import sys, csv, numpy, allantools, pyqtgraph import allanplotUI class allanplot(QtGui.QMainWindow, allanplotUI.Ui_MainWindow): @@ -11,6 +10,17 @@ class allanplot(QtGui.QMainWindow, allanplotUI.Ui_MainWindow): super(allanplot, self).__init__(parent) self.setupUi(self) self.connectActions() + self.pqg_widget(self.frame) + + def pqg_widget(self, frame): + pyqtgraph.setConfigOption('background', 'w') + pyqtgraph.setConfigOption('foreground', 'k') + self.plot_widget = pyqtgraph.PlotWidget() + self.layout_pqg = QtGui.QVBoxLayout(frame) + self.layout_pqg.addWidget(self.plot_widget) + self.plot_widget.showGrid(True, True, 0.5) + self.plot_widget.addLegend() + self.plot_widget.getViewBox().setMouseMode(pyqtgraph.ViewBox.RectMode) def connectActions(self): self.pushQuit.clicked.connect(QtGui.qApp.quit) @@ -40,40 +50,46 @@ class allanplot(QtGui.QMainWindow, allanplotUI.Ui_MainWindow): self.textValue.setText(str(self.data[:])) def timePlot(self): - g = Gnuplot.Gnuplot(persist = 1) - g('set grid') - g.xlabel('t (s)') - g.ylabel('y (unit)') + self.plot_widget.clear() + self.plot_widget.setTitle('time plot') + self.plot_widget.setLabel('bottom', "Time", "s") + self.plot_widget.setLabel('left', "y") + self.plot_widget.setLogMode(False, False) for i in range(2, self.data.shape[1]): - g.replot(Gnuplot.Data(self.data[:,0], self.data[:,i], with_='l', title='#%s'%str(i))) + self.curve = self.plot_widget.plot() + self.curve.setData(self.data[:,0], self.data[:,i], pen=5*i, name='#%s'%i) def relativeTimePlot(self): - g = Gnuplot.Gnuplot(persist = 1) - g('set grid') - g.xlabel('t (s)') - g.ylabel('y (unit)') + self.plot_widget.clear() + self.plot_widget.setTitle('relative time plot') + self.plot_widget.setLabel('bottom', "Time", "s") + self.plot_widget.setLabel('left', "y") + self.plot_widget.setLogMode(False, False) for i in range(2, self.data.shape[1]): - g.replot(Gnuplot.Data(self.data[:,0], self.data[:,i]/self.data[:,i].mean(), with_='l', title='#%s'%str(i))) + self.curve = self.plot_widget.plot() + self.curve.setData(self.data[:,0], self.data[:,i]/self.data[:,i].mean(), pen=5*i, name='#%s'%i) def adevPlot(self): - g = Gnuplot.Gnuplot(persist = 1) - g('set logscale xy') - g('set grid') - g.xlabel('Tau (s)') - g.ylabel('Adev') + self.plot_widget.clear() + self.plot_widget.setTitle('adev plot') + self.plot_widget.setLabel('bottom', "Tau", "s") + self.plot_widget.setLabel('left', "adev") + self.plot_widget.setLogMode(True, True) for i in range(2, self.data.shape[1]): (tau2, ad, ade, adn) = allantools.adev(self.data[:,i], rate=1, data_type="freq", taus='decade') - g.replot(Gnuplot.Data(tau2, ad, ade, with_='yerrorbars', title='#%s'%str(i))) + self.curve = self.plot_widget.plot() + self.curve.setData(tau2, ad, pen=5*i, name='#%s'%i) def relativeAdevPlot(self): - g = Gnuplot.Gnuplot(persist = 1) - g('set logscale xy') - g('set grid') - g.xlabel('Tau (s)') - g.ylabel('Adev') + self.plot_widget.clear() + self.plot_widget.setTitle('relative adev plot') + self.plot_widget.setLabel('bottom', "Tau", "s") + self.plot_widget.setLabel('left', "relative adev") + self.plot_widget.setLogMode(True, True) for i in range(2, self.data.shape[1]): (tau2, ad, ade, adn) = allantools.adev(self.data[:,i]/self.data[:,i].mean(), rate=1, data_type="freq", taus='decade') - g.replot(Gnuplot.Data(tau2, ad, ade, with_='yerrorbars', title='#%s'%str(i))) + self.curve = self.plot_widget.plot() + self.curve.setData(tau2, ad, pen=5*i, name='#%s'%i) def main(self): self.show() diff --git a/allanplotUI.py b/allanplotUI.py index 59de803..d02a591 100644 --- a/allanplotUI.py +++ b/allanplotUI.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'allanplotUI.ui' # -# Created: Wed Jul 6 15:05:06 2016 +# Created: Thu Jul 7 17:46:05 2016 # by: PyQt4 UI code generator 4.11.2 # # WARNING! All changes made in this file will be lost! @@ -26,18 +26,20 @@ except AttributeError: class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) - MainWindow.resize(903, 240) + MainWindow.resize(766, 780) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.gridLayout = QtGui.QGridLayout(self.centralwidget) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.textFileList = QtGui.QTextBrowser(self.centralwidget) - self.textFileList.setObjectName(_fromUtf8("textFileList")) - self.gridLayout.addWidget(self.textFileList, 1, 3, 4, 1) self.pushOpen = QtGui.QPushButton(self.centralwidget) self.pushOpen.setObjectName(_fromUtf8("pushOpen")) self.gridLayout.addWidget(self.pushOpen, 1, 1, 1, 1) self.groupBox = QtGui.QGroupBox(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth()) + self.groupBox.setSizePolicy(sizePolicy) self.groupBox.setObjectName(_fromUtf8("groupBox")) self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) @@ -53,15 +55,40 @@ class Ui_MainWindow(object): self.pushRelativeAdevPlot = QtGui.QPushButton(self.groupBox) self.pushRelativeAdevPlot.setObjectName(_fromUtf8("pushRelativeAdevPlot")) self.verticalLayout_2.addWidget(self.pushRelativeAdevPlot) - self.gridLayout.addWidget(self.groupBox, 5, 1, 1, 1) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.gridLayout.addItem(spacerItem, 3, 1, 1, 1) + self.gridLayout.addWidget(self.groupBox, 4, 1, 1, 1) + self.textValue = QtGui.QTextBrowser(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.textValue.sizePolicy().hasHeightForWidth()) + self.textValue.setSizePolicy(sizePolicy) + self.textValue.setMinimumSize(QtCore.QSize(600, 150)) + self.textValue.setMaximumSize(QtCore.QSize(16777215, 150)) + self.textValue.setObjectName(_fromUtf8("textValue")) + self.gridLayout.addWidget(self.textValue, 4, 2, 1, 1) self.pushQuit = QtGui.QPushButton(self.centralwidget) self.pushQuit.setObjectName(_fromUtf8("pushQuit")) self.gridLayout.addWidget(self.pushQuit, 2, 1, 1, 1) - self.textValue = QtGui.QTextBrowser(self.centralwidget) - self.textValue.setObjectName(_fromUtf8("textValue")) - self.gridLayout.addWidget(self.textValue, 5, 3, 1, 1) + self.textFileList = QtGui.QTextBrowser(self.centralwidget) + self.textFileList.setEnabled(True) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.textFileList.sizePolicy().hasHeightForWidth()) + self.textFileList.setSizePolicy(sizePolicy) + self.textFileList.setMinimumSize(QtCore.QSize(600, 100)) + self.textFileList.setMaximumSize(QtCore.QSize(16777215, 100)) + self.textFileList.setObjectName(_fromUtf8("textFileList")) + self.gridLayout.addWidget(self.textFileList, 1, 2, 3, 1) + self.frame = QtGui.QFrame(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth()) + self.frame.setSizePolicy(sizePolicy) + self.frame.setMinimumSize(QtCore.QSize(700, 500)) + self.frame.setObjectName(_fromUtf8("frame")) + self.gridLayout.addWidget(self.frame, 5, 1, 1, 2) MainWindow.setCentralWidget(self.centralwidget) self.actionOpen = QtGui.QAction(MainWindow) self.actionOpen.setObjectName(_fromUtf8("actionOpen")) @@ -74,24 +101,24 @@ class Ui_MainWindow(object): QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): - MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) - self.textFileList.setHtml(_translate("MainWindow", "\n" -"\n" -"

.dat files

", None)) + MainWindow.setWindowTitle(_translate("MainWindow", "allanplot-gui", None)) self.pushOpen.setText(_translate("MainWindow", "Open", None)) self.groupBox.setTitle(_translate("MainWindow", "Plotting tools", None)) self.pushTimePlot.setText(_translate("MainWindow", "Time Plot", None)) self.pushRelativeTimePlot.setText(_translate("MainWindow", "Relative Time Plot", None)) self.pushAdevPlot.setText(_translate("MainWindow", "Adev Plot", None)) self.pushRelativeAdevPlot.setText(_translate("MainWindow", "Relative Adev Plot", None)) - self.pushQuit.setText(_translate("MainWindow", "Quit", None)) self.textValue.setHtml(_translate("MainWindow", "\n" "\n" "


", None)) + self.pushQuit.setText(_translate("MainWindow", "Quit", None)) + self.textFileList.setHtml(_translate("MainWindow", "\n" +"\n" +"

.dat files

", None)) self.actionOpen.setText(_translate("MainWindow", "Open", None)) self.actionPlot.setText(_translate("MainWindow", "Plot", None)) self.actionQuit.setText(_translate("MainWindow", "Quit", None)) diff --git a/allanplotUI.ui b/allanplotUI.ui index 9b17df9..af85aa7 100644 --- a/allanplotUI.ui +++ b/allanplotUI.ui @@ -6,26 +6,15 @@ 0 0 - 903 - 240 + 766 + 780 - MainWindow + allanplot-gui - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<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> - - - @@ -33,8 +22,14 @@ p, li { white-space: pre-wrap; } - + + + + 0 + 0 + + Plotting tools @@ -70,18 +65,34 @@ p, li { white-space: pre-wrap; } - - - - Qt::Vertical + + + + + 0 + 0 + - + - 20 - 40 + 600 + 150 - + + + 16777215 + 150 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> +<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> + + @@ -90,14 +101,51 @@ p, li { white-space: pre-wrap; } - - + + + + true + + + + 0 + 0 + + + + + 600 + 100 + + + + + 16777215 + 100 + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<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> +<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> + + + + + + + + 0 + 0 + + + + + 700 + 500 + -- 2.16.4