pvplot 1.3.2__tar.gz → 1.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pvplot-1.3.2 → pvplot-1.3.4}/PKG-INFO +1 -1
- pvplot-1.3.4/pvplot/helptxt.py +5 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/pvplot/pvplot.py +134 -62
- {pvplot-1.3.2 → pvplot-1.3.4}/pyproject.toml +1 -1
- pvplot-1.3.2/pvplot/helptxt.py +0 -5
- {pvplot-1.3.2 → pvplot-1.3.4}/LICENSE +0 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/README.md +0 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/cad_epics/__init__.py +0 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/cad_epics/epics.py +0 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/config/peakSimulator_pvp.py +0 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/config.py +0 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/config_proposal.py +0 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/pvplot/__init__.py +0 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/pvplot/__main__.py +0 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/pvplot/pvplot_tmp.py +0 -0
- {pvplot-1.3.2 → pvplot-1.3.4}/pvplot/pvplot_todo_disable_plot.py +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""Plotting package for EPICS PVs, ADO and LITE parameters.
|
|
3
3
|
"""
|
|
4
|
-
__version__ = 'v1.3.
|
|
4
|
+
__version__ = 'v1.3.4 2024-08-30'# Statistics is table, time2plot corrected, close all windows on exit.
|
|
5
5
|
#TODO: if backend times out the gui is not responsive
|
|
6
6
|
#TODO: move Add Dataset to Dataset options
|
|
7
7
|
#TODO: add dataset arithmetics
|
|
8
|
-
#TODO: Use teich text in statistics
|
|
9
8
|
|
|
10
9
|
import sys, os, time, datetime
|
|
11
10
|
timer = time.perf_counter
|
|
@@ -147,23 +146,118 @@ def split_slice(parNameSlice):
|
|
|
147
146
|
else:
|
|
148
147
|
vslice = (r0, int(vrange[1]))
|
|
149
148
|
return devParSlice[0], vslice
|
|
149
|
+
|
|
150
|
+
def get_statistics():
|
|
151
|
+
statList = []
|
|
152
|
+
for dataset in MapOfDatasets.dtsDict.values():
|
|
153
|
+
#if dataset.dockNum != PVPlot.statDock:
|
|
154
|
+
# continue
|
|
155
|
+
s = dataset.get_statistics()
|
|
156
|
+
#print(f's: {s}')
|
|
157
|
+
if len(s) != 0:
|
|
158
|
+
for key,v in s.items():
|
|
159
|
+
statList.append([key, *v["xrange"],
|
|
160
|
+
f'{v["mean"]:.6g}', f'{v["std"]:.6g}',
|
|
161
|
+
f'{v["p2p"]:.6g}'])
|
|
162
|
+
return statList
|
|
163
|
+
|
|
164
|
+
class PopupWindow(QW.QWidget):
|
|
165
|
+
""" This "window" is a QWidget. If it has no parent, it
|
|
166
|
+
will appear as a free-floating window as we want.
|
|
167
|
+
Note: The created window will not be closed on app exit.
|
|
168
|
+
To make it happen, the MainWindow should call close this widget in its closeEvent()
|
|
169
|
+
"""
|
|
170
|
+
def __init__(self):
|
|
171
|
+
super().__init__()
|
|
172
|
+
qr = PVPlot.qWin.geometry()
|
|
173
|
+
self.setGeometry(QtCore.QRect(qr.x(), qr.y(), 0, 0))
|
|
174
|
+
self.setWindowTitle('Statistics')
|
|
175
|
+
layout = QW.QVBoxLayout()
|
|
176
|
+
self.label = QW.QLabel()
|
|
177
|
+
self.label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
|
|
178
|
+
layout.addWidget(self.label)
|
|
179
|
+
self.setLayout(layout)
|
|
180
|
+
|
|
181
|
+
class TableModel(QtCore.QAbstractTableModel):
|
|
182
|
+
def __init__(self, data, headers):
|
|
183
|
+
super(TableModel, self).__init__()
|
|
184
|
+
self._data = data
|
|
185
|
+
self.headers = headers
|
|
186
|
+
|
|
187
|
+
def headerData(self, section: int, orientation: QtCore.Qt.Orientation, role=QtCore.Qt.DisplayRole):
|
|
188
|
+
if role == QtCore.Qt.DisplayRole and orientation == QtCore.Qt.Horizontal:
|
|
189
|
+
try: r = self.headers[section]
|
|
190
|
+
except: r = f's{section+1}'
|
|
191
|
+
return r
|
|
192
|
+
|
|
193
|
+
def data(self, index, role):
|
|
194
|
+
if role == QtCore.Qt.DisplayRole:
|
|
195
|
+
# See below for the nested-list data structure.
|
|
196
|
+
# .row() indexes into the outer list,
|
|
197
|
+
# .column() indexes into the sub-list
|
|
198
|
+
return self._data[index.row()][index.column()]
|
|
199
|
+
|
|
200
|
+
def rowCount(self, parent=QtCore.QModelIndex()):
|
|
201
|
+
# The length of the outer list.
|
|
202
|
+
return len(self._data)
|
|
203
|
+
|
|
204
|
+
def columnCount(self, parent=QtCore.QModelIndex()):
|
|
205
|
+
# The following takes the first sub-list, and returns
|
|
206
|
+
# the length (only works if all rows are an equal length)
|
|
207
|
+
return len(self._data[0])
|
|
208
|
+
|
|
209
|
+
def refresh_data(self, data):
|
|
210
|
+
self._data = data
|
|
211
|
+
#print(f'>refresh_data: {self._data}')
|
|
212
|
+
topLeft = self.createIndex(0, 0)
|
|
213
|
+
bottomRight = self.createIndex(self.rowCount(), self.columnCount())
|
|
214
|
+
self.dataChanged.emit(topLeft, bottomRight)
|
|
215
|
+
|
|
216
|
+
class TableWindow(QW.QWidget):
|
|
217
|
+
"""
|
|
218
|
+
This "window" is a QWidget. If it has no parent, it
|
|
219
|
+
will appear as a free-floating window.
|
|
220
|
+
"""
|
|
221
|
+
def __init__(self, data, headers=[]):
|
|
222
|
+
super().__init__()
|
|
223
|
+
self.setWindowTitle('Statistics')
|
|
224
|
+
layout = QW.QVBoxLayout()
|
|
225
|
+
self.table = QW.QTableView()
|
|
226
|
+
self.model = TableModel(data, headers)
|
|
227
|
+
self.table.setModel(self.model)
|
|
228
|
+
hh = self.table.horizontalHeader()
|
|
229
|
+
#DNW#hh.setSectionResizeMode(QW.QHeaderView.ResizeToContents)
|
|
230
|
+
#hh.setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch)
|
|
231
|
+
hh.setSectionResizeMode(0, QW.QHeaderView.ResizeMode.ResizeToContents)
|
|
232
|
+
hh.setSectionResizeMode(1, QW.QHeaderView.ResizeMode.ResizeToContents)
|
|
233
|
+
hh.setSectionResizeMode(2, QW.QHeaderView.ResizeMode.ResizeToContents)
|
|
234
|
+
layout.addWidget(self.table)
|
|
235
|
+
self.setLayout(layout)
|
|
236
|
+
|
|
237
|
+
qr = PVPlot.qWin.geometry()
|
|
238
|
+
'''
|
|
239
|
+
vh = self.table.verticalHeader()
|
|
240
|
+
extra = (30,30)
|
|
241
|
+
sz = (hh.length() + vh.width() + extra[X],
|
|
242
|
+
vh.length() + hh.height() + extra[Y])
|
|
243
|
+
self.setGeometry(QtCore.QRect(qr.x(), qr.y(), sz[0], sz[1]))
|
|
244
|
+
'''
|
|
245
|
+
self.move(qr.x(), qr.y())
|
|
246
|
+
self.table.setShowGrid(False)
|
|
247
|
+
self.table.setSizeAdjustPolicy(
|
|
248
|
+
QW.QAbstractScrollArea.AdjustToContents)
|
|
150
249
|
#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
|
151
250
|
def update_data():
|
|
152
251
|
""" called on QtCore.qTimer() event to update plots."""
|
|
153
252
|
tstart = timer()
|
|
154
253
|
tt = round(time.time(),6)
|
|
155
|
-
if tt > PVPlot.lastPlotTime + PVPlot.minPlottingPeriod:
|
|
156
|
-
time2plot = True
|
|
157
|
-
PVPlot.lastPlotTime = tt
|
|
158
|
-
else:
|
|
159
|
-
time2plot = False
|
|
160
254
|
|
|
161
255
|
for dataset in MapOfDatasets.dtsDict.values():
|
|
162
|
-
dataset.update_plot(
|
|
256
|
+
dataset.update_plot()
|
|
163
257
|
if dataset.dataChanged:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
258
|
+
if tt > dataset.lastPlotted + PVPlot.minPlottingPeriod:
|
|
259
|
+
dataset.lastPlotted = tt
|
|
260
|
+
dataset.plot(tt)
|
|
167
261
|
|
|
168
262
|
if PVPlot.perfmon:
|
|
169
263
|
v = timer()-tstart
|
|
@@ -248,6 +342,7 @@ class Dataset():
|
|
|
248
342
|
self.timeAxis = False
|
|
249
343
|
self.statistics = {}
|
|
250
344
|
self.enabled = True
|
|
345
|
+
self.lastPlotted = 0
|
|
251
346
|
|
|
252
347
|
# ``````````````````` Add plotItem ``````````````````````````````````````
|
|
253
348
|
#dockNum = name.split('.')[0]
|
|
@@ -382,7 +477,7 @@ class Dataset():
|
|
|
382
477
|
#TODO:pxMode = self.pxMode,
|
|
383
478
|
)
|
|
384
479
|
|
|
385
|
-
def update_plot(self
|
|
480
|
+
def update_plot(self):
|
|
386
481
|
curvePars = self.adoPars
|
|
387
482
|
yd,ts = None,None
|
|
388
483
|
try:
|
|
@@ -457,9 +552,6 @@ class Dataset():
|
|
|
457
552
|
self.data[X][:tmp[X].shape[0]] = tmp[X]
|
|
458
553
|
#printi(f'adjust {self.name} from {tmp[X].shape} to {self.data[X].shape}')
|
|
459
554
|
|
|
460
|
-
if time2plot:
|
|
461
|
-
self.plot(ts)
|
|
462
|
-
|
|
463
555
|
def _visibleRange(self):
|
|
464
556
|
npt = self.dataPtr
|
|
465
557
|
#print(f'viewRange={self.viewBox.viewRange()}')
|
|
@@ -481,7 +573,7 @@ class Dataset():
|
|
|
481
573
|
|
|
482
574
|
def get_statistics(self):
|
|
483
575
|
ileft,iright = self._visibleRange()
|
|
484
|
-
parname = self.adoPars[0][0]
|
|
576
|
+
parname = self.adoPars[0][0]
|
|
485
577
|
r = {parname:{}}
|
|
486
578
|
rp = r[parname]
|
|
487
579
|
rp['xrange'] = (ileft,iright)
|
|
@@ -545,23 +637,6 @@ class MapOfDatasets():
|
|
|
545
637
|
dataset = MapOfDatasets.dtsDict[name]
|
|
546
638
|
dataset.plotWidget.removeItem(dataset.plotItem)
|
|
547
639
|
del MapOfDatasets.dtsDict[dataset.name]
|
|
548
|
-
|
|
549
|
-
class PopupWindow(QW.QWidget):
|
|
550
|
-
""" This "window" is a QWidget. If it has no parent, it
|
|
551
|
-
will appear as a free-floating window as we want.
|
|
552
|
-
Note: The created window will not be closed on app exit.
|
|
553
|
-
To make it happen, the MainWindow should call close this widget in its closeEvent()
|
|
554
|
-
"""
|
|
555
|
-
def __init__(self):
|
|
556
|
-
super().__init__()
|
|
557
|
-
qr = PVPlot.qWin.geometry()
|
|
558
|
-
self.setGeometry(QtCore.QRect(qr.x(), qr.y(), 0, 0))
|
|
559
|
-
self.setWindowTitle('Statistics')
|
|
560
|
-
layout = QW.QVBoxLayout()
|
|
561
|
-
self.label = QW.QLabel()
|
|
562
|
-
self.label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
|
|
563
|
-
layout.addWidget(self.label)
|
|
564
|
-
self.setLayout(layout)
|
|
565
640
|
#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
|
566
641
|
#`````````````````````````````````````````````````````````````````````````````
|
|
567
642
|
class CustomViewBox(pg.ViewBox):
|
|
@@ -613,10 +688,10 @@ class CustomViewBox(pg.ViewBox):
|
|
|
613
688
|
setDatasets = self.menu.addAction('Datasets &Options')
|
|
614
689
|
setDatasets.triggered.connect(self.changed_datasetOptions)
|
|
615
690
|
|
|
616
|
-
_statistics = self.menu.addAction('&
|
|
691
|
+
_statistics = self.menu.addAction('Show &Mean,sigma')
|
|
617
692
|
_statistics.triggered.connect(self.show_statistics)
|
|
618
693
|
|
|
619
|
-
_yProjection = self.menu.addAction('Show
|
|
694
|
+
_yProjection = self.menu.addAction('Show &YProjection')
|
|
620
695
|
_yProjection.triggered.connect(self.show_yProjection)
|
|
621
696
|
|
|
622
697
|
cursorMenu = self.menu.addMenu('Add &Cursor')
|
|
@@ -638,7 +713,7 @@ class CustomViewBox(pg.ViewBox):
|
|
|
638
713
|
self.menu.addAction(labelY)
|
|
639
714
|
|
|
640
715
|
backgroundAction = QW.QWidgetAction(self.menu)
|
|
641
|
-
backgroundGui = QW.QCheckBox('
|
|
716
|
+
backgroundGui = QW.QCheckBox('Black background')
|
|
642
717
|
backgroundGui.stateChanged.connect(
|
|
643
718
|
lambda x: self.setBackgroundColor(\
|
|
644
719
|
'k' if x == QtCore.Qt.Checked else 'w'))
|
|
@@ -646,7 +721,7 @@ class CustomViewBox(pg.ViewBox):
|
|
|
646
721
|
self.menu.addAction(backgroundAction)
|
|
647
722
|
|
|
648
723
|
legenAction = QW.QWidgetAction(self.menu)
|
|
649
|
-
legendGui = QW.QCheckBox('
|
|
724
|
+
legendGui = QW.QCheckBox('Legend')
|
|
650
725
|
legendGui.setChecked(True)
|
|
651
726
|
legendGui.stateChanged.connect(lambda x: self.set_legend(x))
|
|
652
727
|
legenAction.setDefaultWidget(legendGui)
|
|
@@ -845,7 +920,7 @@ class CustomViewBox(pg.ViewBox):
|
|
|
845
920
|
|
|
846
921
|
def show_statistics(self):
|
|
847
922
|
#print(f'print statistics for {self.dockNum}')
|
|
848
|
-
PVPlot.statDock = self.dockNum
|
|
923
|
+
#PVPlot.statDock = self.dockNum
|
|
849
924
|
PVPlot.actionStatistics()
|
|
850
925
|
|
|
851
926
|
def show_yProjection(self):
|
|
@@ -856,7 +931,7 @@ class CustomViewBox(pg.ViewBox):
|
|
|
856
931
|
|
|
857
932
|
PVPlot.yProjectionWindow.show()
|
|
858
933
|
PVPlot.yProjectionWindow.setWindowTitle(
|
|
859
|
-
f'Vertical projection of {self.dataset.
|
|
934
|
+
f'Vertical projection of {self.dataset.name}')
|
|
860
935
|
self.dataset.show_yProjection()
|
|
861
936
|
|
|
862
937
|
def enable_dataset(self, state):
|
|
@@ -936,6 +1011,15 @@ def parse_input_parameters(pargs):
|
|
|
936
1011
|
tmpClass.DOCKS[0][parm] = parms
|
|
937
1012
|
return tmpClass
|
|
938
1013
|
|
|
1014
|
+
class MainWindow(QW.QMainWindow):
|
|
1015
|
+
def closeEvent(self,event):
|
|
1016
|
+
print('Closing all windows')
|
|
1017
|
+
try: PVPlot.statisticsWindow.close()
|
|
1018
|
+
except: pass
|
|
1019
|
+
try: PVPlot.helpWin.close()
|
|
1020
|
+
except: pass
|
|
1021
|
+
event.accept()
|
|
1022
|
+
|
|
939
1023
|
class PVPlot():
|
|
940
1024
|
config = None
|
|
941
1025
|
pargs = None
|
|
@@ -957,7 +1041,7 @@ class PVPlot():
|
|
|
957
1041
|
yProjectionWindow = None
|
|
958
1042
|
yProjectionPlotItem = None
|
|
959
1043
|
stopped = False
|
|
960
|
-
statDock = 0
|
|
1044
|
+
#statDock = 0
|
|
961
1045
|
|
|
962
1046
|
def start():
|
|
963
1047
|
pargs = PVPlot.pargs
|
|
@@ -966,7 +1050,7 @@ class PVPlot():
|
|
|
966
1050
|
try: os.environ["QT_SCALE_FACTOR"] = str(pargs.zoomin)
|
|
967
1051
|
except: pass
|
|
968
1052
|
qApp = QApplication([])
|
|
969
|
-
PVPlot.qWin =
|
|
1053
|
+
PVPlot.qWin = MainWindow()
|
|
970
1054
|
PVPlot.dockArea = dockarea.DockArea()
|
|
971
1055
|
PVPlot.qWin.setCentralWidget(PVPlot.dockArea)
|
|
972
1056
|
PVPlot.qWin.resize(1000,500)
|
|
@@ -977,12 +1061,12 @@ class PVPlot():
|
|
|
977
1061
|
# Shortcuts
|
|
978
1062
|
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+H"), PVPlot.qWin)
|
|
979
1063
|
shortcut.activated.connect(PVPlot.actionHelp)
|
|
980
|
-
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+
|
|
1064
|
+
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+M"), PVPlot.qWin)
|
|
981
1065
|
shortcut.activated.connect(partial(PVPlot.actionStatistics))
|
|
1066
|
+
#shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+O"), PVPlot.qWin)
|
|
1067
|
+
#shortcut.activated.connect(partial(PVPlot.actionDatasetOptions))
|
|
982
1068
|
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+S"), PVPlot.qWin)
|
|
983
1069
|
shortcut.activated.connect(partial(PVPlot.actionStop))
|
|
984
|
-
#shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+Q"), PVPlot.qWin)
|
|
985
|
-
#shortcut.activated.connect(partial(PVPlot.actionStop,False))
|
|
986
1070
|
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+U"), PVPlot.qWin)
|
|
987
1071
|
shortcut.activated.connect(PVPlot.actionUnzoom)
|
|
988
1072
|
from . import helptxt
|
|
@@ -1090,22 +1174,10 @@ class PVPlot():
|
|
|
1090
1174
|
|
|
1091
1175
|
def actionStatistics():
|
|
1092
1176
|
#print(f'>actionStatistics {PVPlot.statDock}')
|
|
1093
|
-
|
|
1094
|
-
statistics = {}
|
|
1095
|
-
for dataset in MapOfDatasets.dtsDict.values():
|
|
1096
|
-
if dataset.dockNum != PVPlot.statDock:
|
|
1097
|
-
continue
|
|
1098
|
-
s = dataset.get_statistics()
|
|
1099
|
-
if len(s) != 0:
|
|
1100
|
-
statistics.update(s)
|
|
1101
|
-
txt = ('Parameter,\tRange \tMean \tSTD \tPeak2Peak\n'
|
|
1102
|
-
'----------\t------\t------\t------\t---------\n')
|
|
1103
|
-
for key,v in statistics.items():
|
|
1104
|
-
txt += f'{key}:\t{v["xrange"]}\t{v["mean"]:.6g}\t{v["std"]:.6g}\t{v["p2p"]:.6g}\n'
|
|
1105
|
-
return txt
|
|
1177
|
+
sl = get_statistics()
|
|
1106
1178
|
if PVPlot.statisticsWindow is None:
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
PVPlot.statisticsWindow.
|
|
1110
|
-
PVPlot.statisticsWindow.show()
|
|
1111
|
-
|
|
1179
|
+
header = ['Parameter','XMin','XMax','Mean','StDev','Peak2Peak']
|
|
1180
|
+
PVPlot.statisticsWindow = TableWindow(sl, header)
|
|
1181
|
+
PVPlot.statisticsWindow.model.refresh_data(sl)
|
|
1182
|
+
PVPlot.statisticsWindow.show()
|
|
1183
|
+
|
pvplot-1.3.2/pvplot/helptxt.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|