pymodaq_data 5.0.20__tar.gz → 5.0.22__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/PKG-INFO +1 -1
  2. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/_version.py +2 -2
  3. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/data.py +7 -11
  4. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/backends.py +8 -4
  5. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/saving.py +48 -17
  6. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/.gitignore +0 -0
  7. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/LICENSE +0 -0
  8. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/README.rst +0 -0
  9. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/pyproject.toml +0 -0
  10. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/__init__.py +0 -0
  11. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/__init__.py +0 -0
  12. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/browsing.py +0 -0
  13. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/data_saving.py +0 -0
  14. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/exporter.py +0 -0
  15. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/exporters/__init__.py +0 -0
  16. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/exporters/base.py +0 -0
  17. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/exporters/flimj.py +0 -0
  18. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/exporters/hyperspy.py +0 -0
  19. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/h5modules/utils.py +0 -0
  20. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/icon.ico +0 -0
  21. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/numpy_func.py +0 -0
  22. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/plotting/__init__.py +0 -0
  23. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/plotting/plotter/plotter.py +0 -0
  24. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/plotting/plotter/plotters/__init__.py +0 -0
  25. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/plotting/plotter/plotters/matplotlib_plotters.py +0 -0
  26. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/post_treatment/__init__.py +0 -0
  27. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/post_treatment/process_to_scalar.py +0 -0
  28. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/slicing.py +0 -0
  29. {pymodaq_data-5.0.20 → pymodaq_data-5.0.22}/src/pymodaq_data/splash.png +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pymodaq_data
3
- Version: 5.0.20
3
+ Version: 5.0.22
4
4
  Summary: Modular Data Acquisition with Python
5
5
  Project-URL: Homepage, http://pymodaq.cnrs.fr
6
6
  Project-URL: Source, https://github.com/PyMoDAQ/pymodaq_data
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '5.0.20'
21
- __version_tuple__ = version_tuple = (5, 0, 20)
20
+ __version__ = version = '5.0.22'
21
+ __version_tuple__ = version_tuple = (5, 0, 22)
@@ -443,6 +443,7 @@ class Axis(SerializableBase):
443
443
  self._scaling = np.mean(np.diff(data))
444
444
  self._offset = data[0]
445
445
  self._data = None
446
+ self._size = len(data)
446
447
 
447
448
  def is_axis_linear(self, data=None):
448
449
  if data is None:
@@ -523,16 +524,11 @@ class Axis(SerializableBase):
523
524
  elif _slice is Ellipsis:
524
525
  return ax
525
526
  elif isinstance(_slice, slice):
526
- if ax._data is not None:
527
- ax.data = ax._data.__getitem__(_slice)
528
- return ax
527
+ if ax.is_axis_linear():
528
+ ax.get_scale_offset_from_data(ax.get_data().__getitem__(_slice))
529
529
  else:
530
- start = _slice.start if _slice.start is not None else 0
531
- stop = _slice.stop if _slice.stop is not None else self.size
532
-
533
- ax._offset = ax.offset + start * ax.scaling
534
- ax._size = stop - start
535
- return ax
530
+ ax.data = ax.get_data().__getitem__(_slice)
531
+ return ax
536
532
 
537
533
  def __getitem__(self, item):
538
534
  if hasattr(self, item):
@@ -2094,12 +2090,12 @@ class DataWithAxes(DataBase, SerializableBase):
2094
2090
  return plotter_factory.get(plotter_backend).plot(self, *args, viewer=viewer, **kwargs)
2095
2091
 
2096
2092
  def set_axes_manager(self, data_shape, axes, nav_indexes, **kwargs):
2097
- if self.distribution.name == DataDistribution.uniform.name or len(nav_indexes) == 0:
2093
+ if self.distribution == DataDistribution.uniform or len(nav_indexes) == 0:
2098
2094
  self._distribution = DataDistribution.uniform
2099
2095
  self.axes_manager = AxesManagerUniform(data_shape=data_shape, axes=axes,
2100
2096
  nav_indexes=nav_indexes,
2101
2097
  **kwargs)
2102
- elif self.distribution.name == DataDistribution.spread.name:
2098
+ elif self.distribution == DataDistribution.spread:
2103
2099
  self.axes_manager = AxesManagerSpread(data_shape=data_shape, axes=axes,
2104
2100
  nav_indexes=nav_indexes,
2105
2101
  **kwargs)
@@ -4,6 +4,8 @@ Created the 15/11/2022
4
4
 
5
5
  @author: Sebastien Weber
6
6
  """
7
+ from typing import Union
8
+ from enum import Enum
7
9
  import numpy as np
8
10
  import importlib
9
11
  from importlib import metadata
@@ -63,6 +65,7 @@ class SaveType(BaseEnum):
63
65
  logger = 2
64
66
  custom = 3
65
67
  actuator = 4
68
+ optimizer = 5
66
69
 
67
70
 
68
71
  class GroupType(BaseEnum):
@@ -1008,14 +1011,14 @@ class H5Backend:
1008
1011
  array.attrs['backend'] = self.backend
1009
1012
  return array
1010
1013
 
1011
- def add_group(self, group_name, group_type: GroupType, where, title='', metadata=dict([])) -> GROUP:
1014
+ def add_group(self, group_name, group_type: Union[GroupType, str], where, title='', metadata=dict([])) -> GROUP:
1012
1015
  """
1013
1016
  Add a node in the h5 file tree of the group type
1014
1017
  Parameters
1015
1018
  ----------
1016
1019
  group_name: (str) a custom name for this group
1017
1020
  group_type: str or GroupType enum
1018
- one of the possible values of GroupType
1021
+ one of the possible values of GroupType, should be enforced by higher level modules not here
1019
1022
  where: (str or node) parent node where to create the new group
1020
1023
  metadata: (dict) extra metadata to be saved with this new group node
1021
1024
 
@@ -1026,14 +1029,15 @@ class H5Backend:
1026
1029
  if isinstance(where, Node):
1027
1030
  where = where.node
1028
1031
 
1029
- group_type = enum_checker(GroupType, group_type)
1032
+ if isinstance(group_type, Enum):
1033
+ group_type = group_type.name
1030
1034
 
1031
1035
  if group_name in self.get_children(self.get_node(where)):
1032
1036
  node = self.get_node(where, group_name)
1033
1037
 
1034
1038
  else:
1035
1039
  node = self.get_set_group(where, utils.capitalize(group_name), title)
1036
- node.attrs['type'] = group_type.name.lower()
1040
+ node.attrs['type'] = group_type.lower()
1037
1041
  for metadat in metadata:
1038
1042
  node.attrs[metadat] = metadata[metadat]
1039
1043
  node.attrs['backend'] = self.backend
@@ -6,6 +6,8 @@ Created the 15/11/2022
6
6
  """
7
7
  import copy
8
8
  import datetime
9
+ import enum
10
+
9
11
  from dateutil import parser
10
12
  from numbers import Number
11
13
  import os
@@ -262,16 +264,18 @@ class H5SaverLowLevel(H5Backend):
262
264
  self._current_group = super().get_set_group(where, name, title, **kwargs)
263
265
  return self._current_group
264
266
 
265
- def get_groups(self, where: Union[str, GROUP], group_type: GroupType):
267
+ def get_groups(self, where: Union[str, GROUP], group_type: Union[str, GroupType, BaseEnum]):
266
268
  """Get all groups hanging from a Group and of a certain type"""
267
269
  groups = []
270
+ if isinstance(group_type, enum.Enum):
271
+ group_type = group_type.name
268
272
  for node_name in list(self.get_children(where)):
269
273
  group = self.get_node(where, node_name)
270
- if 'type' in group.attrs and group.attrs['type'] == group_type.name:
274
+ if 'type' in group.attrs and group.attrs['type'].lower() == group_type.lower():
271
275
  groups.append(group)
272
276
  return groups
273
277
 
274
- def get_last_group(self, where: GROUP, group_type: GroupType):
278
+ def get_last_group(self, where: GROUP, group_type: Union[str, GroupType, enum.Enum]):
275
279
  groups = self.get_groups(where, group_type)
276
280
  if len(groups) != 0:
277
281
  return groups[-1]
@@ -288,7 +292,7 @@ class H5SaverLowLevel(H5Backend):
288
292
  """Get a Node starting from a given node (Group) matching the given title"""
289
293
  return self.get_node_from_attribute_match(where, 'TITLE', title)
290
294
 
291
- def add_data_group(self, where, data_dim: DataDim, title='', settings_as_xml='', metadata=dict([])):
295
+ def add_data_group(self, where, data_dim: DataDim, title='', settings_as_xml='', metadata=None):
292
296
  """Creates a group node at given location in the tree
293
297
 
294
298
  Parameters
@@ -311,12 +315,14 @@ class H5SaverLowLevel(H5Backend):
311
315
  --------
312
316
  :py:meth:`add_group`
313
317
  """
318
+ if metadata is None:
319
+ metadata = {}
314
320
  data_dim = enum_checker(DataDim, data_dim)
315
321
  metadata.update(settings=settings_as_xml)
316
322
  group = self.add_group(data_dim.name, 'data_dim', where, title, metadata)
317
323
  return group
318
324
 
319
- def add_incremental_group(self, group_type, where, title='', settings_as_xml='', metadata=dict([])):
325
+ def add_incremental_group(self, group_type: Union[str, GroupType, enum.Enum], where, title='', settings_as_xml='', metadata=None):
320
326
  """
321
327
  Add a node in the h5 file tree of the group type with an increment in the given name
322
328
  Parameters
@@ -336,50 +342,58 @@ class H5SaverLowLevel(H5Backend):
336
342
  -------
337
343
  node: newly created group node
338
344
  """
339
- group_type = enum_checker(GroupType, group_type)
345
+ if metadata is None:
346
+ metadata = {}
347
+ if isinstance(group_type, enum.Enum):
348
+ group_type = group_type.name
340
349
 
341
350
  nodes = [name for name in self.get_children(self.get_node(where))]
342
351
  nodes_tmp = []
343
352
  for node in nodes:
344
- if utils.capitalize(group_type.name) in node:
353
+ if utils.capitalize(group_type.lower()) in node:
345
354
  nodes_tmp.append(node)
346
355
  nodes_tmp.sort()
347
356
  if len(nodes_tmp) == 0:
348
357
  ind_group = -1
349
358
  else:
350
359
  ind_group = int(nodes_tmp[-1][-3:])
351
- group = self.get_set_group(where, f'{utils.capitalize(group_type.name)}{ind_group + 1:03d}', title)
360
+ group = self.get_set_group(where, f'{utils.capitalize(group_type.lower())}{ind_group + 1:03d}', title)
352
361
  self.set_attr(group, 'settings', settings_as_xml)
353
- if group_type.name.lower() != 'ch':
354
- self.set_attr(group, 'type', group_type.name.lower())
362
+ if group_type.lower() != 'ch':
363
+ self.set_attr(group, 'type', group_type.lower())
355
364
  else:
356
365
  self.set_attr(group, 'type', '')
357
366
  for metadat in metadata:
358
367
  self.set_attr(group, metadat, metadata[metadat])
359
368
  return group
360
369
 
361
- def add_act_group(self, where, title='', settings_as_xml='', metadata=dict([])):
370
+ def add_act_group(self, where, title='', settings_as_xml='', metadata=None):
362
371
  """
363
372
  Add a new group of type detector
364
373
  See Also
365
374
  -------
366
375
  add_incremental_group
367
376
  """
377
+ if metadata is None:
378
+ metadata = {}
368
379
  group = self.add_incremental_group('actuator', where, title, settings_as_xml, metadata)
369
380
  return group
370
381
 
371
- def add_det_group(self, where, title='', settings_as_xml='', metadata=dict([])):
382
+ def add_det_group(self, where, title='', settings_as_xml='', metadata=None):
372
383
  """
373
384
  Add a new group of type detector
374
385
  See Also
375
386
  -------
376
387
  add_incremental_group
377
388
  """
389
+ if metadata is None:
390
+ metadata = {}
378
391
  group = self.add_incremental_group('detector', where, title, settings_as_xml, metadata)
379
392
  return group
380
393
 
381
- def add_scan_group(self, where='/RawData', title='', settings_as_xml='', metadata=dict([])):
382
- """Add a new group of type scan
394
+ def add_generic_group(self, where='/RawData', title='', settings_as_xml='', metadata=None,
395
+ group_type=GroupType.scan):
396
+ """Add a new group of type given by the input argument group_type
383
397
 
384
398
  At creation adds the attributes description and scan_done to be used elsewhere
385
399
 
@@ -387,28 +401,45 @@ class H5SaverLowLevel(H5Backend):
387
401
  -------
388
402
  add_incremental_group
389
403
  """
404
+ if metadata is None:
405
+ metadata = {}
406
+ metadata.update(dict(description='', scan_done=False))
407
+ group = self.add_incremental_group(group_type, where, title, settings_as_xml, metadata)
408
+ return group
409
+
410
+ def add_scan_group(self, where='/RawData', title='', settings_as_xml='', metadata=None,):
411
+ """Add a new group of type scan
412
+
413
+ deprecated, use add_generic_group with a group type as GroupType.scan
414
+ """
415
+ if metadata is None:
416
+ metadata = {}
390
417
  metadata.update(dict(description='', scan_done=False))
391
- group = self.add_incremental_group(GroupType['scan'], where, title, settings_as_xml, metadata)
418
+ group = self.add_generic_group(where, title, settings_as_xml, metadata, group_type=GroupType.scan)
392
419
  return group
393
420
 
394
- def add_ch_group(self, where, title='', settings_as_xml='', metadata=dict([])):
421
+ def add_ch_group(self, where, title='', settings_as_xml='', metadata=None):
395
422
  """
396
423
  Add a new group of type channel
397
424
  See Also
398
425
  -------
399
426
  add_incremental_group
400
427
  """
428
+ if metadata is None:
429
+ metadata = {}
401
430
  group = self.add_incremental_group('ch', where, title, settings_as_xml, metadata)
402
431
  return group
403
432
 
404
433
 
405
- def add_move_group(self, where, title='', settings_as_xml='', metadata=dict([])):
434
+ def add_move_group(self, where, title='', settings_as_xml='', metadata=None):
406
435
  """
407
436
  Add a new group of type actuator
408
437
  See Also
409
438
  -------
410
439
  add_incremental_group
411
440
  """
441
+ if metadata is None:
442
+ metadata = {}
412
443
  group = self.add_incremental_group('actuator', where, title, settings_as_xml, metadata)
413
444
  return group
414
445
 
File without changes
File without changes
File without changes