pymodaq_data 5.1.7__tar.gz → 5.2.0a1__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 (32) hide show
  1. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/PKG-INFO +24 -25
  2. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/README.rst +22 -22
  3. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/pyproject.toml +1 -2
  4. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/__init__.py +4 -2
  5. pymodaq_data-5.2.0a1/src/pymodaq_data/config.py +11 -0
  6. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/data.py +35 -8
  7. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/backends.py +4 -2
  8. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/browsing.py +1 -1
  9. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/data_saving.py +43 -17
  10. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/saving.py +13 -6
  11. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/plotting/plotter/plotters/matplotlib_plotters.py +1 -1
  12. pymodaq_data-5.2.0a1/src/pymodaq_data/plotting/utils.py +52 -0
  13. pymodaq_data-5.2.0a1/src/pymodaq_data/resources/__init__.py +0 -0
  14. pymodaq_data-5.2.0a1/src/pymodaq_data/resources/config_template.toml +26 -0
  15. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/.gitignore +0 -0
  16. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/LICENSE +0 -0
  17. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/__init__.py +0 -0
  18. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/exporter.py +0 -0
  19. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/exporters/__init__.py +0 -0
  20. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/exporters/base.py +0 -0
  21. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/exporters/flimj.py +0 -0
  22. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/exporters/hyperspy.py +0 -0
  23. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/h5modules/utils.py +0 -0
  24. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/icon.ico +0 -0
  25. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/numpy_func.py +0 -0
  26. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/plotting/__init__.py +0 -0
  27. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/plotting/plotter/plotter.py +0 -0
  28. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/plotting/plotter/plotters/__init__.py +0 -0
  29. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/post_treatment/__init__.py +0 -0
  30. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/post_treatment/process_to_scalar.py +0 -0
  31. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/src/pymodaq_data/slicing.py +0 -0
  32. {pymodaq_data-5.1.7 → pymodaq_data-5.2.0a1}/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.1.7
3
+ Version: 5.2.0a1
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
@@ -45,8 +45,7 @@ Classifier: Topic :: Software Development :: User Interfaces
45
45
  Requires-Python: >=3.8
46
46
  Requires-Dist: pymodaq-utils>=0.0.8
47
47
  Requires-Dist: scipy
48
- Requires-Dist: tables<3.9; python_version < '3.10'
49
- Requires-Dist: tables>=3.10; python_version >= '3.10'
48
+ Requires-Dist: tables>=3.10
50
49
  Provides-Extra: dev
51
50
  Requires-Dist: flake8; extra == 'dev'
52
51
  Requires-Dist: h5py; extra == 'dev'
@@ -69,52 +68,52 @@ PyMoDAQ Data
69
68
  :target: https://pypi.org/project/pymodaq_data/
70
69
  :alt: Latest Version
71
70
 
72
- .. image:: https://readthedocs.org/projects/pymodaq/badge/?version=latest
73
- :target: https://pymodaq.readthedocs.io/en/stable/?badge=latest
71
+ .. image:: https://readthedocs.org/projects/pymodaq/badge/?version=malik-irain-patch-2
72
+ :target: https://pymodaq.readthedocs.io/en/stable/?badge=malik-irain-patch-2
74
73
  :alt: Documentation Status
75
74
 
76
- .. image:: https://codecov.io/gh/PyMoDAQ/pymodaq_data/branch/5.0.x_dev/graph/badge.svg?token=H32JflMEYR
77
- :target: https://codecov.io/gh/PyMoDAQ/pymodaq_data
75
+ .. image:: https://codecov.io/gh/PyMoDAQ/PyMoDAQ/branch/malik-irain-patch-2/graph/badge.svg?token=IQNJRCQDM2
76
+ :target: https://codecov.io/gh/PyMoDAQ/PyMoDAQ
78
77
 
79
78
  +-------------+-------------+---------------+
80
79
  | | Linux | Windows |
81
80
  +=============+=============+===============+
82
- | Python 3.9 | |39-linux| | |39-windows| |
83
- +-------------+-------------+---------------+
84
81
  | Python 3.10 | |310-linux| | |310-windows| |
85
82
  +-------------+-------------+---------------+
86
83
  | Python 3.11 | |311-linux| | |311-windows| |
87
84
  +-------------+-------------+---------------+
88
85
  | Python 3.12 | |312-linux| | |312-windows| |
89
86
  +-------------+-------------+---------------+
87
+ | Python 3.13 | |313-linux| | |313-windows| |
88
+ +-------------+-------------+---------------+
90
89
 
91
90
 
92
91
 
93
92
 
94
- .. |39-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Linux_3.9.svg
95
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
96
93
 
97
- .. |310-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Linux_3.10.svg
98
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
94
+ .. |310-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Linux_3.10.svg
95
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
99
96
 
100
- .. |311-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Linux_3.11.svg
101
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
97
+ .. |311-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Linux_3.11.svg
98
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
102
99
 
103
- .. |312-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Linux_3.12.svg
104
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
100
+ .. |312-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Linux_3.12.svg
101
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
105
102
 
106
- .. |39-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Windows_3.9.svg
107
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
103
+ .. |313-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Linux_3.13.svg
104
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
108
105
 
109
- .. |310-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Windows_3.10.svg
110
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
106
+ .. |310-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Windows_3.10.svg
107
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
111
108
 
112
- .. |311-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Windows_3.11.svg
113
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
109
+ .. |311-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Windows_3.11.svg
110
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
114
111
 
115
- .. |312-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Windows_3.12.svg
116
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
112
+ .. |312-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Windows_3.12.svg
113
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
117
114
 
115
+ .. |313-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Windows_3.13.svg
116
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
118
117
 
119
118
 
120
119
 
@@ -11,52 +11,52 @@ PyMoDAQ Data
11
11
  :target: https://pypi.org/project/pymodaq_data/
12
12
  :alt: Latest Version
13
13
 
14
- .. image:: https://readthedocs.org/projects/pymodaq/badge/?version=latest
15
- :target: https://pymodaq.readthedocs.io/en/stable/?badge=latest
14
+ .. image:: https://readthedocs.org/projects/pymodaq/badge/?version=malik-irain-patch-2
15
+ :target: https://pymodaq.readthedocs.io/en/stable/?badge=malik-irain-patch-2
16
16
  :alt: Documentation Status
17
17
 
18
- .. image:: https://codecov.io/gh/PyMoDAQ/pymodaq_data/branch/5.0.x_dev/graph/badge.svg?token=H32JflMEYR
19
- :target: https://codecov.io/gh/PyMoDAQ/pymodaq_data
18
+ .. image:: https://codecov.io/gh/PyMoDAQ/PyMoDAQ/branch/malik-irain-patch-2/graph/badge.svg?token=IQNJRCQDM2
19
+ :target: https://codecov.io/gh/PyMoDAQ/PyMoDAQ
20
20
 
21
21
  +-------------+-------------+---------------+
22
22
  | | Linux | Windows |
23
23
  +=============+=============+===============+
24
- | Python 3.9 | |39-linux| | |39-windows| |
25
- +-------------+-------------+---------------+
26
24
  | Python 3.10 | |310-linux| | |310-windows| |
27
25
  +-------------+-------------+---------------+
28
26
  | Python 3.11 | |311-linux| | |311-windows| |
29
27
  +-------------+-------------+---------------+
30
28
  | Python 3.12 | |312-linux| | |312-windows| |
31
29
  +-------------+-------------+---------------+
30
+ | Python 3.13 | |313-linux| | |313-windows| |
31
+ +-------------+-------------+---------------+
32
32
 
33
33
 
34
34
 
35
35
 
36
- .. |39-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Linux_3.9.svg
37
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
38
36
 
39
- .. |310-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Linux_3.10.svg
40
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
37
+ .. |310-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Linux_3.10.svg
38
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
41
39
 
42
- .. |311-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Linux_3.11.svg
43
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
40
+ .. |311-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Linux_3.11.svg
41
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
44
42
 
45
- .. |312-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Linux_3.12.svg
46
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
43
+ .. |312-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Linux_3.12.svg
44
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
47
45
 
48
- .. |39-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Windows_3.9.svg
49
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
46
+ .. |313-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Linux_3.13.svg
47
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
50
48
 
51
- .. |310-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Windows_3.10.svg
52
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
49
+ .. |310-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Windows_3.10.svg
50
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
53
51
 
54
- .. |311-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Windows_3.11.svg
55
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
52
+ .. |311-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Windows_3.11.svg
53
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
56
54
 
57
- .. |312-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/5.1.x/tests_Windows_3.12.svg
58
- :target: https://github.com/PyMoDAQ/pymodaq_data/actions/workflows/tests-data.yml
55
+ .. |312-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Windows_3.12.svg
56
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
59
57
 
58
+ .. |313-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/PyMoDAQ/badges/pymodaq_data/malik-irain-patch-2/tests_Windows_3.13.svg
59
+ :target: https://github.com/PyMoDAQ/PyMoDAQ/actions/workflows/tests-data.yml
60
60
 
61
61
 
62
62
 
@@ -33,8 +33,7 @@ classifiers = [
33
33
  dependencies = [
34
34
  "pymodaq_utils>=0.0.8",
35
35
  "scipy",
36
- "tables>=3.10; python_version>=\"3.10\"", # issue with some version of required package blosc2>=2.2.8
37
- "tables<3.9; python_version<\"3.10\"", # issue with some version of required package blosc2>=2.2.8
36
+ "tables>=3.10",
38
37
  ]
39
38
 
40
39
  [project.optional-dependencies]
@@ -15,11 +15,12 @@ try:
15
15
  except Exception:
16
16
  print("Couldn't create the local folder to store logs , presets...")
17
17
 
18
+ import pymodaq_data.config
18
19
  logger.info('************************')
19
20
  logger.info('Initializing the pint unit register')
20
21
  logger.info('************************')
21
22
  ureg = UnitRegistry()
22
- ureg.default_format = '~'
23
+ ureg.formatter.default_format = '~'
23
24
  Q_ = ureg.Quantity
24
25
  Unit = ureg.Unit
25
26
  logger.info('')
@@ -45,7 +46,8 @@ try:
45
46
 
46
47
 
47
48
  from pymodaq_data.data import (DataRaw, DataWithAxes, DataToExport, Axis,
48
- DataCalculated, DataDim, DataDistribution, DataSource, DataBase)
49
+ DataCalculated, DataDim, DataDistribution, DataSource, DataBase,
50
+ )
49
51
 
50
52
  except Exception as e:
51
53
  try:
@@ -0,0 +1,11 @@
1
+ from pathlib import Path
2
+
3
+ from pymodaq_utils.config import (GlobalConfig, BaseConfig)
4
+
5
+
6
+ @GlobalConfig.register()
7
+ class Config(BaseConfig):
8
+ """Main class to deal with configuration values for this plugin"""
9
+ config_template_path = Path(__file__).parent.joinpath('resources/config_template.toml')
10
+ config_name = f"data"
11
+
@@ -6,13 +6,13 @@ Created the 28/10/2022
6
6
  """
7
7
  from __future__ import annotations
8
8
 
9
- from abc import ABCMeta, abstractmethod, abstractproperty
9
+ from abc import ABCMeta, abstractmethod
10
10
  import numbers
11
11
  from copy import deepcopy
12
12
 
13
13
  import numpy as np
14
14
  from numpy.lib.mixins import NDArrayOperatorsMixin
15
- from typing import List, Tuple, Union, Any, Callable
15
+ from typing import List, Tuple, Union, Any, Callable, Type
16
16
  from typing import Iterable as IterableType
17
17
  from collections.abc import Iterable
18
18
  from collections import OrderedDict
@@ -26,25 +26,41 @@ from pint.compat import upcast_type_map
26
26
 
27
27
  from multipledispatch import dispatch
28
28
 
29
+
29
30
  from pymodaq_utils.enums import BaseEnum, enum_checker
30
31
  from pymodaq_utils.warnings import deprecation_msg
31
32
  from pymodaq_utils.utils import find_objects_in_list_from_attr_name_val
32
33
  from pymodaq_utils.logger import set_logger, get_module_name
33
34
 
34
35
  from pymodaq_utils import math_utils as mutils
35
- from pymodaq_utils.config import Config
36
+ from pymodaq_utils.config import GlobalConfig as Config
36
37
 
37
38
  from pymodaq_data.plotting.plotter.plotter import PlotterFactory
38
39
  from pymodaq_data.numpy_func import HANDLED_FUNCTIONS, HANDLED_UFUNCS, process_arguments_for_ufuncs
39
40
  from pymodaq_data import Q_, ureg, Unit
40
41
  from pymodaq_data.slicing import SpecialSlicersData
41
- from pymodaq_utils.serialize.factory import SerializableFactory, SerializableBase
42
+ from serializall import SerializableFactory, SerializableBase
42
43
 
43
44
  config = Config()
44
45
  plotter_factory = PlotterFactory()
45
46
  ser_factory = SerializableFactory()
46
47
  logger = set_logger(get_module_name(__file__))
47
48
 
49
+ def dimensionless_aware_reduce_units(q: Type[Q_]) -> Type[Q_]:
50
+ """
51
+ Take a quantity q and converts it to its reduced units.
52
+ For dimensionless units it compact them
53
+
54
+ Parameters
55
+ ----------
56
+ q: The quantity to be reduced
57
+
58
+ Returns
59
+ -------
60
+ The reduced quantity
61
+ """
62
+
63
+ return q.to_compact() if q.dimensionless else q.to_reduced_units()
48
64
 
49
65
  def check_units(units: str):
50
66
  try:
@@ -364,7 +380,7 @@ class Axis(SerializableBase):
364
380
  data=self.get_quantity().to(units))
365
381
 
366
382
  def to_reduced_units(self, inplace=False):
367
- quantity = self.get_quantity().to_reduced_units()
383
+ quantity = dimensionless_aware_reduce_units(self.get_quantity())
368
384
  if inplace:
369
385
  self.data = quantity.magnitude
370
386
  self.force_units(str(quantity.units))
@@ -898,6 +914,17 @@ class DataBase(DataLowLevel, NDArrayOperatorsMixin):
898
914
  """Convenience method to wrap the DataWithAxes object into a DataToExport"""
899
915
  return DataToExport(name, data=[self])
900
916
 
917
+ def split_as_dte(self, name: str = 'mydte') -> DataToExport:
918
+ """ Convenience method to split each ndarray into a DataWithAxes object """
919
+ return DataToExport(name, data=[type(self)(self.labels[ind],
920
+ source=self.source,
921
+ dim = self.dim,
922
+ data=[array],
923
+ labels = [self.labels[ind]],
924
+ axes = deepcopy(self.axes),
925
+ units = self.units,
926
+ ) for ind, array in enumerate(self)])
927
+
901
928
  def add_extra_attribute(self, **kwargs):
902
929
  for key in kwargs:
903
930
  if key not in self.extra_attributes:
@@ -961,7 +988,7 @@ class DataBase(DataLowLevel, NDArrayOperatorsMixin):
961
988
  units = dwa.units
962
989
  ufunc_results = [ufunc(*zipped, **kwargs) for zipped in list(zip(*elts))]
963
990
  if isinstance(ufunc_results[0], Q_):
964
- ufunc_results = [ufunc_result.to_reduced_units() for ufunc_result in ufunc_results]
991
+ ufunc_results = [dimensionless_aware_reduce_units(ufunc_result) for ufunc_result in ufunc_results]
965
992
  units = str(ufunc_results[0].units)
966
993
  ufunc_results = [ufunc_result.magnitude for ufunc_result in ufunc_results]
967
994
  dwa.data = ufunc_results
@@ -2089,7 +2116,7 @@ class DataWithAxes(DataBase, SerializableBase):
2089
2116
  else:
2090
2117
  raise ValueError(f'Cannot create a dwa from a None, should be a list of ndarray')
2091
2118
 
2092
- def plot(self, plotter_backend: str = config('plotting', 'backend'), *args, viewer=None,
2119
+ def plot(self, plotter_backend: str = config('data', 'plotting', 'backend')[0], *args, viewer=None,
2093
2120
  **kwargs):
2094
2121
  """ Call a plotter factory and its plot method over the actual data"""
2095
2122
  return plotter_factory.get(plotter_backend).plot(self, *args, viewer=viewer, **kwargs)
@@ -3024,7 +3051,7 @@ class DataToExport(DataLowLevel, SerializableBase):
3024
3051
 
3025
3052
  return dte, remaining_bytes
3026
3053
 
3027
- def plot(self, plotter_backend: str = config('plotting', 'backend'), *args, **kwargs):
3054
+ def plot(self, plotter_backend: str = config('data', 'plotting', 'backend')[0], *args, **kwargs):
3028
3055
  """ Call a plotter factory and its plot method over the actual data"""
3029
3056
  return plotter_factory.get(plotter_backend).plot(self, *args, **kwargs)
3030
3057
 
@@ -13,7 +13,7 @@ import pickle
13
13
  from typing import Dict
14
14
 
15
15
  from pymodaq_utils.logger import set_logger, get_module_name
16
- from pymodaq_utils.config import Config
16
+ from pymodaq_utils.config import GlobalConfig as Config
17
17
  from pymodaq_utils.utils import capitalize, JsonConverter
18
18
  from pymodaq_utils import utils
19
19
  from pymodaq_utils.enums import BaseEnum, enum_checker
@@ -1011,7 +1011,7 @@ class H5Backend:
1011
1011
  array.attrs['backend'] = self.backend
1012
1012
  return array
1013
1013
 
1014
- def add_group(self, group_name, group_type: Union[GroupType, str], where, title='', metadata=dict([])) -> GROUP:
1014
+ def add_group(self, group_name, group_type: Union[GroupType, str], where, title='', metadata=None) -> GROUP:
1015
1015
  """
1016
1016
  Add a node in the h5 file tree of the group type
1017
1017
  Parameters
@@ -1026,6 +1026,8 @@ class H5Backend:
1026
1026
  -------
1027
1027
  (node): newly created group node
1028
1028
  """
1029
+ if metadata is None:
1030
+ metadata = {}
1029
1031
  if isinstance(where, Node):
1030
1032
  where = where.node
1031
1033
 
@@ -16,7 +16,7 @@ from pathlib import Path
16
16
  from packaging import version as version_mod
17
17
 
18
18
  from pymodaq_utils.logger import set_logger, get_module_name
19
- from pymodaq_utils.config import Config
19
+ from pymodaq_utils.config import GlobalConfig as Config
20
20
  from .backends import H5Backend
21
21
  from .exporter import ExporterFactory
22
22
 
@@ -15,7 +15,7 @@ from pymodaq_utils.enums import enum_checker
15
15
  from pymodaq_data.data import (Axis, DataDim, DataWithAxes, DataToExport, DataDistribution,
16
16
  DataDimError, squeeze)
17
17
  from .saving import DataType, H5SaverLowLevel
18
- from .backends import GROUP, CARRAY, Node, EARRAY, NodeError
18
+ from .backends import GROUP, CARRAY, Node, EARRAY, NodeError, GroupType # noqa: F401
19
19
  from pymodaq_utils.utils import capitalize
20
20
  from pymodaq_data.h5modules.saving import SaveType
21
21
 
@@ -52,6 +52,14 @@ class DataManagement(metaclass=ABCMeta):
52
52
  """
53
53
  return f'{capitalize(cls.data_type.value)}{ind:02d}'
54
54
 
55
+ def __getattr__(self, item):
56
+ """ Allows to call attributes of the underlying H5Saver object"""
57
+
58
+ if hasattr(self._h5saver, item):
59
+ return getattr(self._h5saver, item)
60
+ else:
61
+ raise AttributeError(item)
62
+
55
63
  def __enter__(self):
56
64
  return self
57
65
 
@@ -283,18 +291,21 @@ class DataSaverLoader(DataManagement):
283
291
  """
284
292
  data_type = DataType['data']
285
293
 
286
- def __init__(self, h5saver: Union[H5SaverLowLevel, Path]):
294
+ def __init__(self, h5saver: Union[H5SaverLowLevel, Path],
295
+ new_file: bool = False, metadata: dict = None, save_type=SaveType.custom):
287
296
  self.data_type = enum_checker(DataType, self.data_type)
288
297
 
289
298
  if isinstance(h5saver, Path) or isinstance(h5saver, str):
290
- h5saver_tmp = H5SaverLowLevel()
291
- h5saver_tmp.init_file(file_name=Path(h5saver))
299
+ h5saver_tmp = H5SaverLowLevel(save_type)
300
+ h5saver_tmp.init_file(file_name=Path(h5saver),
301
+ new_file=new_file,
302
+ metadata=metadata)
292
303
  h5saver = h5saver_tmp
293
304
 
294
305
  self._h5saver = h5saver
295
- self._axis_saver = AxisSaverLoader(h5saver)
306
+ self._axis_saver = AxisSaverLoader(self._h5saver)
296
307
  if not isinstance(self, ErrorSaverLoader):
297
- self._error_saver = ErrorSaverLoader(h5saver)
308
+ self._error_saver = ErrorSaverLoader(self._h5saver)
298
309
 
299
310
  def isopen(self) -> bool:
300
311
  """ Get the opened status of the underlying hdf5 file"""
@@ -754,15 +765,27 @@ class DataToExportSaver:
754
765
  h5saver: H5SaverLowLevel
755
766
 
756
767
  """
757
- def __init__(self, h5saver: Union[H5SaverLowLevel, Path, str], save_type=SaveType.scan):
768
+ def __init__(self, h5saver: Union[H5SaverLowLevel, Path, str], save_type=SaveType.custom,
769
+ new_file: bool = False, metadata: dict = None):
770
+
758
771
  if isinstance(h5saver, Path) or isinstance(h5saver, str):
759
- h5saver_tmp = H5SaverLowLevel(save_type=save_type)
760
- h5saver_tmp.init_file(file_name=Path(h5saver))
772
+ h5saver_tmp = H5SaverLowLevel(save_type)
773
+ h5saver_tmp.init_file(file_name=Path(h5saver),
774
+ new_file=new_file,
775
+ metadata=metadata)
761
776
  h5saver = h5saver_tmp
762
777
 
763
778
  self._h5saver = h5saver
764
- self._data_saver = DataSaverLoader(h5saver)
765
- self._bkg_saver = BkgSaver(h5saver)
779
+ self._data_saver = DataSaverLoader(self._h5saver)
780
+ self._bkg_saver = BkgSaver(self._h5saver)
781
+
782
+ def __getattr__(self, item):
783
+ """ Allows to call attributes of the underlying H5Saver object"""
784
+
785
+ if hasattr(self._h5saver, item):
786
+ return getattr(self._h5saver, item)
787
+ else:
788
+ raise AttributeError(item)
766
789
 
767
790
  def _get_node(self, where: Union[Node, str]) -> Node:
768
791
  return self._h5saver.get_node(where)
@@ -805,6 +828,8 @@ class DataToExportSaver:
805
828
  """
806
829
 
807
830
  dims = data.get_dim_presents()
831
+ if settings_as_xml != '' and 'settings' not in kwargs:
832
+ kwargs['settings]'] = settings_as_xml
808
833
  for dim in dims:
809
834
  dim_group = self._h5saver.get_set_group(where, dim)
810
835
  for ind, dwa in enumerate(data.get_data_from_dim(dim)):
@@ -812,6 +837,7 @@ class DataToExportSaver:
812
837
  dwa_group = self._h5saver.get_set_group(dim_group, self.channel_formatter(ind),
813
838
  dwa.name, origin=dwa.origin)
814
839
  # dwa_group = self._h5saver.add_ch_group(dim_group, dwa.name)
840
+
815
841
  self._data_saver.add_data(dwa_group, dwa, **kwargs)
816
842
 
817
843
  def add_bkg(self, where: Union[Node, str], data: DataToExport):
@@ -856,7 +882,7 @@ class DataToExportEnlargeableSaver(DataToExportSaver):
856
882
  axis_units: str, deprecated use enl_axis_units
857
883
  the units of the enlarged axis array
858
884
  """
859
- def __init__(self, h5saver: H5SaverLowLevel,
885
+ def __init__(self, h5saver: Union[Path, H5SaverLowLevel],
860
886
  enl_axis_names: Iterable[str] = None,
861
887
  enl_axis_units: Iterable[str] = None,
862
888
  axis_name: str = 'nav axis', axis_units: str = ''):
@@ -874,8 +900,8 @@ class DataToExportEnlargeableSaver(DataToExportSaver):
874
900
  self._enl_axis_units = enl_axis_units
875
901
  self._n_enl = len(enl_axis_names)
876
902
 
877
- self._data_saver = DataEnlargeableSaver(h5saver)
878
- self._nav_axis_saver = AxisSaverLoader(h5saver)
903
+ self._data_saver = DataEnlargeableSaver(self._h5saver)
904
+ self._nav_axis_saver = AxisSaverLoader(self._h5saver)
879
905
 
880
906
  def add_data(self, where: Union[Node, str], data: DataToExport,
881
907
  axis_values: List[Union[float, np.ndarray]] = None,
@@ -954,8 +980,8 @@ class DataToExportExtendedSaver(DataToExportSaver):
954
980
 
955
981
  def __init__(self, h5saver: H5SaverLowLevel, extended_shape: Tuple[int]):
956
982
  super().__init__(h5saver)
957
- self._data_saver = DataExtendedSaver(h5saver, extended_shape)
958
- self._nav_axis_saver = AxisSaverLoader(h5saver)
983
+ self._data_saver = DataExtendedSaver(self._h5saver, extended_shape)
984
+ self._nav_axis_saver = AxisSaverLoader(self._h5saver)
959
985
 
960
986
  def add_nav_axes(self, where: Union[Node, str], axes: List[Axis]):
961
987
  """Used to add navigation axes related to the extended array
@@ -971,7 +997,7 @@ class DataToExportExtendedSaver(DataToExportSaver):
971
997
  self._nav_axis_saver.add_axis(nav_group, axis)
972
998
 
973
999
  def add_data(self, where: Union[Node, str], data: DataToExport, indexes: Iterable[int],
974
- distribution=DataDistribution['uniform'],
1000
+ distribution=DataDistribution.uniform,
975
1001
  settings_as_xml='', **kwargs):
976
1002
 
977
1003
  """
@@ -20,7 +20,7 @@ import numpy as np
20
20
  from pymodaq_utils.logger import set_logger, get_module_name
21
21
 
22
22
  from pymodaq_utils import utils
23
- from pymodaq_utils.config import Config
23
+ from pymodaq_utils.config import GlobalConfig as Config
24
24
  from pymodaq_data.data import DataDim, DataToExport, Axis, DataWithAxes
25
25
  from pymodaq_utils.enums import BaseEnum, enum_checker
26
26
  from pymodaq_utils.warnings import deprecation_msg
@@ -227,7 +227,7 @@ class H5SaverLowLevel(H5Backend):
227
227
  """
228
228
  if array_type is None:
229
229
  if array_to_save is None:
230
- array_type = config('data_saving', 'data_type', 'dynamics')[0]
230
+ array_type = config('data', 'data_saving', 'data_type', 'dynamic')[0]
231
231
  else:
232
232
  array_type = array_to_save.dtype
233
233
 
@@ -292,20 +292,24 @@ class H5SaverLowLevel(H5Backend):
292
292
  """Get a Node starting from a given node (Group) matching the given title"""
293
293
  return self.get_node_from_attribute_match(where, 'TITLE', title)
294
294
 
295
- def add_data_group(self, where, data_dim: DataDim, title='', settings_as_xml='', metadata=None):
295
+ def add_data_group(self, where, data_dim: DataDim, title='', settings_as_xml='', metadata=None,
296
+ group_name: str = None):
296
297
  """Creates a group node at given location in the tree
297
298
 
298
299
  Parameters
299
300
  ----------
300
301
  where: group node
301
302
  where to create data group
302
- group_data_type: DataDim
303
+ data_dim: DataDim
304
+ the dimensionality of the data group
303
305
  title: str, optional
304
306
  a title for this node, will be saved as metadata
305
307
  settings_as_xml: str, optional
306
308
  XML string created from a Parameter object to be saved as metadata
307
309
  metadata: dict, optional
308
310
  will be saved as a new metadata attribute with name: key and value: dict value
311
+ group_name: str, optional
312
+ the name of the group to create if None, the name of the DataDim enum is used (default)
309
313
 
310
314
  Returns
311
315
  -------
@@ -315,11 +319,14 @@ class H5SaverLowLevel(H5Backend):
315
319
  --------
316
320
  :py:meth:`add_group`
317
321
  """
322
+ data_dim = enum_checker(DataDim, data_dim)
323
+ if group_name is None:
324
+ group_name = data_dim.name
318
325
  if metadata is None:
319
326
  metadata = {}
320
- data_dim = enum_checker(DataDim, data_dim)
327
+
321
328
  metadata.update(settings=settings_as_xml)
322
- group = self.add_group(data_dim.name, 'data_dim', where, title, metadata)
329
+ group = self.add_group(group_name, GroupType.data, where, title, metadata)
323
330
  return group
324
331
 
325
332
  def add_incremental_group(self, group_type: Union[str, GroupType, enum.Enum], where, title='', settings_as_xml='', metadata=None):
@@ -16,7 +16,7 @@ if TYPE_CHECKING:
16
16
  pass
17
17
 
18
18
  logger = set_logger(get_module_name(__file__))
19
- config = configmod.Config()
19
+ config = configmod.GlobalConfig()
20
20
 
21
21
  PLOT_COLORS = utils.plot_colors.copy()
22
22
  PLOT_COLORS.remove((255, 255, 255)) # remove white color as plotted on white background
@@ -0,0 +1,52 @@
1
+ import copy
2
+ from typing import Iterable as IterableType, Iterable
3
+
4
+ from pymodaq_utils.utils import config
5
+
6
+
7
+ class PlotColors:
8
+
9
+ def __init__(self, colors=config('data', 'plotting', 'plot_colors')[:]):
10
+
11
+ self._internal_counter = -1
12
+
13
+ self.check_colors(colors)
14
+ self._plot_colors = [tuple(color) for color in colors]
15
+
16
+ def copy(self):
17
+ return copy.copy(self)
18
+
19
+ def remove(self, item):
20
+ self._plot_colors.remove(item)
21
+
22
+ def __getitem__(self, item: int):
23
+ if not isinstance(item, int):
24
+ raise TypeError('getter should be an integer')
25
+ return tuple(self._plot_colors[item % len(self._plot_colors)])
26
+
27
+ def __len__(self):
28
+ return len(self._plot_colors)
29
+
30
+ def __iter__(self):
31
+ self._internal_counter = -1
32
+ return self
33
+
34
+ def __next__(self):
35
+ if self._internal_counter >= len(self) - 1:
36
+ raise StopIteration
37
+ self._internal_counter += 1
38
+ return self[self._internal_counter]
39
+
40
+ def check_colors(self, colors: IterableType):
41
+ if not isinstance(colors, Iterable):
42
+ raise TypeError('Colors should be a list of 3-tuple 8 bits integer (0-255)')
43
+ for color in colors:
44
+ self.check_color(color)
45
+
46
+ @staticmethod
47
+ def check_color(color: IterableType):
48
+ if not isinstance(color, Iterable) and len(color) != 3:
49
+ raise TypeError('Colors should be a list of 3-tuple 8 bits integer (0-255)')
50
+ for col_val in color:
51
+ if not (isinstance(col_val, int) and 0 <= col_val <= 255):
52
+ raise TypeError('Colors should be a list of 3-tuple 8 bits integer (0-255)')
@@ -0,0 +1,26 @@
1
+ #this is the configuration file of the pymodaq_data package
2
+
3
+ [data_saving]
4
+ [data_saving.h5file]
5
+ save_path = "C:\\Data" #base path where data are automatically saved
6
+ compression_level = 5 # for hdf5 files between 0(min) and 9 (max)
7
+
8
+ [data_saving.hsds] #hsds connection option (https://www.hdfgroup.org/solutions/highly-scalable-data-service-hsds/)
9
+ #to save data in pymodaq using hpyd backend towards distant server or cloud (mimicking hdf5 files)
10
+ root_url = "http://hsds.sebastienweber.fr"
11
+ username = "pymodaq_user"
12
+ pwd = "pymodaq"
13
+
14
+ [data_saving.data_type]
15
+ # choose from below. This will force the datatype to be saved to
16
+ dynamic = [ 'float64', 'uint8', 'int8', 'uint16', 'int16', 'uint32', 'int32', 'uint64', 'int64',]
17
+
18
+
19
+ [general]
20
+ hdf5_backend = 'tables' # could be among ['tables', 'h5py', 'h5pyd'], mostly tested with tables
21
+
22
+ [plotting]
23
+ backend = ['matplotlib'] # either 'matplotlib' or 'qt' or any other custom backend
24
+ plot_colors = [[255, 255, 255], [255, 0, 0], [0, 255, 0], [0, 0, 255], [14, 207, 189], [207, 14, 166], [207, 204, 14]]
25
+ process_roi = true # if True subdata is extracted from the ROI in the data viewers
26
+
File without changes
File without changes