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
|
@@ -4,21 +4,20 @@ Created on Fri Aug 30 12:21:56 2019
|
|
|
4
4
|
|
|
5
5
|
@author: Weber
|
|
6
6
|
"""
|
|
7
|
-
from abc import ABCMeta, abstractmethod
|
|
8
|
-
|
|
9
|
-
|
|
10
7
|
from qtpy.QtCore import QObject, Signal, Slot, QThread
|
|
11
8
|
from qtpy import QtWidgets
|
|
12
9
|
import socket
|
|
13
10
|
import select
|
|
14
11
|
import numpy as np
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import pymodaq.
|
|
19
|
-
from pymodaq.
|
|
20
|
-
from pymodaq.daq_utils import
|
|
21
|
-
from pymodaq.
|
|
13
|
+
from pymodaq.utils.parameter import ioxml
|
|
14
|
+
from pymodaq.utils.parameter import utils as putils
|
|
15
|
+
import pymodaq.utils.parameter.pymodaq_ptypes
|
|
16
|
+
from pymodaq.utils.parameter.ioxml import parameter_to_xml_string
|
|
17
|
+
from pymodaq.utils.daq_utils import getLineInfo, ThreadCommand
|
|
18
|
+
from pymodaq.utils.data import DataFromPlugins
|
|
19
|
+
from pymodaq.utils import math_utils as mutils
|
|
20
|
+
from pymodaq.utils.config import Config
|
|
22
21
|
from pyqtgraph.parametertree import Parameter
|
|
23
22
|
from collections import OrderedDict
|
|
24
23
|
from typing import List
|
|
@@ -228,7 +227,7 @@ class Socket:
|
|
|
228
227
|
data_bytes = self.check_received_length(data_len)
|
|
229
228
|
data = np.frombuffer(data_bytes, dtype=data_type)
|
|
230
229
|
data = data.reshape(tuple(shape))
|
|
231
|
-
data = np.squeeze(data)
|
|
230
|
+
data = np.squeeze(data) # remove singleton dimensions
|
|
232
231
|
return data
|
|
233
232
|
|
|
234
233
|
def send_array(self, data_array):
|
|
@@ -314,6 +313,7 @@ class Socket:
|
|
|
314
313
|
data.append(self.get_array())
|
|
315
314
|
return data
|
|
316
315
|
|
|
316
|
+
|
|
317
317
|
class TCPClientTemplate:
|
|
318
318
|
params = []
|
|
319
319
|
|
|
@@ -411,7 +411,6 @@ class TCPClientTemplate:
|
|
|
411
411
|
"""Error in the socket communication"""
|
|
412
412
|
raise NotImplementedError
|
|
413
413
|
|
|
414
|
-
|
|
415
414
|
def process_error_in_polling(self, e: Exception):
|
|
416
415
|
raise NotImplementedError
|
|
417
416
|
|
|
@@ -472,7 +471,7 @@ class TCPClient(TCPClientTemplate, QObject):
|
|
|
472
471
|
self.socket.send_string(value_as_string)
|
|
473
472
|
|
|
474
473
|
@Slot(ThreadCommand)
|
|
475
|
-
def queue_command(self, command=ThreadCommand
|
|
474
|
+
def queue_command(self, command=ThreadCommand):
|
|
476
475
|
"""
|
|
477
476
|
when this TCPClient object is within a thread, the corresponding module communicate with it with signal and slots
|
|
478
477
|
from module to client: module_signal to queue_command slot
|
|
@@ -490,42 +489,42 @@ class TCPClient(TCPClientTemplate, QObject):
|
|
|
490
489
|
self.cmd_signal.emit(ThreadCommand('disconnected'))
|
|
491
490
|
|
|
492
491
|
elif command.command == 'update_connection':
|
|
493
|
-
self.ipaddress = command.
|
|
494
|
-
self.port = command.
|
|
492
|
+
self.ipaddress = command.attribute['ipaddress']
|
|
493
|
+
self.port = command.attribute['port']
|
|
495
494
|
|
|
496
495
|
elif command.command == 'data_ready':
|
|
497
|
-
self.data_ready(command.
|
|
496
|
+
self.data_ready(command.attribute)
|
|
498
497
|
|
|
499
498
|
elif command.command == 'send_info':
|
|
500
499
|
if self.socket is not None:
|
|
501
|
-
path = command.
|
|
502
|
-
param = command.
|
|
500
|
+
path = command.attribute['path']
|
|
501
|
+
param = command.attribute['param']
|
|
503
502
|
|
|
504
503
|
self.socket.send_string('Info_xml')
|
|
505
504
|
self.socket.send_list(path)
|
|
506
505
|
|
|
507
506
|
# send value
|
|
508
|
-
data =
|
|
507
|
+
data = parameter_to_xml_string(param)
|
|
509
508
|
self.socket.send_string(data)
|
|
510
509
|
|
|
511
510
|
elif command.command == 'position_is':
|
|
512
511
|
if self.socket is not None:
|
|
513
512
|
self.socket.send_string('position_is')
|
|
514
|
-
self.socket.send_scalar(command.
|
|
513
|
+
self.socket.send_scalar(command.attribute[0])
|
|
515
514
|
|
|
516
515
|
elif command.command == 'move_done':
|
|
517
516
|
if self.socket is not None:
|
|
518
517
|
self.socket.send_string('move_done')
|
|
519
|
-
self.socket.send_scalar(command.
|
|
518
|
+
self.socket.send_scalar(command.attribute[0])
|
|
520
519
|
|
|
521
520
|
elif command.command == 'x_axis':
|
|
522
521
|
if self.socket is not None:
|
|
523
522
|
self.socket.send_string('x_axis')
|
|
524
523
|
x_axis = dict(label='', units='')
|
|
525
|
-
if isinstance(command.
|
|
526
|
-
x_axis['data'] = command.
|
|
527
|
-
elif isinstance(command.
|
|
528
|
-
x_axis.update(command.
|
|
524
|
+
if isinstance(command.attribute[0], np.ndarray):
|
|
525
|
+
x_axis['data'] = command.attribute[0]
|
|
526
|
+
elif isinstance(command.attribute[0], dict):
|
|
527
|
+
x_axis.update(command.attribute[0].copy())
|
|
529
528
|
|
|
530
529
|
self.socket.send_array(x_axis['data'])
|
|
531
530
|
self.socket.send_string(x_axis['label'])
|
|
@@ -535,10 +534,10 @@ class TCPClient(TCPClientTemplate, QObject):
|
|
|
535
534
|
if self.socket is not None:
|
|
536
535
|
self.socket.send_string('y_axis')
|
|
537
536
|
y_axis = dict(label='', units='')
|
|
538
|
-
if isinstance(command.
|
|
539
|
-
y_axis['data'] = command.
|
|
540
|
-
elif isinstance(command.
|
|
541
|
-
y_axis.update(command.
|
|
537
|
+
if isinstance(command.attribute[0], np.ndarray):
|
|
538
|
+
y_axis['data'] = command.attribute[0]
|
|
539
|
+
elif isinstance(command.attribute[0], dict):
|
|
540
|
+
y_axis.update(command.attribute[0].copy())
|
|
542
541
|
|
|
543
542
|
self.socket.send_array(y_axis['data'])
|
|
544
543
|
self.socket.send_string(y_axis['label'])
|
|
@@ -576,7 +575,7 @@ class TCPClient(TCPClientTemplate, QObject):
|
|
|
576
575
|
self.cmd_signal.emit(ThreadCommand('connected'))
|
|
577
576
|
self.socket.send_string(self.client_type)
|
|
578
577
|
|
|
579
|
-
self.send_infos_xml(
|
|
578
|
+
self.send_infos_xml(parameter_to_xml_string(self.settings))
|
|
580
579
|
for command in extra_commands:
|
|
581
580
|
if isinstance(command, ThreadCommand):
|
|
582
581
|
self.cmd_signal.emit(command)
|
|
@@ -598,15 +597,15 @@ class TCPClient(TCPClientTemplate, QObject):
|
|
|
598
597
|
if message == 'set_info':
|
|
599
598
|
path = self.socket.get_list()
|
|
600
599
|
param_xml = self.socket.get_string()
|
|
601
|
-
messg.
|
|
600
|
+
messg.attribute = [path, param_xml]
|
|
602
601
|
|
|
603
602
|
elif message == 'move_abs':
|
|
604
603
|
position = self.socket.get_scalar()
|
|
605
|
-
messg.
|
|
604
|
+
messg.attribute = [position]
|
|
606
605
|
|
|
607
606
|
elif message == 'move_rel':
|
|
608
607
|
position = self.socket.get_scalar()
|
|
609
|
-
messg.
|
|
608
|
+
messg.attribute = [position]
|
|
610
609
|
|
|
611
610
|
self.cmd_signal.emit(messg)
|
|
612
611
|
|
|
@@ -925,7 +924,7 @@ class TCPServer(QObject):
|
|
|
925
924
|
def read_infos(self, sock=None, infos=''):
|
|
926
925
|
if sock is not None:
|
|
927
926
|
infos = sock.get_string()
|
|
928
|
-
params =
|
|
927
|
+
params = ioxml.XML_string_to_parameter(infos)
|
|
929
928
|
|
|
930
929
|
param_state = {'title': 'Infos Client:', 'name': 'settings_client', 'type': 'group', 'children': params}
|
|
931
930
|
self.settings.child(('settings_client')).restoreState(param_state)
|
|
@@ -935,7 +934,7 @@ class TCPServer(QObject):
|
|
|
935
934
|
path = sock.get_list()
|
|
936
935
|
param_xml = sock.get_string()
|
|
937
936
|
try:
|
|
938
|
-
param_dict =
|
|
937
|
+
param_dict = ioxml.XML_string_to_parameter(param_xml)[0]
|
|
939
938
|
except Exception as e:
|
|
940
939
|
raise Exception(f'Invalid xml structure for TCP server settings: {str(e)}')
|
|
941
940
|
try:
|
|
@@ -956,7 +955,7 @@ class TCPServer(QObject):
|
|
|
956
955
|
info = sock.get_string()
|
|
957
956
|
data = sock.get_string()
|
|
958
957
|
|
|
959
|
-
if info not in
|
|
958
|
+
if info not in putils.iter_children(self.settings.child(('infos')), []):
|
|
960
959
|
self.settings.child('infos').addChild({'name': info, 'type': 'str', 'value': data})
|
|
961
960
|
pass
|
|
962
961
|
else:
|
|
@@ -1016,7 +1015,7 @@ class Grabber(QObject):
|
|
|
1016
1015
|
self.command_tcpip[ThreadCommand].connect(tcpclient.queue_command)
|
|
1017
1016
|
|
|
1018
1017
|
self.tcpclient_thread.start()
|
|
1019
|
-
tcpclient.init_connection(extra_commands=[ThreadCommand('get_axis')])
|
|
1018
|
+
tcpclient.init_connection(extra_commands=[ThreadCommand('get_axis', )])
|
|
1020
1019
|
self.send_to_tcpip = True
|
|
1021
1020
|
|
|
1022
1021
|
def snapshot(self, info='', send_to_tcpip=True):
|
|
@@ -1056,7 +1055,7 @@ class Grabber(QObject):
|
|
|
1056
1055
|
|
|
1057
1056
|
if __name__ == '__main__': # pragma: no cover
|
|
1058
1057
|
import sys
|
|
1059
|
-
from pymodaq.
|
|
1058
|
+
from pymodaq.utils.parameter import ioxml
|
|
1060
1059
|
|
|
1061
1060
|
app = QtWidgets.QApplication(sys.argv)
|
|
1062
1061
|
mockdata_grabber = MockDataGrabber('2D')
|
|
@@ -3,17 +3,19 @@ from qtpy.QtCore import QObject, Signal, QLocale
|
|
|
3
3
|
import sys
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class
|
|
6
|
+
class TreeLayout(QObject):
|
|
7
7
|
"""
|
|
8
8
|
qtpy class object based on QtreeWidget
|
|
9
|
-
The function
|
|
9
|
+
The function populate_tree has to be used in order to populate the tree with structure as nested lists of dicts
|
|
10
10
|
|
|
11
11
|
"""
|
|
12
12
|
status_sig = Signal(str)
|
|
13
|
-
|
|
13
|
+
item_clicked_sig = Signal(object)
|
|
14
|
+
item_double_clicked_sig = Signal(object)
|
|
15
|
+
|
|
14
16
|
def __init__(self, parent=None, col_counts=1, labels=None):
|
|
15
17
|
|
|
16
|
-
super(
|
|
18
|
+
super().__init__()
|
|
17
19
|
|
|
18
20
|
if parent is None:
|
|
19
21
|
parent = QtWidgets.QWidget()
|
|
@@ -21,66 +23,79 @@ class Tree_layout(QObject):
|
|
|
21
23
|
|
|
22
24
|
self.setupUi()
|
|
23
25
|
|
|
24
|
-
self.
|
|
26
|
+
self.tree.setColumnCount(col_counts)
|
|
25
27
|
if labels is not None:
|
|
26
|
-
self.
|
|
28
|
+
self.tree.setHeaderLabels(labels)
|
|
29
|
+
|
|
30
|
+
self.open_tree_pb.clicked.connect(self.expand_all)
|
|
31
|
+
self.close_tree_pb.clicked.connect(self.collapse_all)
|
|
32
|
+
self.open_tree_selected_pb.clicked.connect(self.open_tree_selection)
|
|
33
|
+
|
|
34
|
+
self.tree.itemClicked.connect(self.item_clicked_sig.emit)
|
|
35
|
+
self.tree.itemDoubleClicked.connect(self.item_double_clicked_sig.emit)
|
|
36
|
+
|
|
37
|
+
def _current_text(self, col_index: int = 2):
|
|
38
|
+
return self.tree.currentItem().text(col_index)
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
self.
|
|
30
|
-
|
|
40
|
+
def current_node_path(self):
|
|
41
|
+
return self._current_text(2)
|
|
42
|
+
|
|
43
|
+
def expand_all(self):
|
|
44
|
+
self.tree.expandAll()
|
|
45
|
+
|
|
46
|
+
def collapse_all(self):
|
|
47
|
+
self.tree.collapseAll()
|
|
31
48
|
|
|
32
49
|
@property
|
|
33
50
|
def treewidget(self):
|
|
34
|
-
return self.
|
|
51
|
+
return self.tree
|
|
35
52
|
|
|
36
53
|
def setupUi(self):
|
|
37
|
-
self.ui = QObject()
|
|
38
|
-
|
|
39
54
|
vlayout = QtWidgets.QVBoxLayout()
|
|
40
55
|
hlayout = QtWidgets.QHBoxLayout()
|
|
41
56
|
|
|
42
|
-
self.
|
|
43
|
-
vlayout.addWidget(self.
|
|
57
|
+
self.tree = CustomTree()
|
|
58
|
+
vlayout.addWidget(self.tree)
|
|
44
59
|
|
|
45
60
|
iconopen = QtGui.QIcon()
|
|
46
61
|
iconopen.addPixmap(QtGui.QPixmap(":/icons/Icon_Library/tree.png"), QtGui.QIcon.Normal,
|
|
47
62
|
QtGui.QIcon.Off)
|
|
48
|
-
self.
|
|
49
|
-
self.
|
|
63
|
+
self.open_tree_pb = QtWidgets.QPushButton('Open Tree')
|
|
64
|
+
self.open_tree_pb.setIcon(iconopen)
|
|
50
65
|
|
|
51
66
|
iconopensel = QtGui.QIcon()
|
|
52
67
|
iconopensel.addPixmap(QtGui.QPixmap(":/icons/Icon_Library/tree.png"), QtGui.QIcon.Normal,
|
|
53
68
|
QtGui.QIcon.Off)
|
|
54
|
-
self.
|
|
55
|
-
self.
|
|
69
|
+
self.open_tree_selected_pb = QtWidgets.QPushButton('Open Selected')
|
|
70
|
+
self.open_tree_selected_pb.setIcon(iconopensel)
|
|
56
71
|
|
|
57
72
|
iconclose = QtGui.QIcon()
|
|
58
73
|
iconclose.addPixmap(QtGui.QPixmap(":/icons/Icon_Library/CollapseAll.png"), QtGui.QIcon.Normal,
|
|
59
74
|
QtGui.QIcon.Off)
|
|
60
|
-
self.
|
|
61
|
-
self.
|
|
75
|
+
self.close_tree_pb = QtWidgets.QPushButton('Close Tree')
|
|
76
|
+
self.close_tree_pb.setIcon(iconclose)
|
|
62
77
|
|
|
63
|
-
hlayout.addWidget(self.
|
|
64
|
-
hlayout.addWidget(self.
|
|
65
|
-
hlayout.addWidget(self.
|
|
78
|
+
hlayout.addWidget(self.open_tree_pb)
|
|
79
|
+
hlayout.addWidget(self.open_tree_selected_pb)
|
|
80
|
+
hlayout.addWidget(self.close_tree_pb)
|
|
66
81
|
|
|
67
82
|
vlayout.addLayout(hlayout)
|
|
68
83
|
|
|
69
84
|
self.parent.setLayout(vlayout)
|
|
70
85
|
|
|
71
|
-
def
|
|
72
|
-
self.
|
|
86
|
+
def open_tree_selection(self):
|
|
87
|
+
self.tree_open_children(self.tree.selectedIndexes()[0])
|
|
73
88
|
|
|
74
|
-
def
|
|
89
|
+
def tree_open_children(self, item_index):
|
|
75
90
|
try:
|
|
76
91
|
if not (item_index.isValid()):
|
|
77
92
|
return
|
|
78
93
|
|
|
79
|
-
self.
|
|
94
|
+
self.tree.expand(item_index)
|
|
80
95
|
except Exception as e:
|
|
81
96
|
self.status_sig.emit(str(e))
|
|
82
97
|
|
|
83
|
-
def
|
|
98
|
+
def tree_open_parents(self, item_index):
|
|
84
99
|
try:
|
|
85
100
|
if not (item_index.isValid()):
|
|
86
101
|
return
|
|
@@ -90,14 +105,14 @@ class Tree_layout(QObject):
|
|
|
90
105
|
while flag:
|
|
91
106
|
parent = parent.parent()
|
|
92
107
|
if parent != empty:
|
|
93
|
-
self.
|
|
108
|
+
self.tree.expand(parent)
|
|
94
109
|
else:
|
|
95
110
|
flag = False
|
|
96
111
|
break
|
|
97
112
|
except Exception as e:
|
|
98
113
|
self.status_sig.emit(str(e))
|
|
99
114
|
|
|
100
|
-
def
|
|
115
|
+
def populate_tree(self, data_dict):
|
|
101
116
|
try:
|
|
102
117
|
parents = []
|
|
103
118
|
for data in data_dict:
|
|
@@ -111,7 +126,7 @@ class Tree_layout(QObject):
|
|
|
111
126
|
parent.addChildren(Items)
|
|
112
127
|
parents.append(parent)
|
|
113
128
|
|
|
114
|
-
self.
|
|
129
|
+
self.tree.addTopLevelItems(parents)
|
|
115
130
|
except Exception as e:
|
|
116
131
|
self.status_sig.emit(str(e))
|
|
117
132
|
|
|
@@ -139,7 +154,7 @@ class Tree_layout(QObject):
|
|
|
139
154
|
class CustomTree(QtWidgets.QTreeWidget):
|
|
140
155
|
|
|
141
156
|
def __init__(self, parent=None):
|
|
142
|
-
super(
|
|
157
|
+
super().__init__(parent)
|
|
143
158
|
self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
|
144
159
|
|
|
145
160
|
|
|
@@ -148,11 +163,11 @@ if __name__ == '__main__':
|
|
|
148
163
|
|
|
149
164
|
app = QtWidgets.QApplication(sys.argv)
|
|
150
165
|
Form = QtWidgets.QWidget()
|
|
151
|
-
prog =
|
|
166
|
+
prog = TreeLayout(Form, col_counts=2, labels=["Material", "File"])
|
|
152
167
|
|
|
153
168
|
# example of actions to add to the tree widget in order to show a context menu
|
|
154
169
|
detector_action = QtWidgets.QAction("Grab from camera", None)
|
|
155
|
-
prog.
|
|
170
|
+
prog.tree.addAction(detector_action)
|
|
156
171
|
########################
|
|
157
172
|
|
|
158
173
|
Form.show()
|
|
@@ -161,7 +176,7 @@ if __name__ == '__main__':
|
|
|
161
176
|
dict(name='fiston1', contents=[dict(name='subfiston', contents='baby', filename='Cest pas malin')]),
|
|
162
177
|
dict(name='fiston2', contents=[dict(name='subfiston', contents='baby', filename='Cest pas normal')])]),
|
|
163
178
|
dict(name='maman', contents=[dict(name='fistone', contents=[dict(name='subfistone', contents='baby')])])]
|
|
164
|
-
prog.
|
|
179
|
+
prog.populate_tree(data)
|
|
165
180
|
# filename='C:\\Data\\2019\\20190220\\Dataset_20190220_004\\Dataset_20190220_004.h5'
|
|
166
181
|
# import tables
|
|
167
182
|
# h5_file = tables.open_file(filename, mode = "a")
|
pymodaq/utils/units.py
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 27/10/2022
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
Cb = 1.602176e-19 # coulomb
|
|
10
|
+
h = 6.626068e-34 # J.s
|
|
11
|
+
c = 2.997924586e8 # m.s-1
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def Enm2cmrel(E_nm, ref_wavelength=515):
|
|
15
|
+
"""Converts energy in nm to cm-1 relative to a ref wavelength
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
19
|
+
E_nm: float
|
|
20
|
+
photon energy in wavelength (nm)
|
|
21
|
+
ref_wavelength: float
|
|
22
|
+
reference wavelength in nm from which calculate the photon relative energy
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
float
|
|
27
|
+
photon energy in cm-1 relative to the ref wavelength
|
|
28
|
+
|
|
29
|
+
Examples
|
|
30
|
+
--------
|
|
31
|
+
>>> Enm2cmrel(530, 515)
|
|
32
|
+
549.551199853453
|
|
33
|
+
"""
|
|
34
|
+
return 1 / (ref_wavelength * 1e-7) - 1 / (E_nm * 1e-7)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def Ecmrel2Enm(Ecmrel, ref_wavelength=515):
|
|
38
|
+
"""Converts energy from cm-1 relative to a ref wavelength to an energy in wavelength (nm)
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
Ecmrel: float
|
|
43
|
+
photon energy in cm-1
|
|
44
|
+
ref_wavelength: float
|
|
45
|
+
reference wavelength in nm from which calculate the photon relative energy
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
float
|
|
50
|
+
photon energy in nm
|
|
51
|
+
|
|
52
|
+
Examples
|
|
53
|
+
--------
|
|
54
|
+
>>> Ecmrel2Enm(500, 515)
|
|
55
|
+
528.6117526302285
|
|
56
|
+
"""
|
|
57
|
+
Ecm = 1 / (ref_wavelength * 1e-7) - Ecmrel
|
|
58
|
+
return 1 / (Ecm * 1e-7)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def eV2nm(E_eV):
|
|
62
|
+
"""Converts photon energy from electronvolt to wavelength in nm
|
|
63
|
+
|
|
64
|
+
Parameters
|
|
65
|
+
----------
|
|
66
|
+
E_eV: float
|
|
67
|
+
Photon energy in eV
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
float
|
|
72
|
+
photon energy in nm
|
|
73
|
+
|
|
74
|
+
Examples
|
|
75
|
+
--------
|
|
76
|
+
>>> eV2nm(1.55)
|
|
77
|
+
799.898112990037
|
|
78
|
+
"""
|
|
79
|
+
E_J = E_eV * Cb
|
|
80
|
+
E_freq = E_J / h
|
|
81
|
+
E_nm = c / E_freq * 1e9
|
|
82
|
+
return E_nm
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def nm2eV(E_nm):
|
|
86
|
+
"""Converts photon energy from wavelength in nm to electronvolt
|
|
87
|
+
|
|
88
|
+
Parameters
|
|
89
|
+
----------
|
|
90
|
+
E_nm: float
|
|
91
|
+
Photon energy in nm
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
float
|
|
96
|
+
photon energy in eV
|
|
97
|
+
|
|
98
|
+
Examples
|
|
99
|
+
--------
|
|
100
|
+
>>> nm2eV(800)
|
|
101
|
+
1.549802593918197
|
|
102
|
+
"""
|
|
103
|
+
E_freq = c / E_nm * 1e9
|
|
104
|
+
E_J = E_freq * h
|
|
105
|
+
E_eV = E_J / Cb
|
|
106
|
+
return E_eV
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def E_J2eV(E_J):
|
|
110
|
+
E_eV = E_J / Cb
|
|
111
|
+
return E_eV
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def eV2cm(E_eV):
|
|
115
|
+
"""Converts photon energy from electronvolt to absolute cm-1
|
|
116
|
+
|
|
117
|
+
Parameters
|
|
118
|
+
----------
|
|
119
|
+
E_eV: float
|
|
120
|
+
Photon energy in eV
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
float
|
|
125
|
+
photon energy in cm-1
|
|
126
|
+
|
|
127
|
+
Examples
|
|
128
|
+
--------
|
|
129
|
+
>>> eV2cm(0.07)
|
|
130
|
+
564.5880342655984
|
|
131
|
+
"""
|
|
132
|
+
E_nm = eV2nm(E_eV)
|
|
133
|
+
E_cm = 1 / (E_nm * 1e-7)
|
|
134
|
+
return E_cm
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def nm2cm(E_nm):
|
|
138
|
+
"""Converts photon energy from wavelength to absolute cm-1
|
|
139
|
+
|
|
140
|
+
Parameters
|
|
141
|
+
----------
|
|
142
|
+
E_nm: float
|
|
143
|
+
Photon energy in nm
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
float
|
|
148
|
+
photon energy in cm-1
|
|
149
|
+
|
|
150
|
+
Examples
|
|
151
|
+
--------
|
|
152
|
+
>>> nm2cm(0.04)
|
|
153
|
+
0.000025
|
|
154
|
+
"""
|
|
155
|
+
return 1 / (E_nm * 1e7)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def cm2nm(E_cm):
|
|
159
|
+
"""Converts photon energy from absolute cm-1 to wavelength
|
|
160
|
+
|
|
161
|
+
Parameters
|
|
162
|
+
----------
|
|
163
|
+
E_cm: float
|
|
164
|
+
photon energy in cm-1
|
|
165
|
+
|
|
166
|
+
Returns
|
|
167
|
+
-------
|
|
168
|
+
float
|
|
169
|
+
Photon energy in nm
|
|
170
|
+
|
|
171
|
+
Examples
|
|
172
|
+
--------
|
|
173
|
+
>>> cm2nm(1e5)
|
|
174
|
+
100
|
|
175
|
+
"""
|
|
176
|
+
return 1 / (E_cm * 1e-7)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def eV2E_J(E_eV):
|
|
180
|
+
E_J = E_eV * Cb
|
|
181
|
+
return E_J
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def eV2radfs(E_eV):
|
|
185
|
+
E_J = E_eV * Cb
|
|
186
|
+
E_freq = E_J / h
|
|
187
|
+
E_radfs = E_freq * 2 * np.pi / 1e15
|
|
188
|
+
return E_radfs
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def l2w(x, speedlight=300):
|
|
192
|
+
"""Converts photon energy in rad/fs to nm (and vice-versa)
|
|
193
|
+
|
|
194
|
+
Parameters
|
|
195
|
+
----------
|
|
196
|
+
x: float
|
|
197
|
+
photon energy in wavelength or rad/fs
|
|
198
|
+
speedlight: float, optional
|
|
199
|
+
the speed of light, by default 300 nm/fs
|
|
200
|
+
|
|
201
|
+
Returns
|
|
202
|
+
-------
|
|
203
|
+
float
|
|
204
|
+
|
|
205
|
+
Examples
|
|
206
|
+
--------
|
|
207
|
+
>>> l2w(800)
|
|
208
|
+
2.356194490192345
|
|
209
|
+
>>> l2w(800,3e8)
|
|
210
|
+
2356194.490192345
|
|
211
|
+
"""
|
|
212
|
+
y = 2 * np.pi * speedlight / x
|
|
213
|
+
return y
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|