pymodaq_data 5.2.2__tar.gz → 5.2.7__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.
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/PKG-INFO +1 -1
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/data.py +78 -2
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/.gitignore +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/LICENSE +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/README.rst +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/pyproject.toml +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/__init__.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/config.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/__init__.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/backends.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/browsing.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/data_saving.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/exporter.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/exporters/__init__.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/exporters/base.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/exporters/flimj.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/exporters/hyperspy.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/saving.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/swmr.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/h5modules/utils.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/icon.ico +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/numpy_func.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/plotting/__init__.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/plotting/plotter/plotter.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/plotting/plotter/plotters/__init__.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/plotting/plotter/plotters/matplotlib_plotters.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/plotting/utils.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/post_treatment/__init__.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/post_treatment/process_to_scalar.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/resources/__init__.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/resources/config_template.toml +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/slicing.py +0 -0
- {pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/splash.png +0 -0
|
@@ -9,6 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
from abc import ABCMeta, abstractmethod
|
|
10
10
|
from copy import deepcopy
|
|
11
11
|
import numbers
|
|
12
|
+
import re
|
|
12
13
|
|
|
13
14
|
import numpy as np
|
|
14
15
|
from numpy.lib.mixins import NDArrayOperatorsMixin
|
|
@@ -27,7 +28,7 @@ from pint.compat import upcast_type_map
|
|
|
27
28
|
from multipledispatch import dispatch
|
|
28
29
|
|
|
29
30
|
|
|
30
|
-
from pymodaq_utils.enums import BaseEnum, enum_checker
|
|
31
|
+
from pymodaq_utils.enums import BaseEnum, enum_checker, StrEnum
|
|
31
32
|
from pymodaq_utils.warnings import deprecation_msg
|
|
32
33
|
from pymodaq_utils.utils import find_objects_in_list_from_attr_name_val
|
|
33
34
|
from pymodaq_utils.logger import set_logger, get_module_name
|
|
@@ -46,6 +47,32 @@ plotter_factory = PlotterFactory()
|
|
|
46
47
|
ser_factory = SerializableFactory()
|
|
47
48
|
logger = set_logger(get_module_name(__file__))
|
|
48
49
|
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def parse_quantity(quantity: str) -> Q_:
|
|
54
|
+
"""
|
|
55
|
+
Converts a string into a Pint Quantity object using
|
|
56
|
+
a regex to split it in two parts and force usage of
|
|
57
|
+
Q_(value, unit) constructor as Q_(value_unit_str)
|
|
58
|
+
induces some errors.
|
|
59
|
+
Parameters
|
|
60
|
+
----------
|
|
61
|
+
quantity: The string to convert
|
|
62
|
+
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
The Quantity object
|
|
66
|
+
|
|
67
|
+
"""
|
|
68
|
+
match = re.match(r'^([+-]?\d*\.?\d*(?:[eE][+-]?\d+)?)\s*(.*)$', quantity.strip())
|
|
69
|
+
if match:
|
|
70
|
+
value, unit = float(match.group(1)), match.group(2).strip()
|
|
71
|
+
value = float(value)
|
|
72
|
+
unit = unit.strip() or 'dimensionless'
|
|
73
|
+
return Q_(value, unit)
|
|
74
|
+
return Q_(quantity)
|
|
75
|
+
|
|
49
76
|
def dimensionless_aware_reduce_units(q: Type[Q_]) -> Type[Q_]:
|
|
50
77
|
"""
|
|
51
78
|
Take a quantity q and converts it to its reduced units.
|
|
@@ -122,6 +149,13 @@ class DataUnitError(Exception):
|
|
|
122
149
|
pass
|
|
123
150
|
|
|
124
151
|
|
|
152
|
+
class Averaging(StrEnum):
|
|
153
|
+
""" Keywords to describe averaging in Data objects"""
|
|
154
|
+
AVERAGED = 'averaged'
|
|
155
|
+
N_AVERAGED = 'n_averaged'
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
125
159
|
class DwaType(BaseEnum):
|
|
126
160
|
"""Different types of `DataWithAxes`."""
|
|
127
161
|
DataWithAxes = 0
|
|
@@ -792,6 +826,8 @@ class DataBase(DataLowLevel, NDArrayOperatorsMixin):
|
|
|
792
826
|
self._units = check_units(units)
|
|
793
827
|
self._errors = None
|
|
794
828
|
self.origin = origin
|
|
829
|
+
self._averaged = False
|
|
830
|
+
self._n_averaged = 0
|
|
795
831
|
|
|
796
832
|
source = enum_checker(DataSource, source)
|
|
797
833
|
self._source = source
|
|
@@ -1077,6 +1113,42 @@ class DataBase(DataLowLevel, NDArrayOperatorsMixin):
|
|
|
1077
1113
|
def deepcopy(self):
|
|
1078
1114
|
return copy.deepcopy(self)
|
|
1079
1115
|
|
|
1116
|
+
@property
|
|
1117
|
+
def averaged(self) -> bool:
|
|
1118
|
+
""" Get/Set a boolean depending if self is the result of an average operation
|
|
1119
|
+
|
|
1120
|
+
See Also
|
|
1121
|
+
--------
|
|
1122
|
+
n_averaged
|
|
1123
|
+
average
|
|
1124
|
+
"""
|
|
1125
|
+
return self._averaged
|
|
1126
|
+
|
|
1127
|
+
@averaged.setter
|
|
1128
|
+
def averaged(self, status: bool):
|
|
1129
|
+
self._averaged = status
|
|
1130
|
+
|
|
1131
|
+
@property
|
|
1132
|
+
def n_averaged(self) -> int:
|
|
1133
|
+
""" Get/set the number of averaging that resulted in this data
|
|
1134
|
+
|
|
1135
|
+
See Also
|
|
1136
|
+
--------
|
|
1137
|
+
averaged
|
|
1138
|
+
average
|
|
1139
|
+
"""
|
|
1140
|
+
return self._n_averaged
|
|
1141
|
+
|
|
1142
|
+
@n_averaged.setter
|
|
1143
|
+
def n_averaged(self, n_data: int):
|
|
1144
|
+
""" Return the number of averaging that resulted in this data
|
|
1145
|
+
|
|
1146
|
+
See Also
|
|
1147
|
+
--------
|
|
1148
|
+
averaged
|
|
1149
|
+
"""
|
|
1150
|
+
self._n_averaged = n_data
|
|
1151
|
+
|
|
1080
1152
|
def average(self, other: 'DataBase', weight: int) -> 'DataBase':
|
|
1081
1153
|
""" Compute the weighted average between self and other DataBase
|
|
1082
1154
|
|
|
@@ -1090,7 +1162,11 @@ class DataBase(DataLowLevel, NDArrayOperatorsMixin):
|
|
|
1090
1162
|
DataBase: the averaged DataBase object
|
|
1091
1163
|
"""
|
|
1092
1164
|
if isinstance(other, DataBase) and len(other) == len(self) and isinstance(weight, numbers.Number):
|
|
1093
|
-
|
|
1165
|
+
averaged_data = (other * weight + self) / (weight + 1)
|
|
1166
|
+
averaged_data.name = self.name
|
|
1167
|
+
averaged_data.add_extra_attribute(**{Averaging.AVERAGED: True,
|
|
1168
|
+
Averaging.N_AVERAGED: weight + 1})
|
|
1169
|
+
return averaged_data
|
|
1094
1170
|
else:
|
|
1095
1171
|
raise TypeError(f'Could not average a {other.__class__.__name__} or a {self.__class__.__name__} '
|
|
1096
1172
|
f'of a different length')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/plotting/plotter/plotters/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pymodaq_data-5.2.2 → pymodaq_data-5.2.7}/src/pymodaq_data/post_treatment/process_to_scalar.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|