pymodaq 5.1.6__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.
- pymodaq/__init__.py +98 -0
- pymodaq/control_modules/__init__.py +1 -0
- pymodaq/control_modules/daq_move.py +1238 -0
- pymodaq/control_modules/daq_move_ui/__init__.py +0 -0
- pymodaq/control_modules/daq_move_ui/factory.py +48 -0
- pymodaq/control_modules/daq_move_ui/ui_base.py +359 -0
- pymodaq/control_modules/daq_move_ui/uis/__init__.py +0 -0
- pymodaq/control_modules/daq_move_ui/uis/binary.py +139 -0
- pymodaq/control_modules/daq_move_ui/uis/original.py +120 -0
- pymodaq/control_modules/daq_move_ui/uis/relative.py +124 -0
- pymodaq/control_modules/daq_move_ui/uis/simple.py +126 -0
- pymodaq/control_modules/daq_viewer.py +1517 -0
- pymodaq/control_modules/daq_viewer_ui.py +407 -0
- pymodaq/control_modules/mocks.py +57 -0
- pymodaq/control_modules/move_utility_classes.py +1141 -0
- pymodaq/control_modules/thread_commands.py +137 -0
- pymodaq/control_modules/ui_utils.py +72 -0
- pymodaq/control_modules/utils.py +591 -0
- pymodaq/control_modules/viewer_utility_classes.py +670 -0
- pymodaq/daq_utils/__init__.py +0 -0
- pymodaq/daq_utils/daq_utils.py +6 -0
- pymodaq/dashboard.py +2396 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.aliases +3 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.lvlps +3 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.lvproj +32 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Server_1Dgaussian.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Server_2Dgaussian.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_cmd.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_float.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_int.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_data.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_int.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_scalar.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_string.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/client_state.ctl +0 -0
- pymodaq/examples/Labview_TCP_Client/cmd_types.ctl +0 -0
- pymodaq/examples/__init__.py +0 -0
- pymodaq/examples/function_plotter.py +160 -0
- pymodaq/examples/nonlinearscanner.py +126 -0
- pymodaq/examples/qt_less_standalone_module.py +165 -0
- pymodaq/examples/tcp_client.py +97 -0
- pymodaq/extensions/__init__.py +25 -0
- pymodaq/extensions/adaptive/__init__.py +2 -0
- pymodaq/extensions/adaptive/adaptive_optimization.py +179 -0
- pymodaq/extensions/adaptive/loss_function/_1d_loss_functions.py +73 -0
- pymodaq/extensions/adaptive/loss_function/_2d_loss_functions.py +73 -0
- pymodaq/extensions/adaptive/loss_function/__init__.py +3 -0
- pymodaq/extensions/adaptive/loss_function/loss_factory.py +110 -0
- pymodaq/extensions/adaptive/utils.py +123 -0
- pymodaq/extensions/bayesian/__init__.py +2 -0
- pymodaq/extensions/bayesian/acquisition/__init__.py +2 -0
- pymodaq/extensions/bayesian/acquisition/acquisition_function_factory.py +80 -0
- pymodaq/extensions/bayesian/acquisition/base_acquisition_function.py +105 -0
- pymodaq/extensions/bayesian/bayesian_optimization.py +143 -0
- pymodaq/extensions/bayesian/utils.py +180 -0
- pymodaq/extensions/console.py +73 -0
- pymodaq/extensions/daq_logger/__init__.py +1 -0
- pymodaq/extensions/daq_logger/abstract.py +52 -0
- pymodaq/extensions/daq_logger/daq_logger.py +519 -0
- pymodaq/extensions/daq_logger/db/__init__.py +0 -0
- pymodaq/extensions/daq_logger/db/db_logger.py +300 -0
- pymodaq/extensions/daq_logger/db/db_logger_models.py +100 -0
- pymodaq/extensions/daq_logger/h5logging.py +84 -0
- pymodaq/extensions/daq_scan.py +1218 -0
- pymodaq/extensions/daq_scan_ui.py +241 -0
- pymodaq/extensions/data_mixer/__init__.py +0 -0
- pymodaq/extensions/data_mixer/daq_0Dviewer_DataMixer.py +97 -0
- pymodaq/extensions/data_mixer/data_mixer.py +262 -0
- pymodaq/extensions/data_mixer/model.py +108 -0
- pymodaq/extensions/data_mixer/models/__init__.py +0 -0
- pymodaq/extensions/data_mixer/models/equation_model.py +91 -0
- pymodaq/extensions/data_mixer/models/gaussian_fit_model.py +65 -0
- pymodaq/extensions/data_mixer/parser.py +53 -0
- pymodaq/extensions/data_mixer/utils.py +23 -0
- pymodaq/extensions/h5browser.py +9 -0
- pymodaq/extensions/optimizers_base/__init__.py +0 -0
- pymodaq/extensions/optimizers_base/optimizer.py +1016 -0
- pymodaq/extensions/optimizers_base/thread_commands.py +22 -0
- pymodaq/extensions/optimizers_base/utils.py +427 -0
- pymodaq/extensions/pid/__init__.py +16 -0
- pymodaq/extensions/pid/actuator_controller.py +14 -0
- pymodaq/extensions/pid/daq_move_PID.py +154 -0
- pymodaq/extensions/pid/pid_controller.py +1016 -0
- pymodaq/extensions/pid/utils.py +189 -0
- pymodaq/extensions/utils.py +111 -0
- pymodaq/icon.ico +0 -0
- pymodaq/post_treatment/__init__.py +6 -0
- pymodaq/post_treatment/load_and_plot.py +352 -0
- pymodaq/resources/__init__.py +0 -0
- pymodaq/resources/config_template.toml +57 -0
- pymodaq/resources/preset_default.xml +1 -0
- pymodaq/resources/setup_plugin.py +73 -0
- pymodaq/splash.png +0 -0
- pymodaq/utils/__init__.py +0 -0
- pymodaq/utils/array_manipulation.py +6 -0
- pymodaq/utils/calibration_camera.py +180 -0
- pymodaq/utils/chrono_timer.py +203 -0
- pymodaq/utils/config.py +53 -0
- pymodaq/utils/conftests.py +5 -0
- pymodaq/utils/daq_utils.py +158 -0
- pymodaq/utils/data.py +128 -0
- pymodaq/utils/enums.py +6 -0
- pymodaq/utils/exceptions.py +38 -0
- pymodaq/utils/gui_utils/__init__.py +10 -0
- pymodaq/utils/gui_utils/loader_utils.py +75 -0
- pymodaq/utils/gui_utils/utils.py +18 -0
- pymodaq/utils/gui_utils/widgets/lcd.py +8 -0
- pymodaq/utils/h5modules/__init__.py +2 -0
- pymodaq/utils/h5modules/module_saving.py +526 -0
- pymodaq/utils/leco/__init__.py +25 -0
- pymodaq/utils/leco/daq_move_LECODirector.py +217 -0
- pymodaq/utils/leco/daq_xDviewer_LECODirector.py +163 -0
- pymodaq/utils/leco/director_utils.py +74 -0
- pymodaq/utils/leco/leco_director.py +166 -0
- pymodaq/utils/leco/pymodaq_listener.py +364 -0
- pymodaq/utils/leco/rpc_method_definitions.py +43 -0
- pymodaq/utils/leco/utils.py +74 -0
- pymodaq/utils/logger.py +6 -0
- pymodaq/utils/managers/__init__.py +0 -0
- pymodaq/utils/managers/batchscan_manager.py +346 -0
- pymodaq/utils/managers/modules_manager.py +589 -0
- pymodaq/utils/managers/overshoot_manager.py +242 -0
- pymodaq/utils/managers/preset_manager.py +229 -0
- pymodaq/utils/managers/preset_manager_utils.py +262 -0
- pymodaq/utils/managers/remote_manager.py +484 -0
- pymodaq/utils/math_utils.py +6 -0
- pymodaq/utils/messenger.py +6 -0
- pymodaq/utils/parameter/__init__.py +10 -0
- pymodaq/utils/parameter/utils.py +6 -0
- pymodaq/utils/scanner/__init__.py +5 -0
- pymodaq/utils/scanner/scan_config.py +16 -0
- pymodaq/utils/scanner/scan_factory.py +259 -0
- pymodaq/utils/scanner/scan_selector.py +477 -0
- pymodaq/utils/scanner/scanner.py +324 -0
- pymodaq/utils/scanner/scanners/_1d_scanners.py +174 -0
- pymodaq/utils/scanner/scanners/_2d_scanners.py +299 -0
- pymodaq/utils/scanner/scanners/__init__.py +1 -0
- pymodaq/utils/scanner/scanners/sequential.py +224 -0
- pymodaq/utils/scanner/scanners/tabular.py +319 -0
- pymodaq/utils/scanner/utils.py +110 -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 +50 -0
- pymodaq/utils/tcp_ip/__init__.py +6 -0
- pymodaq/utils/tcp_ip/mysocket.py +12 -0
- pymodaq/utils/tcp_ip/serializer.py +13 -0
- pymodaq/utils/tcp_ip/tcp_server_client.py +772 -0
- pymodaq-5.1.6.dist-info/METADATA +238 -0
- pymodaq-5.1.6.dist-info/RECORD +154 -0
- pymodaq-5.1.6.dist-info/WHEEL +4 -0
- pymodaq-5.1.6.dist-info/entry_points.txt +7 -0
- pymodaq-5.1.6.dist-info/licenses/LICENSE +21 -0
pymodaq/utils/config.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
from pymodaq_gui.config_saver_loader import get_set_roi_path
|
|
6
|
+
except ModuleNotFoundError:
|
|
7
|
+
from pymodaq_gui.config import get_set_roi_path
|
|
8
|
+
|
|
9
|
+
from pymodaq_utils.config import (BaseConfig, ConfigError, get_set_config_dir,
|
|
10
|
+
USER, CONFIG_BASE_PATH, get_set_local_dir)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_set_preset_path():
|
|
14
|
+
""" creates and return the config folder path for managers files
|
|
15
|
+
"""
|
|
16
|
+
return get_set_config_dir('preset_configs')
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_set_batch_path():
|
|
20
|
+
""" creates and return the config folder path for managers files
|
|
21
|
+
"""
|
|
22
|
+
return get_set_config_dir('batch_configs')
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_set_pid_path():
|
|
26
|
+
""" creates and return the config folder path for PID files
|
|
27
|
+
"""
|
|
28
|
+
return get_set_config_dir('pid_configs')
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def get_set_layout_path():
|
|
32
|
+
""" creates and return the config folder path for layout files
|
|
33
|
+
"""
|
|
34
|
+
return get_set_config_dir('layout_configs')
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def get_set_remote_path():
|
|
38
|
+
""" creates and return the config folder path for remote (shortcuts or joystick) files
|
|
39
|
+
"""
|
|
40
|
+
return get_set_config_dir('remote_configs')
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_set_overshoot_path():
|
|
44
|
+
""" creates and return the config folder path for overshoot files
|
|
45
|
+
"""
|
|
46
|
+
return get_set_config_dir('overshoot_configs')
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Config(BaseConfig):
|
|
50
|
+
"""Main class to deal with configuration values for this plugin"""
|
|
51
|
+
config_template_path = Path(__file__).parent.parent.joinpath('resources/config_template.toml')
|
|
52
|
+
config_name = f"config_pymodaq"
|
|
53
|
+
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
|
|
2
|
+
import importlib
|
|
3
|
+
from packaging import version as version_mod
|
|
4
|
+
import pkgutil
|
|
5
|
+
import platform
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from pymodaq_utils.config import Config
|
|
9
|
+
from pymodaq_utils.utils import get_entrypoints, ThreadCommand, getLineInfo, find_keys_from_val, is_64bits, timer # for backcompat
|
|
10
|
+
from pymodaq_utils.logger import set_logger, get_module_name # for backcompat
|
|
11
|
+
|
|
12
|
+
from pymodaq.utils.data import DataFromPlugins # for backcompat
|
|
13
|
+
|
|
14
|
+
from pymodaq.utils.config import get_set_preset_path
|
|
15
|
+
|
|
16
|
+
if version_mod.parse(platform.python_version()) >= version_mod.parse('3.9'):
|
|
17
|
+
# from version 3.9 the cache decorator is available
|
|
18
|
+
from functools import cache
|
|
19
|
+
else:
|
|
20
|
+
from functools import lru_cache as cache
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
logger = set_logger(get_module_name(__file__))
|
|
24
|
+
|
|
25
|
+
config = Config()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def copy_preset(): # pragma: no cover
|
|
29
|
+
path = get_set_preset_path().joinpath('preset_default.xml')
|
|
30
|
+
if not path.exists(): # copy the preset_default from pymodaq folder and create one in pymodad's local folder
|
|
31
|
+
with open(str(Path(__file__).parent.parent.joinpath('resources/preset_default.xml')), 'r') as file:
|
|
32
|
+
path.write_text(file.read())
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@cache
|
|
36
|
+
def get_instrument_plugins(): # pragma: no cover
|
|
37
|
+
"""
|
|
38
|
+
Get plugins names as a list
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
plugin_type: (str) plugin type either 'daq_0Dviewer', 'daq_1Dviewer', 'daq_2Dviewer', 'daq_NDviewer' or 'daq_move'
|
|
42
|
+
module: (module) parent module of the plugins
|
|
43
|
+
|
|
44
|
+
Returns
|
|
45
|
+
-------
|
|
46
|
+
|
|
47
|
+
"""
|
|
48
|
+
plugins_import = []
|
|
49
|
+
discovered_plugins = []
|
|
50
|
+
discovered_plugins_all = list(get_entrypoints(group='pymodaq.plugins')) # old naming of the instrument plugins
|
|
51
|
+
discovered_plugins_all.extend(list(get_entrypoints(group='pymodaq.instruments'))) # new naming convention
|
|
52
|
+
for entry in discovered_plugins_all:
|
|
53
|
+
if entry.name not in [ent.name for ent in discovered_plugins]:
|
|
54
|
+
discovered_plugins.append(entry)
|
|
55
|
+
discovered_plugins = list(set(discovered_plugins))
|
|
56
|
+
logger.debug(f'Found {len(discovered_plugins)} installed plugins, trying to import them')
|
|
57
|
+
viewer_types = ['0D', '1D', '2D', 'ND']
|
|
58
|
+
plugin_list = []
|
|
59
|
+
for entrypoint in discovered_plugins:
|
|
60
|
+
#print(f'Looking for valid instrument plugins in package: {module.value}')
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
try:
|
|
64
|
+
movemodule = importlib.import_module(f'{entrypoint.value}.daq_move_plugins', entrypoint.value)
|
|
65
|
+
plugin_list.extend([{'name': mod[len('daq_move') + 1:],
|
|
66
|
+
'module': movemodule,
|
|
67
|
+
'parent_module': importlib.import_module(entrypoint.value),
|
|
68
|
+
'type': 'daq_move'}
|
|
69
|
+
for mod in [mod[1] for mod in pkgutil.iter_modules([str(movemodule.path.parent)])]
|
|
70
|
+
if 'daq_move' in mod])
|
|
71
|
+
if len(plugin_list) > 0:
|
|
72
|
+
logger.debug(f"Found Move Instrument:"
|
|
73
|
+
f" {plugin_list[-1]['module'].__name__}/{plugin_list[-1]['name']}")
|
|
74
|
+
except ModuleNotFoundError:
|
|
75
|
+
pass
|
|
76
|
+
|
|
77
|
+
viewer_modules = {}
|
|
78
|
+
for vtype in viewer_types:
|
|
79
|
+
try:
|
|
80
|
+
viewer_modules[vtype] = importlib.import_module(f'{entrypoint.value}.daq_viewer_plugins.plugins_{vtype}',
|
|
81
|
+
entrypoint.value)
|
|
82
|
+
plugin_list.extend([{'name': mod[len(f'daq_{vtype}viewer') + 1:],
|
|
83
|
+
'module': viewer_modules[vtype],
|
|
84
|
+
'parent_module': importlib.import_module(entrypoint.value),
|
|
85
|
+
'type': f'daq_{vtype}viewer'}
|
|
86
|
+
for mod in [mod[1] for mod in pkgutil.iter_modules([str(viewer_modules[vtype].path.parent)])]
|
|
87
|
+
if f'daq_{vtype}viewer' in mod])
|
|
88
|
+
if len(plugin_list) > 0:
|
|
89
|
+
logger.debug(f"Found Viewer Instrument: "
|
|
90
|
+
f"{plugin_list[-1]['module'].__name__}/{plugin_list[-1]['name']}")
|
|
91
|
+
except ModuleNotFoundError:
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
except Exception as e: # pragma: no cover
|
|
95
|
+
logger.debug(str(e))
|
|
96
|
+
|
|
97
|
+
for mod in plugin_list:
|
|
98
|
+
try:
|
|
99
|
+
plugin_type = mod['type']
|
|
100
|
+
if plugin_type == 'daq_move':
|
|
101
|
+
submodule = mod['module']
|
|
102
|
+
importlib.import_module(f'{submodule.__package__}.daq_move_{mod["name"]}')
|
|
103
|
+
else:
|
|
104
|
+
submodule = mod['module']
|
|
105
|
+
importlib.import_module(f'{submodule.__package__}.daq_{plugin_type[4:6]}viewer_{mod["name"]}')
|
|
106
|
+
plugins_import.append(mod)
|
|
107
|
+
logger.info(f"{mod['module'].__name__}/{mod['name']} available")
|
|
108
|
+
except Exception as e: # pragma: no cover
|
|
109
|
+
"""If an error is generated at the import, then exclude this plugin"""
|
|
110
|
+
logger.debug(f'Impossible to import Instrument plugin {mod["name"]}'
|
|
111
|
+
f' from module: {mod["parent_module"].__package__}')
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# add utility plugin for PID
|
|
115
|
+
try:
|
|
116
|
+
pidmodule = importlib.import_module('pymodaq.extensions.pid')
|
|
117
|
+
mod = [{'name': 'PID',
|
|
118
|
+
'module': pidmodule,
|
|
119
|
+
'parent_module': pidmodule,
|
|
120
|
+
'type': 'daq_move'}]
|
|
121
|
+
importlib.import_module(f'{pidmodule.__package__}.daq_move_PID')
|
|
122
|
+
plugins_import.extend(mod)
|
|
123
|
+
|
|
124
|
+
except Exception as e:
|
|
125
|
+
logger.debug(f'Impossible to import PID utility plugin: {str(e)}')
|
|
126
|
+
|
|
127
|
+
# add utility plugin for DataMixer
|
|
128
|
+
try:
|
|
129
|
+
data_mixer_module = importlib.import_module('pymodaq.extensions.data_mixer')
|
|
130
|
+
mod = [{'name': 'DataMixer',
|
|
131
|
+
'module': data_mixer_module,
|
|
132
|
+
'parent_module': data_mixer_module,
|
|
133
|
+
'type': 'daq_0Dviewer'}]
|
|
134
|
+
importlib.import_module(f'{data_mixer_module.__package__}.daq_0Dviewer_DataMixer')
|
|
135
|
+
plugins_import.extend(mod)
|
|
136
|
+
|
|
137
|
+
except Exception as e:
|
|
138
|
+
logger.debug(f'Impossible to import the DataMixer utility plugin: {str(e)}')
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
plugins_import.sort(key=lambda mod: mod['name'])
|
|
142
|
+
return plugins_import
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def get_plugins(plugin_type='daq_0Dviewer'): # pragma: no cover
|
|
146
|
+
"""
|
|
147
|
+
Get plugins names as a list
|
|
148
|
+
Parameters
|
|
149
|
+
----------
|
|
150
|
+
plugin_type: (str) plugin type either 'daq_0Dviewer', 'daq_1Dviewer', 'daq_2Dviewer', 'daq_NDviewer' or 'daq_move'
|
|
151
|
+
module: (module) parent module of the plugins
|
|
152
|
+
|
|
153
|
+
Returns
|
|
154
|
+
-------
|
|
155
|
+
|
|
156
|
+
"""
|
|
157
|
+
return [plug for plug in get_instrument_plugins() if plug['type'] == plugin_type]
|
|
158
|
+
|
pymodaq/utils/data.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import numbers
|
|
3
|
+
import warnings
|
|
4
|
+
import copy
|
|
5
|
+
|
|
6
|
+
from typing import List
|
|
7
|
+
|
|
8
|
+
from pymodaq_utils.warnings import deprecation_msg, user_warning
|
|
9
|
+
|
|
10
|
+
from pymodaq_data.data import (DataRaw, DataWithAxes, DataToExport, DataCalculated, DataDim,
|
|
11
|
+
DataSource, DataBase, Axis, NavAxis, DataDistribution, Q_, Unit,
|
|
12
|
+
) # imported here for backcompatibility. Will allow also the object serialization
|
|
13
|
+
# registration
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from pymodaq_utils.serialize.factory import SerializableFactory, SerializableBase
|
|
17
|
+
|
|
18
|
+
ser_factory = SerializableFactory()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@ser_factory.register_decorator()
|
|
22
|
+
class DataActuator(DataRaw):
|
|
23
|
+
"""Specialized DataWithAxes set with source as 'raw'.
|
|
24
|
+
To be used for raw data generated by actuator plugins"""
|
|
25
|
+
def __init__(self, *args, **kwargs):
|
|
26
|
+
if len(args) == 0 and 'name' not in kwargs:
|
|
27
|
+
args = ['actuator']
|
|
28
|
+
if 'data' not in kwargs:
|
|
29
|
+
kwargs['data'] = [np.array([0.])]
|
|
30
|
+
elif isinstance(kwargs['data'], numbers.Number): # useful formatting
|
|
31
|
+
kwargs['data'] = [np.array([kwargs['data']])]
|
|
32
|
+
super().__init__(*args, **kwargs)
|
|
33
|
+
|
|
34
|
+
def __repr__(self):
|
|
35
|
+
if self.dim.name == 'Data0D':
|
|
36
|
+
return f'<{self.__class__.__name__} ({self.data[0][0]} {self.units})>'
|
|
37
|
+
else:
|
|
38
|
+
return f'<{self.__class__.__name__} ({self.shape} {self.units})>'
|
|
39
|
+
|
|
40
|
+
def __add__(self, other: object):
|
|
41
|
+
if isinstance(other, numbers.Number) and self.length == 1 and self.size == 1:
|
|
42
|
+
new_data = copy.deepcopy(self)
|
|
43
|
+
new_data = new_data + DataActuator(data=other)
|
|
44
|
+
return new_data
|
|
45
|
+
|
|
46
|
+
else:
|
|
47
|
+
return super().__add__(other)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@ser_factory.register_decorator()
|
|
51
|
+
class DataFromPlugins(DataRaw):
|
|
52
|
+
"""Specialized DataWithAxes set with source as 'raw'. To be used for raw data generated by Detector plugins
|
|
53
|
+
|
|
54
|
+
It introduces by default to extra attributes, do_plot and do_save. Their presence can be checked in the
|
|
55
|
+
extra_attributes list.
|
|
56
|
+
|
|
57
|
+
Parameters
|
|
58
|
+
----------
|
|
59
|
+
do_plot: bool
|
|
60
|
+
If True the underlying data will be plotted in the DAQViewer
|
|
61
|
+
do_save: bool
|
|
62
|
+
If True the underlying data will be saved
|
|
63
|
+
|
|
64
|
+
Attributes
|
|
65
|
+
----------
|
|
66
|
+
do_plot: bool
|
|
67
|
+
If True the underlying data will be plotted in the DAQViewer
|
|
68
|
+
do_save: bool
|
|
69
|
+
If True the underlying data will be saved
|
|
70
|
+
"""
|
|
71
|
+
def __init__(self, *args, **kwargs):
|
|
72
|
+
|
|
73
|
+
##### for backcompatibility
|
|
74
|
+
if 'plot' in kwargs:
|
|
75
|
+
deprecation_msg("'plot' should not be used anymore as extra_attribute, "
|
|
76
|
+
"please use 'do_plot'")
|
|
77
|
+
do_plot = kwargs.pop('plot')
|
|
78
|
+
kwargs['do_plot'] = do_plot
|
|
79
|
+
|
|
80
|
+
if 'save' in kwargs:
|
|
81
|
+
deprecation_msg("'save' should not be used anymore as extra_attribute, "
|
|
82
|
+
"please use 'do_save'")
|
|
83
|
+
do_save = kwargs.pop('save')
|
|
84
|
+
kwargs['do_save'] = do_save
|
|
85
|
+
#######
|
|
86
|
+
|
|
87
|
+
if 'do_plot' not in kwargs:
|
|
88
|
+
kwargs['do_plot'] = True
|
|
89
|
+
if 'do_save' not in kwargs:
|
|
90
|
+
kwargs['do_save'] = True
|
|
91
|
+
super().__init__(*args, **kwargs)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@ser_factory.register_decorator()
|
|
95
|
+
class DataScan(DataToExport):
|
|
96
|
+
"""Specialized DataToExport.To be used for data to be saved """
|
|
97
|
+
def __init__(self, name: str, data: List[DataWithAxes] = [], **kwargs):
|
|
98
|
+
super().__init__(name, data, **kwargs)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@ser_factory.register_decorator()
|
|
102
|
+
class DataToActuators(DataToExport):
|
|
103
|
+
""" Particular case of a DataToExport adding one named parameter to indicate what kind of change
|
|
104
|
+
should be applied to the actuators, absolute or relative
|
|
105
|
+
|
|
106
|
+
Attributes
|
|
107
|
+
----------
|
|
108
|
+
mode: str
|
|
109
|
+
Adds an attribute called mode holding a string describing the type of change:
|
|
110
|
+
relative or absolute
|
|
111
|
+
|
|
112
|
+
Parameters
|
|
113
|
+
---------
|
|
114
|
+
mode: str
|
|
115
|
+
either 'rel' or 'abs' for a relative or absolute change of the actuator's values
|
|
116
|
+
"""
|
|
117
|
+
mode: str
|
|
118
|
+
|
|
119
|
+
def __init__(self, *args, mode='rel', **kwargs):
|
|
120
|
+
if mode not in ['rel', 'abs']:
|
|
121
|
+
user_warning('Incorrect mode for the actuators, '
|
|
122
|
+
'switching to default relative mode: rel')
|
|
123
|
+
mode = 'rel'
|
|
124
|
+
kwargs.update({'mode': mode})
|
|
125
|
+
super().__init__(*args, **kwargs)
|
|
126
|
+
|
|
127
|
+
def __repr__(self):
|
|
128
|
+
return f'{super().__repr__()}: {self.mode}'
|
pymodaq/utils/enums.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class DAQ_ScanException(Exception):
|
|
2
|
+
"""Raised when an error occur within the DAQScan"""
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DetectorError(Exception):
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ActuatorError(Exception):
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PIDError(Exception):
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class MasterSlaveError(Exception):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ExpectedError(Exception):
|
|
23
|
+
"""Raised in the tests made for pymodaq plugins"""
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Expected_1(ExpectedError):
|
|
28
|
+
"""Expected error 1 for pymodaq tests"""
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Expected_2(ExpectedError):
|
|
33
|
+
"""Expected error 2 for pymodaq tests"""
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Expected_3(ExpectedError):
|
|
38
|
+
"""Expected error 3 for pymodaq tests"""
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from pymodaq_gui.utils.dock import Dock, DockArea
|
|
2
|
+
from pymodaq_gui.utils.list_picker import ListPicker
|
|
3
|
+
from pymodaq_gui.utils.custom_app import CustomApp
|
|
4
|
+
from pymodaq_gui.utils.file_io import select_file
|
|
5
|
+
from pymodaq_gui.utils.widgets.table import TableView, TableModel, SpinBoxDelegate, BooleanDelegate
|
|
6
|
+
from pymodaq_gui.utils.widgets.push import PushButtonIcon, EditPush, EditPushRel, EditPushInfo
|
|
7
|
+
from pymodaq_gui.utils.widgets.qled import QLED
|
|
8
|
+
from pymodaq_gui.utils.widgets.spinbox import QSpinBox_ro
|
|
9
|
+
|
|
10
|
+
from .utils import get_splash_sc
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from qtpy.QtWidgets import QMessageBox, QMainWindow
|
|
4
|
+
|
|
5
|
+
from pymodaq.dashboard import DashBoard
|
|
6
|
+
from pymodaq.utils.gui_utils import DockArea
|
|
7
|
+
from pymodaq.utils.config import get_set_preset_path
|
|
8
|
+
from pymodaq.extensions.utils import CustomExt
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def load_dashboard_with_preset(preset_name: str, extension_name: str) -> \
|
|
12
|
+
(DashBoard, CustomExt, QMainWindow):
|
|
13
|
+
|
|
14
|
+
""" Load the Dashboard using a given preset then load an extension
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
preset_name: str
|
|
19
|
+
The filename (without extension) defining the preset to be loaded in the Dashboard
|
|
20
|
+
extension_name: str
|
|
21
|
+
The name of the extension. Either the builtins ones:
|
|
22
|
+
* 'DAQScan'
|
|
23
|
+
* 'DAQLogger'
|
|
24
|
+
* 'DAQ_PID'
|
|
25
|
+
* 'Bayesian'
|
|
26
|
+
|
|
27
|
+
or the ones defined within a plugin
|
|
28
|
+
|
|
29
|
+
Returns
|
|
30
|
+
-------
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
win = QMainWindow()
|
|
34
|
+
area = DockArea()
|
|
35
|
+
win.setCentralWidget(area)
|
|
36
|
+
win.resize(1000, 500)
|
|
37
|
+
win.setWindowTitle('extension_name')
|
|
38
|
+
win.show()
|
|
39
|
+
|
|
40
|
+
# win.setVisible(False)
|
|
41
|
+
dashboard = DashBoard(area)
|
|
42
|
+
|
|
43
|
+
preset_name = Path(preset_name).stem
|
|
44
|
+
|
|
45
|
+
file = Path(get_set_preset_path()).joinpath(f"{preset_name}.xml")
|
|
46
|
+
|
|
47
|
+
if file is not None and file.exists():
|
|
48
|
+
dashboard.set_preset_mode(file)
|
|
49
|
+
|
|
50
|
+
if extension_name:
|
|
51
|
+
if extension_name == 'DAQScan':
|
|
52
|
+
extension = dashboard.load_scan_module()
|
|
53
|
+
elif extension_name == 'DAQLogger':
|
|
54
|
+
extension = dashboard.load_log_module()
|
|
55
|
+
elif extension_name == 'DAQ_PID':
|
|
56
|
+
extension = dashboard.load_pid_module()
|
|
57
|
+
elif extension_name == 'Bayesian':
|
|
58
|
+
extension = dashboard.load_bayesian()
|
|
59
|
+
elif extension_name == 'AdaptiveScan':
|
|
60
|
+
extension = dashboard.load_adaptive()
|
|
61
|
+
elif extension_name == 'Data Mixer':
|
|
62
|
+
extension = dashboard.load_datamixer()
|
|
63
|
+
else:
|
|
64
|
+
extension = dashboard.load_extension_from_name(extension_name)
|
|
65
|
+
else:
|
|
66
|
+
extension = None
|
|
67
|
+
|
|
68
|
+
else:
|
|
69
|
+
msgBox = QMessageBox()
|
|
70
|
+
msgBox.setText(f"The default file specified in the configuration file does not exists!\n"
|
|
71
|
+
f"{file}\n"
|
|
72
|
+
f"Impossible to load the {extension_name} extension")
|
|
73
|
+
msgBox.setStandardButtons(QMessageBox.StandardButton.Ok)
|
|
74
|
+
ret = msgBox.exec()
|
|
75
|
+
return dashboard, extension, win
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from pymodaq_utils.config import Config
|
|
2
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
3
|
+
|
|
4
|
+
from pymodaq_gui.utils.splash import get_splash_sc
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
config = Config()
|
|
8
|
+
logger = set_logger(get_module_name(__file__))
|
|
9
|
+
|
|
10
|
+
from pymodaq_utils.warnings import deprecation_msg
|
|
11
|
+
|
|
12
|
+
deprecation_msg('Importing get_splash_sc stuff from pymodaq is deprecated '
|
|
13
|
+
'in pymodaq>5.0.0,'
|
|
14
|
+
'please use the same method from the '
|
|
15
|
+
'pymodaq_gui.utils.splash module')
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from pymodaq_gui.utils.widgets.lcd import LCD
|
|
2
|
+
|
|
3
|
+
from pymodaq_utils.warnings import deprecation_msg
|
|
4
|
+
|
|
5
|
+
deprecation_msg('Importing LCD from pymodaq is deprecated '
|
|
6
|
+
'in pymodaq>5.0.0,'
|
|
7
|
+
'please use the same method from the '
|
|
8
|
+
'pymodaq_gui.utils.widgets.lcd module')
|