pymodaq 3.6.12__py3-none-any.whl → 4.0.1__py3-none-any.whl
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.
Potentially problematic release.
This version of pymodaq might be problematic. Click here for more details.
- pymodaq/__init__.py +13 -6
- pymodaq/control_modules/__init__.py +0 -7
- pymodaq/control_modules/daq_move.py +965 -2
- pymodaq/control_modules/daq_move_ui.py +319 -0
- pymodaq/control_modules/daq_viewer.py +1573 -3
- pymodaq/control_modules/daq_viewer_ui.py +393 -0
- pymodaq/control_modules/mocks.py +51 -0
- pymodaq/control_modules/move_utility_classes.py +709 -8
- pymodaq/control_modules/utils.py +256 -0
- pymodaq/control_modules/viewer_utility_classes.py +663 -6
- pymodaq/daq_utils.py +89 -0
- pymodaq/dashboard.py +91 -72
- pymodaq/examples/custom_app.py +12 -11
- pymodaq/examples/custom_viewer.py +10 -10
- pymodaq/examples/function_plotter.py +16 -13
- pymodaq/examples/nonlinearscanner.py +8 -6
- pymodaq/examples/parameter_ex.py +7 -7
- pymodaq/examples/preset_MockCamera.xml +1 -0
- pymodaq/extensions/__init__.py +16 -0
- pymodaq/extensions/console.py +76 -0
- pymodaq/{daq_logger.py → extensions/daq_logger.py} +115 -65
- pymodaq/extensions/daq_scan.py +1339 -0
- pymodaq/extensions/daq_scan_ui.py +240 -0
- pymodaq/extensions/h5browser.py +23 -0
- pymodaq/{pid → extensions/pid}/__init__.py +4 -2
- pymodaq/{pid → extensions/pid}/daq_move_PID.py +2 -2
- pymodaq/{pid → extensions/pid}/pid_controller.py +48 -36
- pymodaq/{pid → extensions/pid}/utils.py +52 -6
- pymodaq/extensions/utils.py +40 -0
- pymodaq/post_treatment/__init__.py +6 -0
- pymodaq/{daq_analysis → post_treatment/daq_analysis}/daq_analysis_main.py +17 -17
- pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_main.py +8 -14
- pymodaq/post_treatment/load_and_plot.py +219 -0
- pymodaq/post_treatment/process_to_scalar.py +263 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +1 -1
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +1 -0
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +109784 -109173
- pymodaq/resources/QtDesigner_Ressources/icons.svg +142 -0
- pymodaq/resources/VERSION +1 -1
- pymodaq/resources/config_template.toml +32 -13
- pymodaq/resources/preset_default.xml +1 -1
- pymodaq/{daq_utils → utils}/Tuto innosetup/script_full_setup.iss +1 -1
- pymodaq/utils/__init__.py +0 -29
- pymodaq/utils/abstract/__init__.py +48 -0
- pymodaq/{daq_utils → utils}/abstract/logger.py +7 -3
- pymodaq/utils/array_manipulation.py +379 -8
- pymodaq/{daq_utils → utils}/calibration_camera.py +6 -6
- pymodaq/{daq_utils → utils}/chrono_timer.py +1 -1
- pymodaq/utils/config.py +448 -0
- pymodaq/utils/conftests.py +5 -0
- pymodaq/utils/daq_utils.py +828 -8
- pymodaq/utils/data.py +1873 -7
- pymodaq/{daq_utils → utils}/db/db_logger/db_logger.py +86 -47
- pymodaq/{daq_utils → utils}/db/db_logger/db_logger_models.py +31 -10
- pymodaq/{daq_utils → utils}/enums.py +12 -7
- pymodaq/utils/exceptions.py +37 -0
- pymodaq/utils/factory.py +82 -0
- pymodaq/{daq_utils → utils}/gui_utils/__init__.py +1 -1
- pymodaq/utils/gui_utils/custom_app.py +129 -0
- pymodaq/utils/gui_utils/file_io.py +66 -0
- pymodaq/{daq_utils → utils}/gui_utils/layout.py +2 -2
- pymodaq/{daq_utils → utils}/gui_utils/utils.py +13 -3
- pymodaq/{daq_utils → utils}/gui_utils/widgets/__init__.py +2 -2
- pymodaq/utils/gui_utils/widgets/label.py +24 -0
- pymodaq/{daq_utils → utils}/gui_utils/widgets/lcd.py +12 -7
- pymodaq/{daq_utils → utils}/gui_utils/widgets/push.py +66 -2
- pymodaq/{daq_utils → utils}/gui_utils/widgets/qled.py +6 -4
- pymodaq/utils/gui_utils/widgets/spinbox.py +24 -0
- pymodaq/{daq_utils → utils}/gui_utils/widgets/table.py +2 -2
- pymodaq/utils/h5modules/__init__.py +1 -0
- pymodaq/{daq_utils/h5backend.py → utils/h5modules/backends.py} +200 -112
- pymodaq/utils/h5modules/browsing.py +683 -0
- pymodaq/utils/h5modules/data_saving.py +839 -0
- pymodaq/utils/h5modules/h5logging.py +110 -0
- pymodaq/utils/h5modules/module_saving.py +350 -0
- pymodaq/utils/h5modules/saving.py +914 -0
- pymodaq/utils/h5modules/utils.py +85 -0
- pymodaq/utils/logger.py +64 -6
- pymodaq/utils/managers/action_manager.py +460 -0
- pymodaq/{daq_utils → utils}/managers/batchscan_manager.py +144 -112
- pymodaq/{daq_utils → utils}/managers/modules_manager.py +188 -114
- pymodaq/{daq_utils → utils}/managers/overshoot_manager.py +3 -3
- pymodaq/utils/managers/parameter_manager.py +110 -0
- pymodaq/{daq_utils → utils}/managers/preset_manager.py +17 -13
- pymodaq/{daq_utils → utils}/managers/preset_manager_utils.py +8 -7
- pymodaq/{daq_utils → utils}/managers/remote_manager.py +7 -6
- pymodaq/{daq_utils → utils}/managers/roi_manager.py +148 -57
- pymodaq/utils/math_utils.py +546 -10
- pymodaq/{daq_utils → utils}/messenger.py +5 -1
- pymodaq/utils/parameter/__init__.py +2 -15
- pymodaq/{daq_utils → utils}/parameter/ioxml.py +12 -6
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/__init__.py +1 -3
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/filedir.py +1 -1
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/itemselect.py +3 -0
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/led.py +1 -1
- pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +161 -0
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/slide.py +1 -1
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/table.py +1 -1
- pymodaq/utils/parameter/utils.py +206 -11
- pymodaq/utils/plotting/data_viewers/__init__.py +6 -0
- pymodaq/utils/plotting/data_viewers/viewer.py +393 -0
- pymodaq/utils/plotting/data_viewers/viewer0D.py +251 -0
- pymodaq/utils/plotting/data_viewers/viewer1D.py +574 -0
- pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer1Dbasic.py +8 -3
- pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D.py +292 -357
- pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D_basic.py +58 -75
- pymodaq/utils/plotting/data_viewers/viewerND.py +738 -0
- pymodaq/{daq_utils → utils}/plotting/gant_chart.py +2 -2
- pymodaq/{daq_utils → utils}/plotting/items/axis_scaled.py +4 -2
- pymodaq/{daq_utils → utils}/plotting/items/image.py +8 -6
- pymodaq/utils/plotting/navigator.py +355 -0
- pymodaq/utils/plotting/scan_selector.py +480 -0
- pymodaq/utils/plotting/utils/axes_viewer.py +88 -0
- pymodaq/utils/plotting/utils/filter.py +538 -0
- pymodaq/utils/plotting/utils/lineout.py +224 -0
- pymodaq/{daq_utils → utils}/plotting/utils/plot_utils.py +196 -84
- pymodaq/{daq_utils → utils}/plotting/utils/signalND.py +21 -13
- pymodaq/utils/plotting/widgets.py +76 -0
- pymodaq/utils/scanner/__init__.py +10 -0
- pymodaq/utils/scanner/scan_factory.py +204 -0
- pymodaq/utils/scanner/scanner.py +271 -0
- pymodaq/utils/scanner/scanners/_1d_scanners.py +117 -0
- pymodaq/utils/scanner/scanners/_2d_scanners.py +293 -0
- pymodaq/utils/scanner/scanners/sequential.py +192 -0
- pymodaq/utils/scanner/scanners/tabular.py +294 -0
- pymodaq/utils/scanner/utils.py +83 -0
- pymodaq/utils/slicing.py +47 -0
- pymodaq/utils/svg/__init__.py +6 -0
- pymodaq/utils/svg/svg_renderer.py +20 -0
- pymodaq/utils/svg/svg_view.py +35 -0
- pymodaq/utils/svg/svg_viewer2D.py +51 -0
- pymodaq/{daq_utils → utils}/tcp_server_client.py +36 -37
- pymodaq/{daq_utils → utils}/tree_layout/tree_layout_main.py +50 -35
- pymodaq/utils/units.py +216 -0
- pymodaq-4.0.1.dist-info/METADATA +159 -0
- {pymodaq-3.6.12.dist-info → pymodaq-4.0.1.dist-info}/RECORD +167 -170
- {pymodaq-3.6.12.dist-info → pymodaq-4.0.1.dist-info}/WHEEL +1 -2
- pymodaq-4.0.1.dist-info/entry_points.txt +8 -0
- pymodaq/daq_move/daq_move_gui.py +0 -279
- pymodaq/daq_move/daq_move_gui.ui +0 -534
- pymodaq/daq_move/daq_move_main.py +0 -1042
- pymodaq/daq_move/process_from_QtDesigner_DAQ_Move_GUI.bat +0 -2
- pymodaq/daq_move/utility_classes.py +0 -671
- pymodaq/daq_scan.py +0 -2160
- pymodaq/daq_utils/array_manipulation.py +0 -386
- pymodaq/daq_utils/config.py +0 -273
- pymodaq/daq_utils/conftests.py +0 -7
- pymodaq/daq_utils/custom_parameter_tree.py +0 -9
- pymodaq/daq_utils/daq_enums.py +0 -133
- pymodaq/daq_utils/daq_utils.py +0 -1402
- pymodaq/daq_utils/exceptions.py +0 -71
- pymodaq/daq_utils/gui_utils/custom_app.py +0 -103
- pymodaq/daq_utils/gui_utils/file_io.py +0 -75
- pymodaq/daq_utils/gui_utils/widgets/spinbox.py +0 -9
- pymodaq/daq_utils/h5exporter_hyperspy.py +0 -115
- pymodaq/daq_utils/h5exporters.py +0 -242
- pymodaq/daq_utils/h5modules.py +0 -1559
- pymodaq/daq_utils/h5utils.py +0 -241
- pymodaq/daq_utils/managers/action_manager.py +0 -236
- pymodaq/daq_utils/managers/parameter_manager.py +0 -57
- pymodaq/daq_utils/math_utils.py +0 -705
- pymodaq/daq_utils/parameter/__init__.py +0 -1
- pymodaq/daq_utils/parameter/oldpymodaq_ptypes.py +0 -1626
- pymodaq/daq_utils/parameter/pymodaq_ptypes/pixmap.py +0 -85
- pymodaq/daq_utils/parameter/utils.py +0 -136
- pymodaq/daq_utils/plotting/data_viewers/__init__.py +0 -0
- pymodaq/daq_utils/plotting/data_viewers/process_from_QtDesigner_0DViewer_GUI.bat +0 -2
- pymodaq/daq_utils/plotting/data_viewers/viewer0D.py +0 -204
- pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.py +0 -89
- pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.ui +0 -131
- pymodaq/daq_utils/plotting/data_viewers/viewer1D.py +0 -781
- pymodaq/daq_utils/plotting/data_viewers/viewerND.py +0 -894
- pymodaq/daq_utils/plotting/data_viewers/viewerbase.py +0 -64
- pymodaq/daq_utils/plotting/items/__init__.py +0 -0
- pymodaq/daq_utils/plotting/navigator.py +0 -500
- pymodaq/daq_utils/plotting/scan_selector.py +0 -289
- pymodaq/daq_utils/plotting/utils/__init__.py +0 -0
- pymodaq/daq_utils/plotting/utils/filter.py +0 -236
- pymodaq/daq_utils/plotting/viewer0D/__init__.py +0 -0
- pymodaq/daq_utils/plotting/viewer0D/viewer0D_main.py +0 -4
- pymodaq/daq_utils/plotting/viewer1D/__init__.py +0 -0
- pymodaq/daq_utils/plotting/viewer1D/viewer1D_main.py +0 -4
- pymodaq/daq_utils/plotting/viewer1D/viewer1Dbasic.py +0 -4
- pymodaq/daq_utils/plotting/viewer2D/viewer_2D_basic.py +0 -4
- pymodaq/daq_utils/plotting/viewer2D/viewer_2D_main.py +0 -4
- pymodaq/daq_utils/plotting/viewerND/__init__.py +0 -0
- pymodaq/daq_utils/plotting/viewerND/viewerND_main.py +0 -4
- pymodaq/daq_utils/scanner.py +0 -1289
- pymodaq/daq_utils/tree_layout/__init__.py +0 -0
- pymodaq/daq_viewer/__init__.py +0 -0
- pymodaq/daq_viewer/daq_gui_settings.py +0 -237
- pymodaq/daq_viewer/daq_gui_settings.ui +0 -441
- pymodaq/daq_viewer/daq_viewer_main.py +0 -2225
- pymodaq/daq_viewer/process_from_QtDesigner_DAQ_GUI_settings.bat +0 -2
- pymodaq/daq_viewer/utility_classes.py +0 -673
- pymodaq/examples/logger_image/__init__.py +0 -0
- pymodaq/examples/logger_image/logger_displayer.py +0 -121
- pymodaq/examples/logger_image/setup.svg +0 -3119
- pymodaq/examples/logger_image/setup_svg.py +0 -114
- pymodaq/h5browser.py +0 -39
- pymodaq/utils/scanner.py +0 -15
- pymodaq-3.6.12.dist-info/METADATA +0 -39
- pymodaq-3.6.12.dist-info/entry_points.txt +0 -8
- pymodaq-3.6.12.dist-info/top_level.txt +0 -1
- /pymodaq/{daq_analysis → post_treatment/daq_analysis}/__init__.py +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/__init__.py +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.py +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.ui +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/process_from_QtDesigner_DAQ_Measurement_GUI.bat +0 -0
- /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.odt +0 -0
- /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.pdf +0 -0
- /pymodaq/{daq_move → utils/db}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils/db/db_logger}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/gui_utils/dock.py +0 -0
- /pymodaq/{daq_utils → utils}/gui_utils/list_picker.py +0 -0
- /pymodaq/{daq_utils/abstract → utils/managers}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/bool.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/date.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/list.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/numeric.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/tableview.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/text.py +0 -0
- /pymodaq/{daq_utils/db → utils/plotting}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/plotting/image_viewer.py +0 -0
- /pymodaq/{daq_utils/db/db_logger → utils/plotting/items}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/plotting/items/crosshair.py +0 -0
- /pymodaq/{daq_utils/managers → utils/plotting/utils}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/qvariant.py +0 -0
- /pymodaq/{daq_utils/plotting/viewer2D → utils/scanner/scanners}/__init__.py +0 -0
- /pymodaq/{daq_utils/plotting → utils/tree_layout}/__init__.py +0 -0
- {pymodaq-3.6.12.dist-info → pymodaq-4.0.1.dist-info/licenses}/LICENSE +0 -0
|
@@ -1,781 +0,0 @@
|
|
|
1
|
-
from qtpy import QtWidgets
|
|
2
|
-
from qtpy.QtCore import QObject, Slot, Signal, Qt
|
|
3
|
-
from qtpy.QtGui import QIcon, QPixmap
|
|
4
|
-
import sys
|
|
5
|
-
|
|
6
|
-
from pymodaq.daq_utils.parameter import utils as putils
|
|
7
|
-
from pymodaq.daq_measurement.daq_measurement_main import DAQ_Measurement
|
|
8
|
-
from collections import OrderedDict
|
|
9
|
-
from pymodaq.daq_utils.plotting.items.crosshair import Crosshair
|
|
10
|
-
import pyqtgraph as pg
|
|
11
|
-
import numpy as np
|
|
12
|
-
from pymodaq.daq_utils import daq_utils as utils
|
|
13
|
-
from pymodaq.daq_utils import math_utils as mutils
|
|
14
|
-
from pymodaq.daq_utils.managers.action_manager import QAction
|
|
15
|
-
from pymodaq.daq_utils.plotting.data_viewers.viewer1Dbasic import Viewer1DBasic
|
|
16
|
-
from pymodaq.daq_utils.managers.roi_manager import ROIManager
|
|
17
|
-
import datetime
|
|
18
|
-
|
|
19
|
-
logger = utils.set_logger(utils.get_module_name(__file__))
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class Viewer1D(QtWidgets.QWidget, QObject):
|
|
23
|
-
"""this plots 1D data on a plotwidget. Math and measurement can be done on it. Datas and measurements are then exported with the signal
|
|
24
|
-
data_to_export_signal
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
data_to_export_signal = Signal(OrderedDict) # self.data_to_export=edict(data0D=None,data1D=None,data2D=None)
|
|
28
|
-
math_signal = Signal(OrderedDict) # OrderedDict:=[x_axis=...,data=...,ROI_bounds=...,operation=]
|
|
29
|
-
ROI_changed = Signal()
|
|
30
|
-
ROI_changed_finished = Signal()
|
|
31
|
-
|
|
32
|
-
def __init__(self, parent=None):
|
|
33
|
-
|
|
34
|
-
super().__init__()
|
|
35
|
-
|
|
36
|
-
self.viewer_type = 'Data1D'
|
|
37
|
-
self.title = 'viewer1D'
|
|
38
|
-
if parent is None:
|
|
39
|
-
parent = QtWidgets.QWidget()
|
|
40
|
-
self.parent = parent
|
|
41
|
-
|
|
42
|
-
self.roi_manager = ROIManager('1D')
|
|
43
|
-
self.roi_manager.new_ROI_signal.connect(self.add_lineout)
|
|
44
|
-
self.roi_manager.remove_ROI_signal.connect(self.remove_ROI)
|
|
45
|
-
# self.roi_manager.ROI_changed_finished.connect(self.update_lineouts)
|
|
46
|
-
|
|
47
|
-
self.setupUI()
|
|
48
|
-
|
|
49
|
-
self.wait_time = 3000
|
|
50
|
-
self.measurement_module = None
|
|
51
|
-
|
|
52
|
-
self.math_module = Viewer1D_math()
|
|
53
|
-
|
|
54
|
-
if DAQ_Measurement is None: # pragma: no cover
|
|
55
|
-
self.ui.do_measurements_pb.setVisible(False)
|
|
56
|
-
|
|
57
|
-
self._labels = []
|
|
58
|
-
self.plot_channels = None
|
|
59
|
-
self.plot_colors = utils.plot_colors
|
|
60
|
-
self.color_list = ROIManager.color_list
|
|
61
|
-
self.lo_items = OrderedDict([])
|
|
62
|
-
self.lo_data = OrderedDict([])
|
|
63
|
-
self.ROI_bounds = []
|
|
64
|
-
|
|
65
|
-
self._x_axis = None
|
|
66
|
-
|
|
67
|
-
self.datas = [] # datas on each channel. list of 1D arrays
|
|
68
|
-
self.data_to_export = None
|
|
69
|
-
self.measurement_dict = OrderedDict(x_axis=None, datas=[], ROI_bounds=[], operations=[], channels=[])
|
|
70
|
-
# OrderedDict to be send to the daq_measurement module
|
|
71
|
-
self.measure_data_dict = OrderedDict()
|
|
72
|
-
# dictionnary with data to be put in the table on the form: key="Meas.{}:".format(ind)
|
|
73
|
-
# and value is the result of a given lineout or measurement
|
|
74
|
-
|
|
75
|
-
def setupUI(self):
|
|
76
|
-
|
|
77
|
-
self.ui = QObject()
|
|
78
|
-
|
|
79
|
-
self.parent.setLayout(QtWidgets.QVBoxLayout())
|
|
80
|
-
splitter_hor = QtWidgets.QSplitter(Qt.Horizontal)
|
|
81
|
-
|
|
82
|
-
# self.ui.statusbar = QtWidgets.QStatusBar()
|
|
83
|
-
# self.ui.statusbar.setMaximumHeight(15)
|
|
84
|
-
|
|
85
|
-
self.parent.layout().addWidget(splitter_hor)
|
|
86
|
-
#self.parent.layout().addWidget(self.ui.statusbar)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
splitter_ver = QtWidgets.QSplitter(Qt.Vertical)
|
|
90
|
-
splitter_hor.addWidget(splitter_ver)
|
|
91
|
-
splitter_hor.addWidget(self.roi_manager.roiwidget)
|
|
92
|
-
self.roi_manager.roiwidget.hide()
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
self.ui.button_widget = QtWidgets.QToolBar()
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
splitter_ver.addWidget(self.ui.button_widget)
|
|
99
|
-
|
|
100
|
-
self.ui.Graph_Lineouts = pg.PlotWidget()
|
|
101
|
-
|
|
102
|
-
widg = QtWidgets.QWidget()
|
|
103
|
-
self.viewer = Viewer1DBasic(widg)
|
|
104
|
-
splitter_ver.addWidget(widg)
|
|
105
|
-
splitter_ver.addWidget(self.ui.Graph_Lineouts)
|
|
106
|
-
self.ui.Graph1D = self.viewer # for backcompatibility
|
|
107
|
-
self.roi_manager.viewer_widget = self.viewer.plotwidget
|
|
108
|
-
|
|
109
|
-
self.setup_buttons(self.ui.button_widget)
|
|
110
|
-
self.setup_zoom()
|
|
111
|
-
|
|
112
|
-
self.legend = None
|
|
113
|
-
self.axis_settings = dict(orientation='bottom', label='x axis', units='pxls')
|
|
114
|
-
|
|
115
|
-
self.ui.xaxis_item = self.viewer.plotwidget.plotItem.getAxis('bottom')
|
|
116
|
-
self.ui.Graph_Lineouts.hide()
|
|
117
|
-
|
|
118
|
-
self.ui.aspect_ratio_pb.triggered.connect(self.lock_aspect_ratio)
|
|
119
|
-
|
|
120
|
-
# #crosshair
|
|
121
|
-
self.ui.crosshair = Crosshair(self.viewer.plotwidget.plotItem, orientation='vertical')
|
|
122
|
-
self.ui.crosshair.crosshair_dragged.connect(self.update_crosshair_data)
|
|
123
|
-
self.ui.crosshair_pb.triggered.connect(self.crosshairClicked)
|
|
124
|
-
self.crosshairClicked()
|
|
125
|
-
|
|
126
|
-
# self.ui.Measurement_widget=Dock("Measurement Module", size=(300, 100), closable=True)
|
|
127
|
-
# self.dockarea.addDock(self.ui.Measurement_widget)
|
|
128
|
-
self.ui.Measurement_widget = QtWidgets.QWidget()
|
|
129
|
-
self.ui.Measurement_widget.setVisible(False)
|
|
130
|
-
|
|
131
|
-
# #Connecting buttons:
|
|
132
|
-
self.ui.Do_math_pb.triggered.connect(self.do_math_fun)
|
|
133
|
-
self.ui.do_measurements_pb.triggered.connect(self.open_measurement_module)
|
|
134
|
-
self.ui.zoom_pb.triggered.connect(self.enable_zoom)
|
|
135
|
-
self.ui.scatter.triggered.connect(self.do_scatter)
|
|
136
|
-
self.ui.xyplot_action.triggered.connect(self.do_xy)
|
|
137
|
-
|
|
138
|
-
def setup_buttons(self, button_widget):
|
|
139
|
-
|
|
140
|
-
self.ui.zoom_pb = QAction(QIcon(QPixmap(":/icons/Icon_Library/Zoom_to_Selection.png")), 'Zoom Widget')
|
|
141
|
-
self.ui.zoom_pb.setCheckable(True)
|
|
142
|
-
button_widget.addAction(self.ui.zoom_pb)
|
|
143
|
-
|
|
144
|
-
self.ui.Do_math_pb = QAction(QIcon(QPixmap(":/icons/Icon_Library/Calculator.png")), 'Do Math using ROI')
|
|
145
|
-
self.ui.Do_math_pb.setCheckable(True)
|
|
146
|
-
button_widget.addAction(self.ui.Do_math_pb)
|
|
147
|
-
|
|
148
|
-
self.ui.do_measurements_pb = QAction(QIcon(QPixmap(":/icons/Icon_Library/MeasurementStudio_32.png")),
|
|
149
|
-
'Do Advanced measurements (fits,...)')
|
|
150
|
-
self.ui.do_measurements_pb.setCheckable(True)
|
|
151
|
-
button_widget.addAction(self.ui.do_measurements_pb)
|
|
152
|
-
|
|
153
|
-
self.ui.crosshair_pb = QAction(QIcon(QPixmap(":/icons/Icon_Library/reset.png")),
|
|
154
|
-
'Show data cursor')
|
|
155
|
-
self.ui.crosshair_pb.setCheckable(True)
|
|
156
|
-
button_widget.addAction(self.ui.crosshair_pb)
|
|
157
|
-
|
|
158
|
-
self.ui.aspect_ratio_pb = QAction(QIcon(QPixmap(":/icons/Icon_Library/zoomReset.png")),
|
|
159
|
-
'Fix the aspect ratio')
|
|
160
|
-
self.ui.aspect_ratio_pb.setCheckable(True)
|
|
161
|
-
button_widget.addAction(self.ui.aspect_ratio_pb)
|
|
162
|
-
|
|
163
|
-
self.ui.scatter = QAction(QIcon(QPixmap(":/icons/Icon_Library/Marker.png")),
|
|
164
|
-
'Switch between line or scatter plots')
|
|
165
|
-
self.ui.scatter.setCheckable(True)
|
|
166
|
-
button_widget.addAction(self.ui.scatter)
|
|
167
|
-
|
|
168
|
-
self.ui.xyplot_action = QAction(QIcon(QPixmap(":/icons/Icon_Library/2d.png")),
|
|
169
|
-
'Switch between normal or XY representation (valid for 2 channels)')
|
|
170
|
-
self.ui.xyplot_action.setCheckable(True)
|
|
171
|
-
button_widget.addAction(self.ui.xyplot_action)
|
|
172
|
-
self.ui.xyplot_action.setVisible(False)
|
|
173
|
-
|
|
174
|
-
self.ui.x_label = QAction('x:')
|
|
175
|
-
button_widget.addAction(self.ui.x_label)
|
|
176
|
-
|
|
177
|
-
self.ui.y_label = QAction('y:')
|
|
178
|
-
button_widget.addAction(self.ui.y_label)
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
def setup_zoom(self):
|
|
182
|
-
# create and set the zoom widget
|
|
183
|
-
# self.ui.zoom_widget=Dock("1DViewer zoom", size=(300, 100), closable=True)
|
|
184
|
-
self.ui.zoom_widget = QtWidgets.QWidget()
|
|
185
|
-
layout = QtWidgets.QHBoxLayout()
|
|
186
|
-
|
|
187
|
-
self.ui.Graph_zoom = pg.PlotWidget()
|
|
188
|
-
layout.addWidget(self.ui.Graph_zoom)
|
|
189
|
-
self.ui.zoom_widget.setLayout(layout)
|
|
190
|
-
|
|
191
|
-
self.ui.zoom_region = pg.LinearRegionItem()
|
|
192
|
-
self.ui.zoom_region.setZValue(-10)
|
|
193
|
-
self.ui.zoom_region.setBrush('r')
|
|
194
|
-
self.ui.zoom_region.setOpacity(0.2)
|
|
195
|
-
self.ui.Graph_zoom.addItem(self.ui.zoom_region)
|
|
196
|
-
self.zoom_plot = []
|
|
197
|
-
# self.dockarea.addDock(self.ui.zoom_widget)
|
|
198
|
-
self.ui.zoom_widget.setVisible(False)
|
|
199
|
-
|
|
200
|
-
def do_scatter(self):
|
|
201
|
-
self.update_graph1D(self.datas)
|
|
202
|
-
|
|
203
|
-
def do_xy(self):
|
|
204
|
-
if self.ui.xyplot_action.isChecked():
|
|
205
|
-
axis = self.viewer.plotwidget.plotItem.getAxis('bottom')
|
|
206
|
-
axis.setLabel(text=self.labels[0], units='')
|
|
207
|
-
axis = self.viewer.plotwidget.plotItem.getAxis('left')
|
|
208
|
-
axis.setLabel(text=self.labels[1], units='')
|
|
209
|
-
self.legend.setVisible(False)
|
|
210
|
-
else:
|
|
211
|
-
self.set_axis_label(dict(orientation='bottom', label=self.axis_settings['label'],
|
|
212
|
-
units=self.axis_settings['units']))
|
|
213
|
-
axis = self.viewer.plotwidget.plotItem.getAxis('left')
|
|
214
|
-
axis.setLabel(text='', units='')
|
|
215
|
-
self.legend.setVisible(True)
|
|
216
|
-
self.update_graph1D(self.datas)
|
|
217
|
-
|
|
218
|
-
def update_lineouts(self):
|
|
219
|
-
try:
|
|
220
|
-
operations = []
|
|
221
|
-
channels = []
|
|
222
|
-
for ind, key in enumerate(self.roi_manager.ROIs):
|
|
223
|
-
operations.append(self.roi_manager.settings.child('ROIs', key, 'math_function').value())
|
|
224
|
-
channels.append(
|
|
225
|
-
self.roi_manager.settings.child('ROIs', key,
|
|
226
|
-
'use_channel').opts['limits'].index(
|
|
227
|
-
self.roi_manager.settings.child('ROIs',
|
|
228
|
-
key, 'use_channel').value()))
|
|
229
|
-
self.lo_items[key].setPen(self.roi_manager.settings.child('ROIs', key,
|
|
230
|
-
'Color').value())
|
|
231
|
-
|
|
232
|
-
self.measurement_dict['datas'] = self.datas
|
|
233
|
-
self.measurement_dict['ROI_bounds'] = [self.roi_manager.ROIs[item].getRegion() for item in
|
|
234
|
-
self.roi_manager.ROIs]
|
|
235
|
-
self.measurement_dict['channels'] = channels
|
|
236
|
-
self.measurement_dict['operations'] = operations
|
|
237
|
-
|
|
238
|
-
data_lo = self.math_module.update_math(self.measurement_dict)
|
|
239
|
-
self.show_math(data_lo)
|
|
240
|
-
except Exception as e:
|
|
241
|
-
pass
|
|
242
|
-
|
|
243
|
-
@Slot(str)
|
|
244
|
-
def remove_ROI(self, roi_name):
|
|
245
|
-
|
|
246
|
-
item = self.lo_items.pop(roi_name)
|
|
247
|
-
self.ui.Graph_Lineouts.plotItem.removeItem(item)
|
|
248
|
-
self.measure_data_dict.pop("Lineout_{:s}:".format(roi_name))
|
|
249
|
-
self.update_lineouts()
|
|
250
|
-
|
|
251
|
-
@Slot(int, str)
|
|
252
|
-
def add_lineout(self, index, roi_type=''):
|
|
253
|
-
try:
|
|
254
|
-
item = self.roi_manager.ROIs['ROI_{:02d}'.format(index)]
|
|
255
|
-
item_param = self.roi_manager.settings.child('ROIs', 'ROI_{:02d}'.format(index))
|
|
256
|
-
item_param.child(('use_channel')).setOpts(limits=self.labels)
|
|
257
|
-
if len(self.labels) == 0: # pragma: no cover
|
|
258
|
-
lab = ''
|
|
259
|
-
else:
|
|
260
|
-
lab = self.labels[0]
|
|
261
|
-
item_param.child(('use_channel')).setValue(lab)
|
|
262
|
-
item.sigRegionChanged.connect(self.update_lineouts)
|
|
263
|
-
item.sigRegionChangeFinished.connect(lambda: self.ROI_changed_finished.emit())
|
|
264
|
-
for child in putils.iter_children_params(item_param, childlist=[]):
|
|
265
|
-
if child.type() != 'group':
|
|
266
|
-
child.sigValueChanged.connect(self.update_lineouts)
|
|
267
|
-
|
|
268
|
-
item_lo = self.ui.Graph_Lineouts.plot()
|
|
269
|
-
item_lo.setPen(item_param.child(('Color')).value())
|
|
270
|
-
self.lo_items['ROI_{:02d}'.format(index)] = item_lo
|
|
271
|
-
self.lo_data = OrderedDict([])
|
|
272
|
-
for k in self.lo_items:
|
|
273
|
-
self.lo_data[k] = np.zeros((1,))
|
|
274
|
-
self.update_lineouts()
|
|
275
|
-
except Exception as e:
|
|
276
|
-
logger.exception(str(e))
|
|
277
|
-
|
|
278
|
-
def clear_lo(self):
|
|
279
|
-
self.lo_data = [[] for ind in range(len(self.lo_data))]
|
|
280
|
-
self.update_lineouts()
|
|
281
|
-
|
|
282
|
-
def crosshairClicked(self):
|
|
283
|
-
if self.ui.crosshair_pb.isChecked():
|
|
284
|
-
self.ui.crosshair.setVisible(True)
|
|
285
|
-
self.ui.x_label.setVisible(True)
|
|
286
|
-
self.ui.y_label.setVisible(True)
|
|
287
|
-
range = self.viewer.plotwidget.plotItem.vb.viewRange()
|
|
288
|
-
self.ui.crosshair.set_crosshair_position(xpos=np.mean(np.array(range[0])))
|
|
289
|
-
else:
|
|
290
|
-
self.ui.crosshair.setVisible(False)
|
|
291
|
-
self.ui.x_label.setVisible(False)
|
|
292
|
-
self.ui.y_label.setVisible(False)
|
|
293
|
-
|
|
294
|
-
def do_math_fun(self):
|
|
295
|
-
try:
|
|
296
|
-
if self.ui.Do_math_pb.isChecked():
|
|
297
|
-
self.roi_manager.roiwidget.show()
|
|
298
|
-
self.ui.Graph_Lineouts.show()
|
|
299
|
-
|
|
300
|
-
else:
|
|
301
|
-
self.ui.Graph_Lineouts.hide()
|
|
302
|
-
self.roi_manager.roiwidget.hide()
|
|
303
|
-
|
|
304
|
-
except Exception as e:
|
|
305
|
-
logger.exception(str(e))
|
|
306
|
-
|
|
307
|
-
def do_zoom(self):
|
|
308
|
-
bounds = self.ui.zoom_region.getRegion()
|
|
309
|
-
self.viewer.plotwidget.setXRange(bounds[0], bounds[1])
|
|
310
|
-
|
|
311
|
-
def enable_zoom(self):
|
|
312
|
-
try:
|
|
313
|
-
if not (self.ui.zoom_pb.isChecked()):
|
|
314
|
-
if self.zoom_plot != []:
|
|
315
|
-
for plot in self.zoom_plot:
|
|
316
|
-
self.ui.Graph_zoom.removeItem(plot)
|
|
317
|
-
self.ui.zoom_widget.hide()
|
|
318
|
-
self.ui.zoom_region.sigRegionChanged.disconnect(self.do_zoom)
|
|
319
|
-
|
|
320
|
-
else:
|
|
321
|
-
self.zoom_plot = []
|
|
322
|
-
for ind, data in enumerate(self.datas):
|
|
323
|
-
channel = self.ui.Graph_zoom.plot()
|
|
324
|
-
channel.setPen(self.plot_colors[ind])
|
|
325
|
-
self.zoom_plot.append(channel)
|
|
326
|
-
self.update_graph1D(self.datas)
|
|
327
|
-
self.ui.zoom_region.setRegion([np.min(self._x_axis), np.max(self._x_axis)])
|
|
328
|
-
|
|
329
|
-
self.ui.zoom_widget.show()
|
|
330
|
-
self.ui.zoom_region.sigRegionChanged.connect(self.do_zoom)
|
|
331
|
-
except Exception as e:
|
|
332
|
-
logger.exception(str(e))
|
|
333
|
-
|
|
334
|
-
def ini_data_plots(self, Nplots):
|
|
335
|
-
try:
|
|
336
|
-
self.plot_channels = []
|
|
337
|
-
# if self.legend is not None:
|
|
338
|
-
# self.viewer.plotwidget.plotItem.removeItem(self.legend)
|
|
339
|
-
self.legend = self.viewer.plotwidget.plotItem.legend
|
|
340
|
-
flag = True
|
|
341
|
-
while flag:
|
|
342
|
-
items = [item[1].text for item in self.legend.items]
|
|
343
|
-
if len(items) == 0:
|
|
344
|
-
flag = False
|
|
345
|
-
else:
|
|
346
|
-
self.legend.removeItem(items[0])
|
|
347
|
-
channels = []
|
|
348
|
-
for ind in range(Nplots):
|
|
349
|
-
channel = self.viewer.plotwidget.plot()
|
|
350
|
-
channel.setPen(self.plot_colors[ind])
|
|
351
|
-
self.legend.addItem(channel, self._labels[ind])
|
|
352
|
-
channels.append(ind)
|
|
353
|
-
self.plot_channels.append(channel)
|
|
354
|
-
except Exception as e:
|
|
355
|
-
logger.exception(str(e))
|
|
356
|
-
|
|
357
|
-
def update_labels(self, labels=[]):
|
|
358
|
-
try:
|
|
359
|
-
labels_tmp = labels[:]
|
|
360
|
-
if self.labels == labels:
|
|
361
|
-
if self.labels == [] or len(self.labels) < len(self.datas):
|
|
362
|
-
self._labels = [f"CH{ind:02d}" for ind in range(len(self.datas))]
|
|
363
|
-
else:
|
|
364
|
-
if self.legend is not None:
|
|
365
|
-
flag = True
|
|
366
|
-
while flag:
|
|
367
|
-
items = [item[1].text for item in self.legend.items]
|
|
368
|
-
if len(items) == 0:
|
|
369
|
-
flag = False
|
|
370
|
-
else:
|
|
371
|
-
self.legend.removeItem(items[0])
|
|
372
|
-
|
|
373
|
-
if len(labels) < len(self.plot_channels):
|
|
374
|
-
for ind in range(len(labels), len(self.plot_channels)):
|
|
375
|
-
labels_tmp.append(f'CH{ind:02d}')
|
|
376
|
-
|
|
377
|
-
if len(labels_tmp) == len(self.plot_channels):
|
|
378
|
-
for ind, channel in enumerate(self.plot_channels):
|
|
379
|
-
self.legend.addItem(channel, labels_tmp[ind])
|
|
380
|
-
|
|
381
|
-
self._labels = labels_tmp
|
|
382
|
-
|
|
383
|
-
if self.labels != labels:
|
|
384
|
-
for ind in range(len(self.roi_manager.ROIs)):
|
|
385
|
-
val = self.roi_manager.settings.child('ROIs', 'ROI_{:02d}'.format(ind), 'use_channel').value()
|
|
386
|
-
self.roi_manager.settings.child('ROIs', 'ROI_{:02d}'.format(ind), 'use_channel').setOpts(
|
|
387
|
-
limits=self.labels)
|
|
388
|
-
if val not in self.labels:
|
|
389
|
-
self.roi_manager.settings.child('ROIs', 'ROI_{:02d}'.format(ind), 'use_channel').setValue(
|
|
390
|
-
self.labels[0])
|
|
391
|
-
|
|
392
|
-
self.ui.xyplot_action.setVisible(len(self.labels) == 2)
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
except Exception as e:
|
|
396
|
-
logger.exception(str(e))
|
|
397
|
-
|
|
398
|
-
@property
|
|
399
|
-
def labels(self):
|
|
400
|
-
return self._labels
|
|
401
|
-
|
|
402
|
-
@labels.setter
|
|
403
|
-
def labels(self, labels):
|
|
404
|
-
self.update_labels(labels)
|
|
405
|
-
self._labels = labels
|
|
406
|
-
|
|
407
|
-
def lock_aspect_ratio(self):
|
|
408
|
-
if self.ui.aspect_ratio_pb.isChecked():
|
|
409
|
-
self.viewer.plotwidget.plotItem.vb.setAspectLocked(lock=True, ratio=1)
|
|
410
|
-
else:
|
|
411
|
-
self.viewer.plotwidget.plotItem.vb.setAspectLocked(lock=False)
|
|
412
|
-
|
|
413
|
-
def open_measurement_module(self):
|
|
414
|
-
if not (self.ui.Do_math_pb.isChecked()):
|
|
415
|
-
self.ui.Do_math_pb.setChecked(True)
|
|
416
|
-
QtWidgets.QApplication.processEvents()
|
|
417
|
-
self.ui.Do_math_pb.triggered.emit()
|
|
418
|
-
QtWidgets.QApplication.processEvents()
|
|
419
|
-
|
|
420
|
-
self.ui.Measurement_widget.setVisible(True)
|
|
421
|
-
if self.ui.do_measurements_pb.isChecked():
|
|
422
|
-
Form = self.ui.Measurement_widget
|
|
423
|
-
self.measurement_module = DAQ_Measurement(Form)
|
|
424
|
-
# self.ui.Measurement_widget.addWidget(Form)
|
|
425
|
-
self.measurement_module.measurement_signal[list].connect(self.show_measurement)
|
|
426
|
-
self.update_measurement_module()
|
|
427
|
-
|
|
428
|
-
elif self.measurement_module is not None:
|
|
429
|
-
self.measurement_module.Quit_fun()
|
|
430
|
-
|
|
431
|
-
def remove_plots(self):
|
|
432
|
-
if self.plot_channels is not None:
|
|
433
|
-
for channel in self.plot_channels:
|
|
434
|
-
self.viewer.plotwidget.removeItem(channel)
|
|
435
|
-
self.plot_channels = None
|
|
436
|
-
if self.legend is not None:
|
|
437
|
-
self.viewer.plotwidget.removeItem(self.legend)
|
|
438
|
-
|
|
439
|
-
def set_axis_label(self, axis_settings=dict(orientation='bottom', label='x axis', units='pxls')):
|
|
440
|
-
axis = self.viewer.plotwidget.plotItem.getAxis(axis_settings['orientation'])
|
|
441
|
-
axis.setLabel(text=axis_settings['label'], units=axis_settings['units'])
|
|
442
|
-
self.axis_settings = axis_settings
|
|
443
|
-
|
|
444
|
-
@Slot(list)
|
|
445
|
-
def show_data(self, datas, labels=None, x_axis=None):
|
|
446
|
-
try:
|
|
447
|
-
self.datas = datas
|
|
448
|
-
self.update_labels(self.labels)
|
|
449
|
-
|
|
450
|
-
self.data_to_export = OrderedDict(name=self.title, data0D=OrderedDict(), data1D=OrderedDict(), data2D=None)
|
|
451
|
-
for ind, data in enumerate(datas):
|
|
452
|
-
self.data_to_export['data1D']['CH{:03d}'.format(ind)] = utils.DataToExport()
|
|
453
|
-
|
|
454
|
-
if self.plot_channels == [] or self.plot_channels is None: # initialize data and plots
|
|
455
|
-
self.ini_data_plots(len(datas))
|
|
456
|
-
|
|
457
|
-
elif len(self.plot_channels) != len(datas):
|
|
458
|
-
self.remove_plots()
|
|
459
|
-
self.ini_data_plots(len(datas))
|
|
460
|
-
|
|
461
|
-
if x_axis is not None:
|
|
462
|
-
self.set_x_axis(x_axis)
|
|
463
|
-
|
|
464
|
-
self.update_graph1D(datas)
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if labels is not None:
|
|
469
|
-
self.update_labels(labels)
|
|
470
|
-
|
|
471
|
-
if self.ui.do_measurements_pb.isChecked():
|
|
472
|
-
self.update_measurement_module()
|
|
473
|
-
|
|
474
|
-
except Exception as e:
|
|
475
|
-
logger.exception(str(e))
|
|
476
|
-
|
|
477
|
-
@Slot(list)
|
|
478
|
-
def show_data_temp(self, datas):
|
|
479
|
-
"""f
|
|
480
|
-
to plot temporary data, for instance when all pixels are not yet populated...
|
|
481
|
-
"""
|
|
482
|
-
try:
|
|
483
|
-
self.update_labels(self.labels)
|
|
484
|
-
self.datas = datas
|
|
485
|
-
|
|
486
|
-
if self.plot_channels is None: # initialize data and plots
|
|
487
|
-
self.ini_data_plots(len(datas))
|
|
488
|
-
elif len(self.plot_channels) != len(datas):
|
|
489
|
-
self.remove_plots()
|
|
490
|
-
self.ini_data_plots(len(datas))
|
|
491
|
-
|
|
492
|
-
for ind_plot, data in enumerate(datas):
|
|
493
|
-
if self.x_axis is None:
|
|
494
|
-
self.x_axis = np.linspace(0, len(data), len(data), endpoint=False)
|
|
495
|
-
x_axis = self.x_axis
|
|
496
|
-
elif len(self.x_axis) != len(data):
|
|
497
|
-
x_axis = np.linspace(0, len(data), len(data), endpoint=False)
|
|
498
|
-
else:
|
|
499
|
-
x_axis = self.x_axis
|
|
500
|
-
|
|
501
|
-
self.plot_channels[ind_plot].setData(x=x_axis, y=data)
|
|
502
|
-
except Exception as e:
|
|
503
|
-
logger.exception(str(e))
|
|
504
|
-
|
|
505
|
-
@Slot(list)
|
|
506
|
-
def show_math(self, data_lo):
|
|
507
|
-
# self.data_to_export=OrderedDict(x_axis=None,y_axis=None,z_axis=None,data0D=None,data1D=None,data2D=None)
|
|
508
|
-
if len(data_lo) != 0:
|
|
509
|
-
for ind, key in enumerate(self.lo_items):
|
|
510
|
-
self.measure_data_dict["Lineout_{:s}:".format(key)] = data_lo[ind]
|
|
511
|
-
self.data_to_export['data0D']['Measure_{:03d}'.format(ind)] = utils.DataToExport(name=self.title,
|
|
512
|
-
data=data_lo[ind],
|
|
513
|
-
source='roi')
|
|
514
|
-
self.roi_manager.settings.child(('measurements')).setValue(self.measure_data_dict)
|
|
515
|
-
|
|
516
|
-
for ind, key in enumerate(self.lo_items):
|
|
517
|
-
self.lo_data[key] = np.append(self.lo_data[key], data_lo[ind])
|
|
518
|
-
self.lo_items[key].setData(y=self.lo_data[key])
|
|
519
|
-
|
|
520
|
-
if not (self.ui.do_measurements_pb.isChecked()): # otherwise you export data from measurement
|
|
521
|
-
self.data_to_export['acq_time_s'] = datetime.datetime.now().timestamp()
|
|
522
|
-
self.data_to_export_signal.emit(self.data_to_export)
|
|
523
|
-
|
|
524
|
-
@Slot(list)
|
|
525
|
-
def show_measurement(self, data_meas):
|
|
526
|
-
ind_offset = len(self.data_to_export['data0D'])
|
|
527
|
-
for ind, res in enumerate(data_meas):
|
|
528
|
-
self.measure_data_dict["Meas.{}:".format(ind)] = res
|
|
529
|
-
self.data_to_export['data0D']['Measure_{:03d}'.format(ind + ind_offset)] = \
|
|
530
|
-
utils.DataToExport(name=self.title, data=res, source='roi')
|
|
531
|
-
self.roi_manager.settings.child('measurements').setValue(self.measure_data_dict)
|
|
532
|
-
self.data_to_export['acq_time_s'] = datetime.datetime.now().timestamp()
|
|
533
|
-
self.data_to_export_signal.emit(self.data_to_export)
|
|
534
|
-
|
|
535
|
-
def update_crosshair_data(self, posx, posy, name=""):
|
|
536
|
-
try:
|
|
537
|
-
indx = mutils.find_index(self._x_axis, posx)[0][0]
|
|
538
|
-
|
|
539
|
-
string = "y="
|
|
540
|
-
for data in self.datas:
|
|
541
|
-
string += "{:.6e} / ".format(data[indx])
|
|
542
|
-
self.ui.y_label.setText(string)
|
|
543
|
-
self.ui.x_label.setText("x={:.6e} ".format(posx))
|
|
544
|
-
|
|
545
|
-
except Exception as e:
|
|
546
|
-
pass
|
|
547
|
-
|
|
548
|
-
def update_graph1D(self, datas):
|
|
549
|
-
# self.data_to_export=OrderedDict(data0D=OrderedDict(),data1D=OrderedDict(),data2D=None)
|
|
550
|
-
try:
|
|
551
|
-
|
|
552
|
-
pens = []
|
|
553
|
-
symbolBrushs = []
|
|
554
|
-
symbolSize = 5
|
|
555
|
-
for ind, ch in enumerate(self.plot_channels):
|
|
556
|
-
if self.ui.scatter.isChecked():
|
|
557
|
-
pens.append(None)
|
|
558
|
-
symbol = 'o'
|
|
559
|
-
symbolBrushs.append(self.plot_colors[ind])
|
|
560
|
-
else:
|
|
561
|
-
pens.append(self.plot_colors[ind])
|
|
562
|
-
symbol = None
|
|
563
|
-
|
|
564
|
-
symbolBrushs.append(None)
|
|
565
|
-
|
|
566
|
-
if self.x_axis is None:
|
|
567
|
-
self._x_axis = np.linspace(0, len(datas[0]), len(datas[0]), endpoint=False)
|
|
568
|
-
elif len(self.x_axis) != len(datas[0]):
|
|
569
|
-
self._x_axis = np.linspace(0, len(datas[0]), len(datas[0]), endpoint=False)
|
|
570
|
-
|
|
571
|
-
for ind_plot, data in enumerate(datas):
|
|
572
|
-
if not self.ui.xyplot_action.isChecked() or len(datas) == 0:
|
|
573
|
-
self.plot_channels[ind_plot].setData(x=self.x_axis, y=data, pen=pens[ind_plot], symbol=symbol,
|
|
574
|
-
symbolBrush=symbolBrushs[ind_plot], symbolSize=symbolSize,
|
|
575
|
-
pxMode=True)
|
|
576
|
-
else:
|
|
577
|
-
self.plot_channels[ind_plot].setData(x=np.array([]), y=np.array([]), pen=pens[ind_plot], symbol=symbol,
|
|
578
|
-
symbolBrush=symbolBrushs[ind_plot], symbolSize=symbolSize,
|
|
579
|
-
pxMode=True)
|
|
580
|
-
if self.ui.zoom_pb.isChecked():
|
|
581
|
-
self.zoom_plot[ind_plot].setData(x=self.x_axis, y=data)
|
|
582
|
-
x_axis = utils.Axis(data=self.x_axis, units=self.axis_settings['units'],
|
|
583
|
-
label=self.axis_settings['label'])
|
|
584
|
-
self.data_to_export['data1D']['CH{:03d}'.format(ind_plot)].update(
|
|
585
|
-
OrderedDict(name=self.title, data=data, x_axis=x_axis, source='raw')) # to be saved or exported
|
|
586
|
-
|
|
587
|
-
if self.ui.xyplot_action.isChecked() and len(datas) > 1:
|
|
588
|
-
self.plot_channels[0].setData(x=datas[0], y=datas[1], pen=pens[0], symbol=symbol,
|
|
589
|
-
symbolBrush=symbolBrushs[0], symbolSize=symbolSize,
|
|
590
|
-
pxMode=True)
|
|
591
|
-
|
|
592
|
-
if not self.ui.Do_math_pb.isChecked(): # otherwise math is done and then data is exported
|
|
593
|
-
self.data_to_export['acq_time_s'] = datetime.datetime.now().timestamp()
|
|
594
|
-
self.data_to_export_signal.emit(self.data_to_export)
|
|
595
|
-
else:
|
|
596
|
-
self.measurement_dict['datas'] = datas
|
|
597
|
-
if self.measurement_dict['x_axis'] is None:
|
|
598
|
-
self.measurement_dict['x_axis'] = self._x_axis
|
|
599
|
-
data_lo = self.math_module.update_math(self.measurement_dict)
|
|
600
|
-
self.show_math(data_lo)
|
|
601
|
-
|
|
602
|
-
except Exception as e:
|
|
603
|
-
logger.exception(str(e))
|
|
604
|
-
|
|
605
|
-
def update_measurement_module(self):
|
|
606
|
-
xdata = self.measurement_dict['x_axis']
|
|
607
|
-
ydata = self.measurement_dict['datas'][0]
|
|
608
|
-
if xdata is None:
|
|
609
|
-
self.measurement_module.update_data(ydata=ydata)
|
|
610
|
-
else:
|
|
611
|
-
self.measurement_module.update_data(xdata=xdata, ydata=ydata)
|
|
612
|
-
|
|
613
|
-
def update_status(self, txt):
|
|
614
|
-
logger.info(txt)
|
|
615
|
-
|
|
616
|
-
@property
|
|
617
|
-
def x_axis(self):
|
|
618
|
-
return self._x_axis
|
|
619
|
-
|
|
620
|
-
@x_axis.setter
|
|
621
|
-
def x_axis(self, x_axis):
|
|
622
|
-
self.set_x_axis(x_axis)
|
|
623
|
-
if self.datas:
|
|
624
|
-
self.show_data_temp(self.datas)
|
|
625
|
-
|
|
626
|
-
def set_x_axis(self, x_axis):
|
|
627
|
-
label = 'Pxls'
|
|
628
|
-
units = ''
|
|
629
|
-
if isinstance(x_axis, dict):
|
|
630
|
-
if 'data' in x_axis:
|
|
631
|
-
xdata = x_axis['data']
|
|
632
|
-
if 'label' in x_axis:
|
|
633
|
-
label = x_axis['label']
|
|
634
|
-
if 'units' in x_axis:
|
|
635
|
-
units = x_axis['units']
|
|
636
|
-
else:
|
|
637
|
-
xdata = x_axis
|
|
638
|
-
self._x_axis = xdata
|
|
639
|
-
self.measurement_dict['x_axis'] = self._x_axis
|
|
640
|
-
self.set_axis_label(dict(orientation='bottom', label=label, units=units))
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
class Viewer1D_math(QObject):
|
|
644
|
-
status_sig = Signal(list)
|
|
645
|
-
|
|
646
|
-
def __init__(self):
|
|
647
|
-
super(QObject, self).__init__()
|
|
648
|
-
self.datas = []
|
|
649
|
-
self.ROI_bounds = []
|
|
650
|
-
self.x_axis = None
|
|
651
|
-
self.operations = []
|
|
652
|
-
self.channels = []
|
|
653
|
-
|
|
654
|
-
def update_math(self, measurement_dict):
|
|
655
|
-
try:
|
|
656
|
-
if 'datas' in measurement_dict:
|
|
657
|
-
self.datas = measurement_dict['datas']
|
|
658
|
-
if 'ROI_bounds' in measurement_dict:
|
|
659
|
-
self.ROI_bounds = measurement_dict['ROI_bounds']
|
|
660
|
-
if 'x_axis' in measurement_dict:
|
|
661
|
-
self.x_axis = measurement_dict['x_axis']
|
|
662
|
-
if 'operations' in measurement_dict:
|
|
663
|
-
self.operations = measurement_dict['operations']
|
|
664
|
-
if 'channels' in measurement_dict:
|
|
665
|
-
self.channels = measurement_dict['channels']
|
|
666
|
-
|
|
667
|
-
# self.status_sig.emit(["Update_Status","doing math"])
|
|
668
|
-
data_lo = []
|
|
669
|
-
for ind_meas in range(len(self.operations)):
|
|
670
|
-
indexes = mutils.find_index(self.x_axis, self.ROI_bounds[ind_meas])
|
|
671
|
-
ind1 = indexes[0][0]
|
|
672
|
-
ind2 = indexes[1][0]
|
|
673
|
-
sub_data = self.datas[self.channels[ind_meas]][ind1:ind2]
|
|
674
|
-
sub_xaxis = self.x_axis[ind1:ind2]
|
|
675
|
-
|
|
676
|
-
if self.operations[ind_meas] == "Mean":
|
|
677
|
-
data_lo.append(float(np.mean(sub_data)))
|
|
678
|
-
elif self.operations[ind_meas] == "Sum":
|
|
679
|
-
data_lo.append(float(np.sum(sub_data)))
|
|
680
|
-
else:
|
|
681
|
-
ind_x0 = mutils.find_index(sub_data, np.max(sub_data))[0][0]
|
|
682
|
-
x0 = sub_xaxis[ind_x0]
|
|
683
|
-
max = np.max(sub_data)
|
|
684
|
-
moments = mutils.my_moment(sub_xaxis, sub_data)
|
|
685
|
-
|
|
686
|
-
sub_data = sub_data - np.min(sub_data)
|
|
687
|
-
if self.operations[ind_meas] in ['half-life', 'expotime']:
|
|
688
|
-
sub_xaxis = sub_xaxis[ind_x0:]
|
|
689
|
-
sub_data = sub_data[ind_x0:]
|
|
690
|
-
|
|
691
|
-
if self.operations[ind_meas] == 'half-life':
|
|
692
|
-
val_to_append = sub_xaxis[mutils.find_index(sub_data, 0.5 * max)[0][0]] - x0
|
|
693
|
-
elif self.operations[ind_meas] == 'expotime':
|
|
694
|
-
val_to_append = sub_xaxis[mutils.find_index(sub_data, 0.37 * max)[0][0]] - x0
|
|
695
|
-
elif self.operations[ind_meas] == 'fwhm':
|
|
696
|
-
ind_x0m, fwhm_value = mutils.find_index(sub_data, max / 2)[0]
|
|
697
|
-
val_to_append = (sub_xaxis[ind_x0] - sub_xaxis[ind_x0m]) * 2
|
|
698
|
-
elif self.operations[ind_meas] == 'moment':
|
|
699
|
-
val_to_append = moments[0]
|
|
700
|
-
elif self.operations[ind_meas] == 'fwhm_moment2':
|
|
701
|
-
val_to_append = np.sqrt(8*np.log(2)) * moments[1]
|
|
702
|
-
data_lo.append(val_to_append)
|
|
703
|
-
|
|
704
|
-
return data_lo
|
|
705
|
-
except Exception as e:
|
|
706
|
-
logger.exception(str(e))
|
|
707
|
-
return []
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
def main():
|
|
711
|
-
app = QtWidgets.QApplication(sys.argv)
|
|
712
|
-
Form = QtWidgets.QWidget()
|
|
713
|
-
prog = Viewer1D(Form)
|
|
714
|
-
|
|
715
|
-
from pymodaq.daq_utils.math_utils import gauss1D
|
|
716
|
-
|
|
717
|
-
x = np.linspace(0, 200, 201)
|
|
718
|
-
y1 = gauss1D(x, 75, 25 / (np.sqrt(2))) # so the measured FWHM should be 25
|
|
719
|
-
y2 = gauss1D(x, 120, 50, 2)
|
|
720
|
-
tau_half = 27
|
|
721
|
-
tau2 = 100
|
|
722
|
-
x0 = 50
|
|
723
|
-
dx = 20
|
|
724
|
-
ydata_expodec = np.zeros((len(x)))
|
|
725
|
-
ydata_expodec[:50] = 1 * gauss1D(x[:50], x0, dx, 2)
|
|
726
|
-
ydata_expodec[50:] = 1 * np.exp(-(x[50:] - x0) / (tau_half / np.log(2))) # +1*np.exp(-(x[50:]-x0)/tau2)
|
|
727
|
-
ydata_expodec += 0.1 * np.random.rand(len(x))
|
|
728
|
-
|
|
729
|
-
# x = np.sin(np.linspace(0,6*np.pi,201))
|
|
730
|
-
# y = np.sin(np.linspace(0, 6*np.pi, 201)+np.pi/2)
|
|
731
|
-
|
|
732
|
-
Form.show()
|
|
733
|
-
prog.ui.Do_math_pb.click()
|
|
734
|
-
QtWidgets.QApplication.processEvents()
|
|
735
|
-
prog.x_axis = x
|
|
736
|
-
# prog.show_data([y, y+2])
|
|
737
|
-
prog.show_data([y1, y2, ydata_expodec])
|
|
738
|
-
QtWidgets.QApplication.processEvents()
|
|
739
|
-
prog.update_labels(['coucou', 'label2'])
|
|
740
|
-
sys.exit(app.exec_())
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
def main_unsorted():
|
|
744
|
-
app = QtWidgets.QApplication(sys.argv)
|
|
745
|
-
widget = QtWidgets.QWidget()
|
|
746
|
-
prog = Viewer1D(widget)
|
|
747
|
-
|
|
748
|
-
from pymodaq.daq_utils.daq_utils import gauss1D
|
|
749
|
-
|
|
750
|
-
x = np.linspace(0, 200, 201)
|
|
751
|
-
xaxis = np.concatenate((x, x[::-1]))
|
|
752
|
-
y = gauss1D(x, 75, 25)
|
|
753
|
-
yaxis = np.concatenate((y, -y))
|
|
754
|
-
|
|
755
|
-
widget.show()
|
|
756
|
-
prog.show_data([yaxis], x_axis=xaxis)
|
|
757
|
-
|
|
758
|
-
sys.exit(app.exec_())
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
def main_nans():
|
|
762
|
-
app = QtWidgets.QApplication(sys.argv)
|
|
763
|
-
widget = QtWidgets.QWidget()
|
|
764
|
-
prog = Viewer1D(widget)
|
|
765
|
-
|
|
766
|
-
from pymodaq.daq_utils.daq_utils import gauss1D
|
|
767
|
-
|
|
768
|
-
x = np.linspace(0, 200, 201)
|
|
769
|
-
y = gauss1D(x, 75, 25)
|
|
770
|
-
|
|
771
|
-
y[100:150] = np.nan
|
|
772
|
-
|
|
773
|
-
widget.show()
|
|
774
|
-
prog.show_data([y], x_axis=x)
|
|
775
|
-
|
|
776
|
-
sys.exit(app.exec_())
|
|
777
|
-
|
|
778
|
-
if __name__ == '__main__': # pragma: no cover
|
|
779
|
-
main()
|
|
780
|
-
#main_unsorted()
|
|
781
|
-
#main_nans()
|