pvplot 1.3.0__tar.gz → 1.3.3__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.0 → pvplot-1.3.3}/PKG-INFO +1 -1
- pvplot-1.3.3/pvplot/helptxt.py +5 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/pvplot/pvplot.py +75 -44
- {pvplot-1.3.0 → pvplot-1.3.3}/pyproject.toml +1 -1
- pvplot-1.3.0/pvplot/helptxt.py +0 -6
- {pvplot-1.3.0 → pvplot-1.3.3}/LICENSE +0 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/README.md +0 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/cad_epics/__init__.py +0 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/cad_epics/epics.py +0 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/config/peakSimulator_pvp.py +0 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/config.py +0 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/config_proposal.py +0 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/pvplot/__init__.py +0 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/pvplot/__main__.py +0 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/pvplot/pvplot_tmp.py +0 -0
- {pvplot-1.3.0 → pvplot-1.3.3}/pvplot/pvplot_todo_disable_plot.py +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
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.3 2024-08-21'# Statistics shows full name of parameter
|
|
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 rich text in statistics, make it as table or use pprint
|
|
8
9
|
|
|
9
10
|
import sys, os, time, datetime
|
|
10
11
|
timer = time.perf_counter
|
|
@@ -22,6 +23,18 @@ from importlib import import_module
|
|
|
22
23
|
#````````````````````````````Constants````````````````````````````````````````
|
|
23
24
|
X,Y = 0,1
|
|
24
25
|
Scale,Units = 0,1
|
|
26
|
+
TxtColor = (0,128,128)# color of the plot texts
|
|
27
|
+
class color:
|
|
28
|
+
PURPLE = '\033[95m'
|
|
29
|
+
CYAN = '\033[96m'
|
|
30
|
+
DARKCYAN = '\033[36m'
|
|
31
|
+
BLUE = '\033[94m'
|
|
32
|
+
GREEN = '\033[92m'
|
|
33
|
+
YELLOW = '\033[93m'
|
|
34
|
+
RED = '\033[91m'
|
|
35
|
+
BOLD = '\033[1m'
|
|
36
|
+
UNDERLINE = '\033[4m'
|
|
37
|
+
END = '\033[0m'
|
|
25
38
|
#````````````````````````````Helper methods```````````````````````````````````
|
|
26
39
|
def printTime(): return time.strftime("%m%d:%H%M%S")
|
|
27
40
|
def printi(msg): print((f'INFO_PVP@{printTime()}: '+msg))
|
|
@@ -141,7 +154,7 @@ def update_data():
|
|
|
141
154
|
tt = round(time.time(),6)
|
|
142
155
|
if tt > PVPlot.lastPlotTime + PVPlot.minPlottingPeriod:
|
|
143
156
|
time2plot = True
|
|
144
|
-
PVPlot.lastPlotTime = tt
|
|
157
|
+
PVPlot.lastPlotTime = tt
|
|
145
158
|
else:
|
|
146
159
|
time2plot = False
|
|
147
160
|
|
|
@@ -156,23 +169,12 @@ def update_data():
|
|
|
156
169
|
v = timer()-tstart
|
|
157
170
|
print('update time:'+str(timer()-tstart))
|
|
158
171
|
|
|
159
|
-
def get_statistics():
|
|
160
|
-
statistics = {}
|
|
161
|
-
for dataset in MapOfDatasets.dtsDict.values():
|
|
162
|
-
s = dataset.get_statistics()
|
|
163
|
-
if len(s) != 0:
|
|
164
|
-
statistics.update(s)
|
|
165
|
-
txt = 'Parm,\tRange,\tMean,\t\tSTD\n'
|
|
166
|
-
for key,v in statistics.items():
|
|
167
|
-
txt += f'{key},\t{v["xrange"]},\t{v["mean"]},\t{v["std"]}\n'
|
|
168
|
-
return txt
|
|
169
|
-
|
|
170
172
|
def set_legend(dockNum:int, state:bool):
|
|
171
173
|
if state: # legend enabled
|
|
172
174
|
printv(f'add legends to dock{dockNum}')
|
|
173
175
|
widget = PVPlot.mapOfPlotWidgets[dockNum]
|
|
174
176
|
listOfItems = widget.getPlotItem().listDataItems()
|
|
175
|
-
l = pg.LegendItem((100,60), offset=(70,30)) # args are (size, offset)
|
|
177
|
+
l = pg.LegendItem((100,60), offset=(70,30), labelTextColor=TxtColor) # args are (size, offset)
|
|
176
178
|
l.setParentItem(widget.graphicsItem())
|
|
177
179
|
PVPlot.legend[dockNum] = l
|
|
178
180
|
for item in listOfItems:
|
|
@@ -283,9 +285,11 @@ class Dataset():
|
|
|
283
285
|
PVPlot.mapOfDocks[dockNum].addWidget(self.plotWidget)
|
|
284
286
|
printv(f'docks: {PVPlot.mapOfDocks.keys()}, widgets: {PVPlot.mapOfPlotWidgets.keys()}')
|
|
285
287
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
288
|
+
xl,yl = 'LabelX','LabelY'
|
|
289
|
+
try:
|
|
290
|
+
c = PVPlot.config
|
|
291
|
+
xl,yl = c.XLABEL,c.YLABEL
|
|
292
|
+
except: pass
|
|
289
293
|
#print(f'd:{self.dockNum}, X,Y: {xl,yl}')
|
|
290
294
|
if self.dockNum == 0 and yl != 'LabelY':
|
|
291
295
|
self.plotWidget.setLabel('left', yl)
|
|
@@ -391,14 +395,11 @@ class Dataset():
|
|
|
391
395
|
if ts:
|
|
392
396
|
if ts == self.lastTimeUpdated:
|
|
393
397
|
self.dataChanged = False
|
|
394
|
-
printv(f'curve {self.name} did not change {round(ts,3)}')
|
|
395
|
-
#if time2plot:
|
|
396
|
-
# self.plot(ts)
|
|
398
|
+
#printv(f'curve {self.name} did not change {round(ts,3)}')
|
|
397
399
|
return
|
|
398
400
|
printv(f'update_plot: {self.name,curvePars}')
|
|
399
401
|
self.dataChanged = True
|
|
400
402
|
self.lastTimeUpdated = ts
|
|
401
|
-
#printv(f'update_plot: {curvePars}, data:{yd}')
|
|
402
403
|
#print(f'update {self.name, round(ts,3), round(self.lastTimePlotted,3)}')
|
|
403
404
|
try:
|
|
404
405
|
l = len(yd)
|
|
@@ -480,12 +481,14 @@ class Dataset():
|
|
|
480
481
|
|
|
481
482
|
def get_statistics(self):
|
|
482
483
|
ileft,iright = self._visibleRange()
|
|
483
|
-
parname = self.adoPars[0][0]
|
|
484
|
+
parname = self.adoPars[0][0]
|
|
484
485
|
r = {parname:{}}
|
|
485
486
|
rp = r[parname]
|
|
486
487
|
rp['xrange'] = (ileft,iright)
|
|
487
|
-
|
|
488
|
-
rp['
|
|
488
|
+
y = np.array(self.data[Y][ileft:iright])
|
|
489
|
+
rp['mean'] = y.mean().astype('f4')
|
|
490
|
+
rp['std'] = y.std().astype('f4')
|
|
491
|
+
rp['p2p'] = (y.max() - y.min()).astype('f4')
|
|
489
492
|
return r
|
|
490
493
|
|
|
491
494
|
def get_visibleData(self):
|
|
@@ -610,7 +613,7 @@ class CustomViewBox(pg.ViewBox):
|
|
|
610
613
|
setDatasets = self.menu.addAction('Datasets &Options')
|
|
611
614
|
setDatasets.triggered.connect(self.changed_datasetOptions)
|
|
612
615
|
|
|
613
|
-
_statistics = self.menu.addAction('
|
|
616
|
+
_statistics = self.menu.addAction('&Print Statistics')
|
|
614
617
|
_statistics.triggered.connect(self.show_statistics)
|
|
615
618
|
|
|
616
619
|
_yProjection = self.menu.addAction('Show yProjection')
|
|
@@ -685,7 +688,7 @@ class CustomViewBox(pg.ViewBox):
|
|
|
685
688
|
pos = (vr[vid][1] + vr[vid][0])/2.
|
|
686
689
|
pen = pg.mkPen(color='b', width=1, style=QtCore.Qt.DotLine)
|
|
687
690
|
cursor = pg.InfiniteLine(pos=pos, pen=pen, movable=True, angle=angle
|
|
688
|
-
, label=self.cursor_text(pos,vid), labelOpts={'color':
|
|
691
|
+
, label=self.cursor_text(pos,vid), labelOpts={'color':TxtColor})#,'fill':(0,255,255)})
|
|
689
692
|
cursor.sigPositionChangeFinished.connect(\
|
|
690
693
|
(partial(self.cursorPositionChanged,cursor)))
|
|
691
694
|
self.cursors.add(cursor)
|
|
@@ -711,8 +714,8 @@ class CustomViewBox(pg.ViewBox):
|
|
|
711
714
|
rowCount,columnCount = 0,8
|
|
712
715
|
tbl = QW.QTableWidget(rowCount, columnCount, dlg)
|
|
713
716
|
tbl.setHorizontalHeaderLabels(
|
|
714
|
-
|
|
715
|
-
widths = (
|
|
717
|
+
['','Name','PV','Color','Width','Sym','Size',''])
|
|
718
|
+
widths = (10, 50, 100, 20, 80, 35, 80,80)
|
|
716
719
|
for column,width in enumerate(widths):
|
|
717
720
|
tbl.setColumnWidth(column, width)
|
|
718
721
|
tbl.setShowGrid(False)
|
|
@@ -726,18 +729,22 @@ class CustomViewBox(pg.ViewBox):
|
|
|
726
729
|
col = 0
|
|
727
730
|
cbox = QW.QCheckBox()
|
|
728
731
|
cbox.setChecked(dataset.enabled)
|
|
729
|
-
#cbox.stateChanged.connect(lambda x: self.enable_dataset(x))
|
|
730
732
|
cbox.stateChanged.connect(self.enable_dataset)
|
|
731
733
|
cbox.setObjectName(curveName)
|
|
732
734
|
tbl.setCellWidget(row, col, cbox)
|
|
733
735
|
|
|
734
736
|
col+=1
|
|
735
737
|
adoparName = dataset.adoPars[0][0]
|
|
736
|
-
|
|
738
|
+
item = QW.QTableWidgetItem(curveName)
|
|
739
|
+
#item.setTextAlignment(QtCore.Qt.AlignRight)
|
|
740
|
+
tbl.setItem(row, col, item)
|
|
737
741
|
|
|
738
742
|
col+=1
|
|
739
743
|
printv(f'dataset:{adoparName}')
|
|
740
|
-
|
|
744
|
+
txt = adoparName[-24:]
|
|
745
|
+
txt = txt[:12]+'\n'+txt[12:]
|
|
746
|
+
item = QW.QTableWidgetItem(txt)
|
|
747
|
+
tbl.setItem(row, col, QW.QTableWidgetItem(item))
|
|
741
748
|
|
|
742
749
|
col+=1
|
|
743
750
|
# color button for line
|
|
@@ -837,12 +844,9 @@ class CustomViewBox(pg.ViewBox):
|
|
|
837
844
|
update=True, disableAutoRange=True)
|
|
838
845
|
|
|
839
846
|
def show_statistics(self):
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
PVPlot.statisticsWindow.label.setText(txt)
|
|
844
|
-
PVPlot.statisticsWindow.show()
|
|
845
|
-
PVPlot.statistics = {}
|
|
847
|
+
#print(f'print statistics for {self.dockNum}')
|
|
848
|
+
PVPlot.statDock = self.dockNum
|
|
849
|
+
PVPlot.actionStatistics()
|
|
846
850
|
|
|
847
851
|
def show_yProjection(self):
|
|
848
852
|
if PVPlot.yProjectionWindow is None:
|
|
@@ -953,6 +957,7 @@ class PVPlot():
|
|
|
953
957
|
yProjectionWindow = None
|
|
954
958
|
yProjectionPlotItem = None
|
|
955
959
|
stopped = False
|
|
960
|
+
statDock = 0
|
|
956
961
|
|
|
957
962
|
def start():
|
|
958
963
|
pargs = PVPlot.pargs
|
|
@@ -972,10 +977,12 @@ class PVPlot():
|
|
|
972
977
|
# Shortcuts
|
|
973
978
|
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+H"), PVPlot.qWin)
|
|
974
979
|
shortcut.activated.connect(PVPlot.actionHelp)
|
|
980
|
+
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+P"), PVPlot.qWin)
|
|
981
|
+
shortcut.activated.connect(partial(PVPlot.actionStatistics))
|
|
975
982
|
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+S"), PVPlot.qWin)
|
|
976
|
-
shortcut.activated.connect(partial(PVPlot.actionStop
|
|
977
|
-
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+Q"), PVPlot.qWin)
|
|
978
|
-
shortcut.activated.connect(partial(PVPlot.actionStop,False))
|
|
983
|
+
shortcut.activated.connect(partial(PVPlot.actionStop))
|
|
984
|
+
#shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+Q"), PVPlot.qWin)
|
|
985
|
+
#shortcut.activated.connect(partial(PVPlot.actionStop,False))
|
|
979
986
|
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+U"), PVPlot.qWin)
|
|
980
987
|
shortcut.activated.connect(PVPlot.actionUnzoom)
|
|
981
988
|
from . import helptxt
|
|
@@ -1055,12 +1062,13 @@ class PVPlot():
|
|
|
1055
1062
|
|
|
1056
1063
|
def stop(state):
|
|
1057
1064
|
PVPlot.stopped = state
|
|
1065
|
+
suffix = ' is stopped'
|
|
1058
1066
|
if state == True:
|
|
1059
1067
|
PVPlot.qTimer.stop()
|
|
1060
|
-
title = PVPlot.qWin.windowTitle()+
|
|
1068
|
+
title = PVPlot.qWin.windowTitle()+suffix
|
|
1061
1069
|
else:
|
|
1062
1070
|
PVPlot.qTimer.start(int(PVPlot.pargs.sleepTime*1000))
|
|
1063
|
-
title = PVPlot.qWin.windowTitle().replace(
|
|
1071
|
+
title = PVPlot.qWin.windowTitle().replace(suffix,'')
|
|
1064
1072
|
PVPlot.qWin.setWindowTitle(title)
|
|
1065
1073
|
|
|
1066
1074
|
#``````````Shorthcut handlers
|
|
@@ -1069,8 +1077,9 @@ class PVPlot():
|
|
|
1069
1077
|
PVPlot.helpWin.label.setText(PVPlot.helptxt)
|
|
1070
1078
|
PVPlot.helpWin.show()
|
|
1071
1079
|
|
|
1072
|
-
def actionStop(
|
|
1073
|
-
PVPlot.
|
|
1080
|
+
def actionStop():
|
|
1081
|
+
PVPlot.stopped = not PVPlot.stopped
|
|
1082
|
+
PVPlot.stop(PVPlot.stopped)
|
|
1074
1083
|
|
|
1075
1084
|
def actionUnzoom():
|
|
1076
1085
|
md = PVPlot.mapOfDocks
|
|
@@ -1078,3 +1087,25 @@ class PVPlot():
|
|
|
1078
1087
|
for dockNum in docks:
|
|
1079
1088
|
vb = PVPlot.mapOfPlotWidgets[dockNum].getPlotItem().getViewBox()
|
|
1080
1089
|
vb.unzoom()
|
|
1090
|
+
|
|
1091
|
+
def actionStatistics():
|
|
1092
|
+
#print(f'>actionStatistics {PVPlot.statDock}')
|
|
1093
|
+
def get_statistics():
|
|
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\t\tRange \tMean \tSTD \tPeak2Peak\n'
|
|
1102
|
+
'---------\t\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
|
|
1106
|
+
if PVPlot.statisticsWindow is None:
|
|
1107
|
+
PVPlot.statisticsWindow = PopupWindow()
|
|
1108
|
+
txt = get_statistics()
|
|
1109
|
+
PVPlot.statisticsWindow.label.setText(txt)
|
|
1110
|
+
PVPlot.statisticsWindow.show()
|
|
1111
|
+
PVPlot.statistics = {}
|
pvplot-1.3.0/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
|