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
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 23/11/2022
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Union, List, Dict, Tuple, TYPE_CHECKING, Iterable
|
|
10
|
+
import xml.etree.ElementTree as ET
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import numpy as np
|
|
14
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
15
|
+
from pymodaq_utils.enums import BaseEnum
|
|
16
|
+
from pymodaq_utils.abstract import ABCMeta, abstract_attribute, abstractmethod
|
|
17
|
+
from pymodaq_utils.utils import capitalize
|
|
18
|
+
from pymodaq_data.data import Axis, DataDim, DataWithAxes, DataToExport, DataDistribution
|
|
19
|
+
from pymodaq_data.h5modules.saving import H5SaverLowLevel
|
|
20
|
+
from pymodaq_data.h5modules.backends import GROUP, CARRAY, Node, GroupType
|
|
21
|
+
from pymodaq_data.h5modules.data_saving import (
|
|
22
|
+
DataToExportSaver, AxisSaverLoader, DataToExportEnlargeableSaver,
|
|
23
|
+
DataToExportTimedSaver, DataToExportExtendedSaver)
|
|
24
|
+
from pymodaq_gui.parameter import ioxml
|
|
25
|
+
|
|
26
|
+
if TYPE_CHECKING:
|
|
27
|
+
from pymodaq.extensions.daq_scan import DAQScan
|
|
28
|
+
from pymodaq.control_modules.daq_viewer import DAQ_Viewer
|
|
29
|
+
from pymodaq.control_modules.daq_move import DAQ_Move
|
|
30
|
+
from pymodaq.extensions.daq_logger.h5logging import H5Logger
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
logger = set_logger(get_module_name(__file__))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class GroupModuleType(BaseEnum):
|
|
37
|
+
DETECTOR = 0
|
|
38
|
+
ACTUATOR = 1
|
|
39
|
+
SCAN = 2
|
|
40
|
+
DATALOGGER = 3
|
|
41
|
+
OPTIMIZER = 4
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ModuleSaver(metaclass=ABCMeta):
|
|
45
|
+
"""Abstract base class to save info and data from main modules (DAQScan, DAQViewer, DAQMove, ...)"""
|
|
46
|
+
group_type: GroupModuleType = abstract_attribute()
|
|
47
|
+
_module = abstract_attribute()
|
|
48
|
+
_h5saver: H5SaverLowLevel = abstract_attribute()
|
|
49
|
+
_module_group: GROUP = abstract_attribute()
|
|
50
|
+
main_module = True
|
|
51
|
+
|
|
52
|
+
def flush(self):
|
|
53
|
+
"""Flush the underlying file"""
|
|
54
|
+
self._h5saver.flush()
|
|
55
|
+
|
|
56
|
+
def get_set_node(self, where: Union[Node, str] = None, name: str = None) -> GROUP:
|
|
57
|
+
"""Get or create the node corresponding to this particular Module instance
|
|
58
|
+
|
|
59
|
+
Parameters
|
|
60
|
+
----------
|
|
61
|
+
where: Union[Node, str]
|
|
62
|
+
the path of a given node or the node itself
|
|
63
|
+
new: bool
|
|
64
|
+
if True force the creation of a new indexed node of this class type
|
|
65
|
+
if False return the last node (or create one if None)
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
GROUP: the Node associated with this module which should be a GROUP node
|
|
70
|
+
"""
|
|
71
|
+
if where is None:
|
|
72
|
+
where = self._h5saver.raw_group
|
|
73
|
+
if name is None:
|
|
74
|
+
name = self._module.title
|
|
75
|
+
group = self._h5saver.get_node_from_title(where, name)
|
|
76
|
+
if group is not None:
|
|
77
|
+
self._module_group = group
|
|
78
|
+
return group # if I got one I return it else I create one
|
|
79
|
+
|
|
80
|
+
self._module_group = self._add_module(where)
|
|
81
|
+
return self._module_group
|
|
82
|
+
|
|
83
|
+
def get_last_node(self, where: Union[Node, str] = None):
|
|
84
|
+
"""Get the last node corresponding to this particular Module instance
|
|
85
|
+
|
|
86
|
+
Parameters
|
|
87
|
+
----------
|
|
88
|
+
where: Union[Node, str]
|
|
89
|
+
the path of a given node or the node itself
|
|
90
|
+
new: bool
|
|
91
|
+
if True force the creation of a new indexed node of this class type
|
|
92
|
+
if False return the last node (or create one if None)
|
|
93
|
+
|
|
94
|
+
Returns
|
|
95
|
+
-------
|
|
96
|
+
GROUP: the Node associated with this module which should be a GROUP node
|
|
97
|
+
"""
|
|
98
|
+
if where is None:
|
|
99
|
+
where = self._h5saver.raw_group
|
|
100
|
+
|
|
101
|
+
group = self._h5saver.get_last_group(where, self.group_type)
|
|
102
|
+
self._module_group = group
|
|
103
|
+
return self._module_group
|
|
104
|
+
|
|
105
|
+
@abstractmethod
|
|
106
|
+
def _add_module(self, where: Union[Node, str] = None, metadata={}):
|
|
107
|
+
...
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def module(self):
|
|
111
|
+
return self._module
|
|
112
|
+
|
|
113
|
+
@property
|
|
114
|
+
def module_group(self):
|
|
115
|
+
return self._module_group
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def h5saver(self):
|
|
119
|
+
return self._h5saver
|
|
120
|
+
|
|
121
|
+
@h5saver.setter
|
|
122
|
+
def h5saver(self, _h5saver: H5SaverLowLevel):
|
|
123
|
+
self._h5saver = _h5saver
|
|
124
|
+
self.update_after_h5changed()
|
|
125
|
+
|
|
126
|
+
@abstractmethod
|
|
127
|
+
def update_after_h5changed(self):
|
|
128
|
+
...
|
|
129
|
+
|
|
130
|
+
def get_last_node_index(self, where: Union[Node, str] = None):
|
|
131
|
+
node = self.get_last_node(where)
|
|
132
|
+
return int(node.name.split(capitalize(self.group_type.name.lower()))[1])
|
|
133
|
+
|
|
134
|
+
def get_next_node_name(self, where: Union[Node, str] = None):
|
|
135
|
+
index = self.get_last_node_index(where)
|
|
136
|
+
return f'{capitalize(self.group_type.name.lower())}{index+1:03d}'
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class DetectorSaver(ModuleSaver):
|
|
140
|
+
"""Implementation of the ModuleSaver class dedicated to DAQ_Viewer modules
|
|
141
|
+
|
|
142
|
+
Parameters
|
|
143
|
+
----------
|
|
144
|
+
module
|
|
145
|
+
"""
|
|
146
|
+
group_type = GroupModuleType.DETECTOR
|
|
147
|
+
|
|
148
|
+
def __init__(self, module: DAQ_Viewer):
|
|
149
|
+
self._datatoexport_saver: DataToExportSaver = None
|
|
150
|
+
|
|
151
|
+
self._module: 'DAQ_Viewer' = module
|
|
152
|
+
self._module_group: GROUP = None
|
|
153
|
+
self._h5saver = None
|
|
154
|
+
|
|
155
|
+
def update_after_h5changed(self, ):
|
|
156
|
+
self._datatoexport_saver = DataToExportSaver(self.h5saver)
|
|
157
|
+
|
|
158
|
+
def _add_module(self, where: Union[Node, str] = None, metadata={}) -> Node:
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
Parameters
|
|
162
|
+
----------
|
|
163
|
+
where: Union[Node, str]
|
|
164
|
+
the path of a given node or the node itself
|
|
165
|
+
metadata: dict
|
|
166
|
+
|
|
167
|
+
Returns
|
|
168
|
+
-------
|
|
169
|
+
|
|
170
|
+
"""
|
|
171
|
+
if where is None:
|
|
172
|
+
where = self._h5saver.raw_group
|
|
173
|
+
|
|
174
|
+
settings_xml = ET.Element('All_settings', type='group')
|
|
175
|
+
settings_xml.append(ioxml.walk_parameters_to_xml(param=self._module.settings))
|
|
176
|
+
if self.main_module:
|
|
177
|
+
saver_xml = ET.SubElement(settings_xml, 'H5Saver', type='group')
|
|
178
|
+
saver_xml.append(ioxml.walk_parameters_to_xml(param=self._h5saver.settings))
|
|
179
|
+
|
|
180
|
+
if self._module.ui is not None:
|
|
181
|
+
for ind, viewer in enumerate(self._module.viewers):
|
|
182
|
+
if hasattr(viewer, 'roi_manager'):
|
|
183
|
+
roi_xml = ET.SubElement(settings_xml, f'ROI_Viewer_{ind:02d}', type='group')
|
|
184
|
+
roi_xml.append(ioxml.walk_parameters_to_xml(param=viewer.roi_manager.settings))
|
|
185
|
+
|
|
186
|
+
return self._h5saver.add_det_group(where, title=self._module.title, settings_as_xml=ET.tostring(settings_xml),
|
|
187
|
+
metadata=metadata)
|
|
188
|
+
|
|
189
|
+
def add_data(self, where: Union[Node, str], data: DataToExport, **kwargs):
|
|
190
|
+
self._datatoexport_saver.add_data(where, data, **kwargs)
|
|
191
|
+
|
|
192
|
+
def add_bkg(self, where: Union[Node, str], data_bkg: DataToExport):
|
|
193
|
+
""" Adds a DataToExport as a background node in the h5file
|
|
194
|
+
|
|
195
|
+
Parameters
|
|
196
|
+
----------
|
|
197
|
+
where: Union[Node, str]
|
|
198
|
+
the path of a given node or the node itself
|
|
199
|
+
data_bkg: DataToExport
|
|
200
|
+
The data to be saved as background
|
|
201
|
+
|
|
202
|
+
Returns
|
|
203
|
+
-------
|
|
204
|
+
|
|
205
|
+
"""
|
|
206
|
+
self._datatoexport_saver.add_bkg(where, data_bkg)
|
|
207
|
+
|
|
208
|
+
def add_external_h5(self, other_h5data: H5SaverLowLevel):
|
|
209
|
+
if other_h5data is not None:
|
|
210
|
+
external_group = self._h5saver.add_group('external_data', 'external_h5', self.module_group)
|
|
211
|
+
try:
|
|
212
|
+
if not other_h5data.isopen:
|
|
213
|
+
h5saver = H5SaverLowLevel()
|
|
214
|
+
h5saver.init_file(addhoc_file_path=other_h5data.filename)
|
|
215
|
+
h5_file = h5saver.h5_file
|
|
216
|
+
else:
|
|
217
|
+
h5_file = other_h5data
|
|
218
|
+
h5_file.copy_children(h5_file.get_node('/'), external_group, recursive=True)
|
|
219
|
+
h5_file.flush()
|
|
220
|
+
h5_file.close()
|
|
221
|
+
|
|
222
|
+
except Exception as e:
|
|
223
|
+
self.logger.exception(str(e))
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class DetectorTimeSaver(DetectorSaver):
|
|
227
|
+
"""Implementation of the ModuleSaver class dedicated to DAQ_Viewer modules in order to save enlargeable data
|
|
228
|
+
|
|
229
|
+
Parameters
|
|
230
|
+
----------
|
|
231
|
+
module
|
|
232
|
+
"""
|
|
233
|
+
group_type = GroupModuleType.DETECTOR
|
|
234
|
+
|
|
235
|
+
def __init__(self, module: DAQ_Viewer):
|
|
236
|
+
super().__init__(module)
|
|
237
|
+
self._datatoexport_saver: DataToExportTimedSaver = None
|
|
238
|
+
|
|
239
|
+
def update_after_h5changed(self, ):
|
|
240
|
+
self._datatoexport_saver = DataToExportTimedSaver(self.h5saver)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
class DetectorEnlargeableSaver(DetectorSaver):
|
|
244
|
+
"""Implementation of the ModuleSaver class dedicated to DAQ_Viewer modules in order to save enlargeable data
|
|
245
|
+
|
|
246
|
+
Parameters
|
|
247
|
+
----------
|
|
248
|
+
module
|
|
249
|
+
"""
|
|
250
|
+
group_type = GroupModuleType.DETECTOR
|
|
251
|
+
|
|
252
|
+
def __init__(self, module: DAQ_Viewer,
|
|
253
|
+
enl_axis_names: Iterable[str] = None,
|
|
254
|
+
enl_axis_units: Iterable[str] = None,):
|
|
255
|
+
super().__init__(module)
|
|
256
|
+
self.enl_axis_names = enl_axis_names
|
|
257
|
+
self.enl_axis_units = enl_axis_units
|
|
258
|
+
self._datatoexport_saver: DataToExportEnlargeableSaver = None
|
|
259
|
+
|
|
260
|
+
def update_after_h5changed(self):
|
|
261
|
+
self._datatoexport_saver = DataToExportEnlargeableSaver(
|
|
262
|
+
self.h5saver, self.enl_axis_names, self.enl_axis_units)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class DetectorExtendedSaver(DetectorSaver):
|
|
266
|
+
"""Implementation of the ModuleSaver class dedicated to DAQ_Viewer modules in order to save enlargeable data
|
|
267
|
+
|
|
268
|
+
Parameters
|
|
269
|
+
----------
|
|
270
|
+
module
|
|
271
|
+
"""
|
|
272
|
+
group_type = GroupModuleType.DETECTOR
|
|
273
|
+
|
|
274
|
+
def __init__(self, module: DAQ_Viewer, extended_shape: Tuple[int]):
|
|
275
|
+
super().__init__(module)
|
|
276
|
+
self._extended_shape = extended_shape
|
|
277
|
+
self._datatoexport_saver: DataToExportExtendedSaver = None
|
|
278
|
+
|
|
279
|
+
def update_after_h5changed(self, ):
|
|
280
|
+
self._datatoexport_saver = DataToExportExtendedSaver(self.h5saver, self._extended_shape)
|
|
281
|
+
|
|
282
|
+
def add_data(self, where: Union[Node, str], data: DataToExport, indexes: Tuple[int],
|
|
283
|
+
distribution=DataDistribution['uniform']):
|
|
284
|
+
self._datatoexport_saver.add_data(where, data, indexes=indexes, distribution=distribution)
|
|
285
|
+
|
|
286
|
+
def add_nav_axes(self, where: Union[Node, str], axes: List[Axis]):
|
|
287
|
+
self._datatoexport_saver.add_nav_axes(where, axes)
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class ActuatorSaver(ModuleSaver):
|
|
291
|
+
"""Implementation of the ModuleSaver class dedicated to DAQ_Move modules
|
|
292
|
+
|
|
293
|
+
Parameters
|
|
294
|
+
----------
|
|
295
|
+
h5saver
|
|
296
|
+
module
|
|
297
|
+
"""
|
|
298
|
+
group_type = GroupModuleType.ACTUATOR
|
|
299
|
+
|
|
300
|
+
def __init__(self, module: DAQ_Move):
|
|
301
|
+
self._datatoexport_saver: DataToExportSaver = None
|
|
302
|
+
self._module_group: GROUP = None
|
|
303
|
+
self._module: DAQ_Move = module
|
|
304
|
+
self._h5saver = None
|
|
305
|
+
|
|
306
|
+
def update_after_h5changed(self, ):
|
|
307
|
+
self._datatoexport_saver = DataToExportSaver(self.h5saver)
|
|
308
|
+
|
|
309
|
+
def _add_module(self, where: Union[Node, str] = None, metadata=None):
|
|
310
|
+
if metadata is None:
|
|
311
|
+
metadata={}
|
|
312
|
+
if where is None:
|
|
313
|
+
where = self._h5saver.raw_group
|
|
314
|
+
|
|
315
|
+
settings_xml = ET.Element('All_settings')
|
|
316
|
+
settings_xml.append(ioxml.walk_parameters_to_xml(param=self._module.settings))
|
|
317
|
+
|
|
318
|
+
return self._h5saver.add_act_group(where, title=self._module.title, settings_as_xml=ET.tostring(settings_xml),
|
|
319
|
+
metadata=metadata)
|
|
320
|
+
|
|
321
|
+
def add_data(self, where: Union[Node, str], data: DataToExport):
|
|
322
|
+
self._datatoexport_saver.add_data(where, data)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
class ActuatorTimeSaver(ActuatorSaver):
|
|
326
|
+
def __init__(self, module: DAQ_Move):
|
|
327
|
+
super().__init__(module)
|
|
328
|
+
self._datatoexport_saver: DataToExportTimedSaver = None
|
|
329
|
+
|
|
330
|
+
def update_after_h5changed(self, ):
|
|
331
|
+
self._datatoexport_saver = DataToExportTimedSaver(self.h5saver)
|
|
332
|
+
|
|
333
|
+
def add_data(self, where: Union[Node, str], data: DataToExport):
|
|
334
|
+
self._datatoexport_saver.add_data(where, data)
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
class ActuatorEnlargeableSaver(ActuatorTimeSaver):
|
|
338
|
+
"""Implementation of the ModuleSaver class dedicated to DAQ_Move modules
|
|
339
|
+
|
|
340
|
+
Parameters
|
|
341
|
+
----------
|
|
342
|
+
h5saver
|
|
343
|
+
module
|
|
344
|
+
"""
|
|
345
|
+
|
|
346
|
+
def __init__(self, module: DAQ_Move,
|
|
347
|
+
enl_axis_names: Iterable[str] = None,
|
|
348
|
+
enl_axis_units: Iterable[str] = None,):
|
|
349
|
+
super().__init__(module)
|
|
350
|
+
self.enl_axis_names = enl_axis_names
|
|
351
|
+
self.enl_axis_units = enl_axis_units
|
|
352
|
+
self._datatoexport_saver: DataToExportEnlargeableSaver = None
|
|
353
|
+
|
|
354
|
+
def update_after_h5changed(self, ):
|
|
355
|
+
self._datatoexport_saver = DataToExportEnlargeableSaver(
|
|
356
|
+
self.h5saver, self.enl_axis_names, self.enl_axis_units)
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def add_data(self, where: Union[Node, str], data: DataToExport,
|
|
360
|
+
axis_values: List[Union[float, np.ndarray]] = None,
|
|
361
|
+
**kwargs):
|
|
362
|
+
self._datatoexport_saver.add_data(where, data, axis_values, **kwargs)
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
class ScanSaver(ModuleSaver):
|
|
366
|
+
"""Implementation of the ModuleSaver class dedicated to DAQScan module
|
|
367
|
+
|
|
368
|
+
Parameters
|
|
369
|
+
----------
|
|
370
|
+
h5saver
|
|
371
|
+
module
|
|
372
|
+
"""
|
|
373
|
+
group_type = GroupModuleType.SCAN
|
|
374
|
+
|
|
375
|
+
def __init__(self, module):
|
|
376
|
+
self._module_group: GROUP = None
|
|
377
|
+
self._module: DAQScan = module
|
|
378
|
+
self._h5saver = None
|
|
379
|
+
|
|
380
|
+
for detector in self._module.modules_manager.detectors_all:
|
|
381
|
+
detector._module_and_data_saver = DetectorSaver(detector)
|
|
382
|
+
for actuator in self._module.modules_manager.actuators_all:
|
|
383
|
+
actuator._module_and_data_saver = ActuatorSaver(actuator)
|
|
384
|
+
|
|
385
|
+
def update_after_h5changed(self):
|
|
386
|
+
for module in self._module.modules_manager.modules_all:
|
|
387
|
+
if hasattr(module, '_module_and_data_saver'):
|
|
388
|
+
module._module_and_data_saver.h5saver = self.h5saver
|
|
389
|
+
|
|
390
|
+
def forget_h5(self):
|
|
391
|
+
for module in self._module.modules_manager.modules_all:
|
|
392
|
+
if hasattr(module, 'module_and_data_saver'):
|
|
393
|
+
module.module_and_data_saver.h5saver = None
|
|
394
|
+
self.h5saver.flush()
|
|
395
|
+
|
|
396
|
+
def get_set_node(self, where: Union[Node, str] = None, new=False) -> GROUP:
|
|
397
|
+
"""Get the last group scan node
|
|
398
|
+
|
|
399
|
+
Get the last Scan Group or create one
|
|
400
|
+
get the last Scan Group if:
|
|
401
|
+
* there is one already created
|
|
402
|
+
* new is False
|
|
403
|
+
|
|
404
|
+
Parameters
|
|
405
|
+
----------
|
|
406
|
+
where: Union[Node, str]
|
|
407
|
+
the path of a given node or the node itself
|
|
408
|
+
new: bool
|
|
409
|
+
|
|
410
|
+
Returns
|
|
411
|
+
-------
|
|
412
|
+
GROUP: the GROUP associated with this module
|
|
413
|
+
"""
|
|
414
|
+
self._module_group = self.get_last_node(where)
|
|
415
|
+
new = new or (self._module_group is None)
|
|
416
|
+
if new:
|
|
417
|
+
self._module_group = self._add_module(where)
|
|
418
|
+
for module in self._module.modules_manager.modules:
|
|
419
|
+
module.module_and_data_saver.main_module = False
|
|
420
|
+
module.module_and_data_saver.get_set_node(self._module_group)
|
|
421
|
+
return self._module_group
|
|
422
|
+
|
|
423
|
+
def _add_module(self, where: Union[Node, str] = None, metadata=None) -> Node:
|
|
424
|
+
"""
|
|
425
|
+
|
|
426
|
+
Parameters
|
|
427
|
+
----------
|
|
428
|
+
where: Union[Node, str]
|
|
429
|
+
the path of a given node or the node itself
|
|
430
|
+
metadata: dict
|
|
431
|
+
|
|
432
|
+
Returns
|
|
433
|
+
-------
|
|
434
|
+
|
|
435
|
+
"""
|
|
436
|
+
if metadata is None:
|
|
437
|
+
metadata = {}
|
|
438
|
+
if where is None:
|
|
439
|
+
where = self._h5saver.raw_group
|
|
440
|
+
|
|
441
|
+
settings_xml = ET.Element('All_settings', type='group')
|
|
442
|
+
settings_xml.append(ioxml.walk_parameters_to_xml(param=self._module.settings))
|
|
443
|
+
if self.main_module:
|
|
444
|
+
saver_xml = ET.SubElement(settings_xml, 'H5Saver', type='group')
|
|
445
|
+
saver_xml.append(ioxml.walk_parameters_to_xml(param=self._h5saver.settings))
|
|
446
|
+
|
|
447
|
+
return self._h5saver.add_generic_group(where, title=self._module.title,
|
|
448
|
+
settings_as_xml=ET.tostring(settings_xml),
|
|
449
|
+
metadata=metadata,
|
|
450
|
+
group_type=self.group_type.name)
|
|
451
|
+
|
|
452
|
+
def add_nav_axes(self, axes: List[Axis]):
|
|
453
|
+
for detector in self._module.modules_manager.detectors:
|
|
454
|
+
detector.module_and_data_saver.add_nav_axes(self._module_group, axes)
|
|
455
|
+
|
|
456
|
+
def add_data(self, dte: DataToExport = None, indexes: Tuple[int] = None,
|
|
457
|
+
distribution=DataDistribution['uniform'], **kwargs):
|
|
458
|
+
for detector in self._module.modules_manager.detectors:
|
|
459
|
+
try:
|
|
460
|
+
detector.insert_data(indexes, where=self._module_group, distribution=distribution)
|
|
461
|
+
except Exception as e:
|
|
462
|
+
logger.exception(f'Cannot insert data: {str(e)}')
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
class LoggerSaver(ScanSaver):
|
|
466
|
+
"""Implementation of the ModuleSaver class dedicated to H5Logger module
|
|
467
|
+
|
|
468
|
+
H5Logger is the special logger to h5file of the DAQ_Logger extension
|
|
469
|
+
|
|
470
|
+
Parameters
|
|
471
|
+
----------
|
|
472
|
+
h5saver
|
|
473
|
+
module
|
|
474
|
+
"""
|
|
475
|
+
group_type = GroupModuleType.DATALOGGER
|
|
476
|
+
|
|
477
|
+
def add_data(self, dte: DataToExport):
|
|
478
|
+
"""Add data to it's corresponding control module
|
|
479
|
+
|
|
480
|
+
The name of the control module is the DataToExport name attribute
|
|
481
|
+
"""
|
|
482
|
+
if dte.name in self._module.modules_manager.detectors_name:
|
|
483
|
+
control_module = self._module.modules_manager.detectors[
|
|
484
|
+
self._module.modules_manager.detectors_name.index(dte.name)]
|
|
485
|
+
elif dte.name in self._module.modules_manager.actuators_name:
|
|
486
|
+
control_module = self._module.modules_manager.actuators[
|
|
487
|
+
self._module.modules_manager.actuators_name.index(dte.name)]
|
|
488
|
+
else:
|
|
489
|
+
return
|
|
490
|
+
|
|
491
|
+
control_module.append_data(dte=dte, where=self._module_group)
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
class OptimizerSaver(ScanSaver):
|
|
495
|
+
"""Implementation of the ModuleSaver class dedicated to Optimizer based modules
|
|
496
|
+
|
|
497
|
+
Parameters
|
|
498
|
+
----------
|
|
499
|
+
h5saver
|
|
500
|
+
module
|
|
501
|
+
"""
|
|
502
|
+
group_type = GroupModuleType.OPTIMIZER
|
|
503
|
+
|
|
504
|
+
def __init__(self, module,
|
|
505
|
+
enl_axis_names: Iterable[str] = None,
|
|
506
|
+
enl_axis_units: Iterable[str] = None,):
|
|
507
|
+
super().__init__(module)
|
|
508
|
+
self.enl_axis_names = enl_axis_names
|
|
509
|
+
self.enl_axis_units = enl_axis_units
|
|
510
|
+
|
|
511
|
+
def update_after_h5changed(self, ):
|
|
512
|
+
for module in self._module.modules_manager.detectors:
|
|
513
|
+
module.module_and_data_saver = DetectorEnlargeableSaver(
|
|
514
|
+
module, self.enl_axis_names, self.enl_axis_units)
|
|
515
|
+
module.module_and_data_saver.h5saver = self.h5saver
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
def add_data(self, *args, axis_values: List[Union[float, np.ndarray]] = None,
|
|
519
|
+
**kwargs):
|
|
520
|
+
for module in self._module.modules_manager.detectors:
|
|
521
|
+
try:
|
|
522
|
+
module.append_data(where=self._module_group,
|
|
523
|
+
axis_values=axis_values,
|
|
524
|
+
**kwargs)
|
|
525
|
+
except Exception as e:
|
|
526
|
+
logger.exception(f'Cannot append data: {str(e)}')
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from pymodaq_utils.logger import set_logger
|
|
2
|
+
from pymodaq_utils.config import Config
|
|
3
|
+
|
|
4
|
+
logger = set_logger('pymodaq')
|
|
5
|
+
config = Config() # to ckeck for config file existence, otherwise create one
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
if config('network', 'leco-server', 'run_coordinator_at_startup'):
|
|
9
|
+
try:
|
|
10
|
+
from pymodaq.utils.leco.utils import start_coordinator
|
|
11
|
+
|
|
12
|
+
logger.info('')
|
|
13
|
+
logger.info('')
|
|
14
|
+
logger.info(f'********************************')
|
|
15
|
+
logger.info(f"Starting the LECO Coordinator...")
|
|
16
|
+
start_coordinator()
|
|
17
|
+
logger.info(f"Done")
|
|
18
|
+
except ImportError as e:
|
|
19
|
+
logger.warning(f'Issue while importing the pyleco package: {str(e)}')
|
|
20
|
+
except Exception as e:
|
|
21
|
+
logger.warning(f'Issue while starting the pyleco coordinator: {str(e)}')
|
|
22
|
+
finally:
|
|
23
|
+
logger.info('************************')
|
|
24
|
+
logger.info('')
|
|
25
|
+
logger.info('')
|