pymodaq_data 5.0.26__tar.gz → 5.0.27__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.0.26 → pymodaq_data-5.0.27}/PKG-INFO +1 -1
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/_version.py +2 -2
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/data.py +32 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/numpy_func.py +37 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/plotting/plotter/plotter.py +4 -3
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/.gitignore +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/LICENSE +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/README.rst +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/pyproject.toml +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/__init__.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/__init__.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/backends.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/browsing.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/data_saving.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/exporter.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/exporters/__init__.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/exporters/base.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/exporters/flimj.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/exporters/hyperspy.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/saving.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/utils.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/icon.ico +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/plotting/__init__.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/plotting/plotter/plotters/__init__.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/plotting/plotter/plotters/matplotlib_plotters.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/post_treatment/__init__.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/post_treatment/process_to_scalar.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/slicing.py +0 -0
- {pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/splash.png +0 -0
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '5.0.
|
|
32
|
-
__version_tuple__ = version_tuple = (5, 0,
|
|
31
|
+
__version__ = version = '5.0.27'
|
|
32
|
+
__version_tuple__ = version_tuple = (5, 0, 27)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -8,6 +8,8 @@ from __future__ import annotations
|
|
|
8
8
|
|
|
9
9
|
from abc import ABCMeta, abstractmethod, abstractproperty
|
|
10
10
|
import numbers
|
|
11
|
+
from copy import deepcopy
|
|
12
|
+
|
|
11
13
|
import numpy as np
|
|
12
14
|
from numpy.lib.mixins import NDArrayOperatorsMixin
|
|
13
15
|
from typing import List, Tuple, Union, Any, Callable
|
|
@@ -1081,6 +1083,7 @@ class DataBase(DataLowLevel, NDArrayOperatorsMixin):
|
|
|
1081
1083
|
new_data.data = [np.fliplr(dat) for dat in new_data]
|
|
1082
1084
|
return new_data
|
|
1083
1085
|
|
|
1086
|
+
|
|
1084
1087
|
def append(self, data: DataWithAxes):
|
|
1085
1088
|
"""Append data content if the underlying arrays have the same shape and compatible units"""
|
|
1086
1089
|
for dat in data:
|
|
@@ -2272,6 +2275,16 @@ class DataWithAxes(DataBase, SerializableBase):
|
|
|
2272
2275
|
labels=self.labels)
|
|
2273
2276
|
return new_data
|
|
2274
2277
|
|
|
2278
|
+
def pad(self, pad_width: Union[int, Tuple[int, int], Iterable[Tuple[int, int]]], **kwargs):
|
|
2279
|
+
""" Pad the data arrays using the numpy pad function
|
|
2280
|
+
|
|
2281
|
+
The accepted pad_witdh type is the same than the numpy pad function
|
|
2282
|
+
|
|
2283
|
+
|
|
2284
|
+
see numpy.pad method for the signature and possible named arguments
|
|
2285
|
+
"""
|
|
2286
|
+
return np.pad(self, pad_width, **kwargs)
|
|
2287
|
+
|
|
2275
2288
|
def ft(self, axis: int = 0, axis_label: str = None,
|
|
2276
2289
|
axis_units: str = None, labels: List[str] = None) -> DataWithAxes:
|
|
2277
2290
|
"""Process the Fourier Transform of the data on the specified axis and returns the new data
|
|
@@ -2557,6 +2570,25 @@ class DataWithAxes(DataBase, SerializableBase):
|
|
|
2557
2570
|
axes.append(ax)
|
|
2558
2571
|
self.axes = axes
|
|
2559
2572
|
|
|
2573
|
+
def rot90(self, k=1, axes=(0, 1)):
|
|
2574
|
+
""" Rotate an array by 90 degrees in the plane specified by axes.
|
|
2575
|
+
|
|
2576
|
+
Valid only for 2D data
|
|
2577
|
+
"""
|
|
2578
|
+
if self.dim == DataDim.Data2D:
|
|
2579
|
+
new_data: DataWithAxes = copy.copy(self)
|
|
2580
|
+
new_data.data = [np.rot90(dat, k, axes) for dat in new_data]
|
|
2581
|
+
new_axes = []
|
|
2582
|
+
axis = new_data.get_axis_from_index(0)[0]
|
|
2583
|
+
axis.index = 1
|
|
2584
|
+
new_axes.append(axis)
|
|
2585
|
+
axis = new_data.get_axis_from_index(1)[0]
|
|
2586
|
+
axis.index = 0
|
|
2587
|
+
new_data.axes = new_axes
|
|
2588
|
+
return new_data
|
|
2589
|
+
else:
|
|
2590
|
+
return self
|
|
2591
|
+
|
|
2560
2592
|
def _compute_slices(self, slices, is_navigation=True, is_index=True):
|
|
2561
2593
|
"""Compute the total slice to apply to the data
|
|
2562
2594
|
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
from typing import Union, List, TYPE_CHECKING, Iterable, Optional, Callable
|
|
2
2
|
import numbers
|
|
3
|
+
from copy import deepcopy
|
|
3
4
|
|
|
4
5
|
import numpy as np
|
|
5
6
|
from pint.facets.numpy.numpy_func import HANDLED_UFUNCS # imported by the data module
|
|
6
7
|
from pymodaq_data import Q_
|
|
7
8
|
from pymodaq_data import data as data_mod
|
|
8
9
|
|
|
10
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
11
|
+
|
|
9
12
|
if TYPE_CHECKING:
|
|
10
13
|
from pymodaq_data.data import DataBase, DataWithAxes
|
|
11
14
|
|
|
12
15
|
HANDLED_FUNCTIONS = {}
|
|
13
16
|
|
|
17
|
+
logger = set_logger(get_module_name(__file__))
|
|
18
|
+
|
|
14
19
|
|
|
15
20
|
def process_arguments_for_ufuncs(input: 'DataBase',
|
|
16
21
|
inputs: List[Union[numbers.Number, Q_, np.ndarray, 'DataBase']]):
|
|
@@ -161,6 +166,38 @@ def _roll(dwa: 'DataWithAxes', *args, **kwargs):
|
|
|
161
166
|
dwa_func.name += f"_{'roll'}"
|
|
162
167
|
return dwa_func
|
|
163
168
|
|
|
169
|
+
|
|
170
|
+
@implements('pad')
|
|
171
|
+
def _pad(dwa: 'DataWithAxes', pad_width, mode = 'constant', **kwargs):
|
|
172
|
+
dwa.create_missing_axes()
|
|
173
|
+
for axis in dwa.axes:
|
|
174
|
+
if not axis.is_axis_linear():
|
|
175
|
+
raise TypeError('Could not pad data with non linear axes')
|
|
176
|
+
if isinstance(pad_width, int):
|
|
177
|
+
pad_width = [(pad_width, pad_width) for _ in range(len(dwa.shape))]
|
|
178
|
+
elif len(pad_width) == 1:
|
|
179
|
+
if hasattr(pad_width[0], '__len__') and len(pad_width[0]) == 2:
|
|
180
|
+
pad_width = [pad_width[0] for _ in range(len(dwa.shape))]
|
|
181
|
+
else:
|
|
182
|
+
pad_width = pad_width[0]
|
|
183
|
+
pad_width = [(pad_width, pad_width) for _ in range(len(dwa.shape))]
|
|
184
|
+
elif len(pad_width) == 2 and not hasattr(pad_width[0], '__len__'):
|
|
185
|
+
pad_width = [pad_width for _ in range(len(dwa.shape))]
|
|
186
|
+
elif len(pad_width) == len(dwa.shape):
|
|
187
|
+
if not hasattr(pad_width[0], '__len__'):
|
|
188
|
+
raise TypeError('Could not pad data with the given argument')
|
|
189
|
+
else:
|
|
190
|
+
raise TypeError(f'Could not pad data with the given arguments: {pad_width}')
|
|
191
|
+
dwa_func = dwa.deepcopy_with_new_data(data=[np.pad(array, pad_width, mode, **kwargs) for array in dwa])
|
|
192
|
+
dwa_func.axes = []
|
|
193
|
+
for axis in deepcopy(dwa.axes):
|
|
194
|
+
axis.offset -= pad_width[axis.index][0] * axis.scaling
|
|
195
|
+
axis.size += pad_width[axis.index][0] + pad_width[axis.index][1]
|
|
196
|
+
dwa_func.axes.append(axis)
|
|
197
|
+
dwa_func.name += f"_{'pad'}"
|
|
198
|
+
return dwa_func
|
|
199
|
+
|
|
200
|
+
|
|
164
201
|
# ******** functions that return booleans ***********
|
|
165
202
|
@implements('all')
|
|
166
203
|
def _all(dwa: 'DataWithAxes', *args, axis: Optional[Union[int, Iterable[int]]] = None, **kwargs):
|
|
@@ -83,13 +83,14 @@ class PlotterFactory(ObjectFactory):
|
|
|
83
83
|
def create(cls, key, **kwargs) -> PlotterBase:
|
|
84
84
|
builder = cls._builders[cls.__name__].get(key)
|
|
85
85
|
if not builder:
|
|
86
|
-
raise ValueError(key)
|
|
86
|
+
raise ValueError(f'{key} is not a valid plotter: {cls.backends()}')
|
|
87
87
|
return builder(**kwargs)
|
|
88
88
|
|
|
89
89
|
def get(self, backend: str, **kwargs):
|
|
90
90
|
return self.create(backend, **kwargs)
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
@classmethod
|
|
93
|
+
def backends(cls) -> List[str]:
|
|
93
94
|
"""Returns the list of plotter backends, main identifier of a given plotter"""
|
|
94
|
-
return sorted(list(
|
|
95
|
+
return sorted(list(cls._builders[cls.__name__].keys()))
|
|
95
96
|
|
|
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.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/exporters/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/h5modules/exporters/hyperspy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/plotting/plotter/plotters/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pymodaq_data-5.0.26 → pymodaq_data-5.0.27}/src/pymodaq_data/post_treatment/process_to_scalar.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|