pymodaq_data 5.0.2__tar.gz → 5.0.4__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.2 → pymodaq_data-5.0.4}/.gitignore +2 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/PKG-INFO +1 -1
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/_version.py +2 -2
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/data.py +64 -6
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/data_saving.py +1 -1
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/saving.py +4 -1
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/plotting/plotter/plotter.py +1 -1
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/LICENSE +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/README.rst +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/pyproject.toml +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/__init__.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/__init__.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/backends.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/browsing.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/exporter.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/exporters/__init__.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/exporters/base.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/exporters/flimj.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/exporters/hyperspy.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/h5modules/utils.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/icon.ico +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/numpy_func.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/plotting/__init__.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/plotting/plotter/plotters/__init__.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/plotting/plotter/plotters/matplotlib_plotters.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/post_treatment/__init__.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/post_treatment/process_to_scalar.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/slicing.py +0 -0
- {pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/splash.png +0 -0
|
@@ -585,7 +585,7 @@ class DataBase(DataLowLevel, NDArrayOperatorsMixin):
|
|
|
585
585
|
>>> import numpy as np
|
|
586
586
|
>>> from pymodaq.utils.data import DataBase, DataSource, DataDim, DataDistribution
|
|
587
587
|
>>> data = DataBase('mydata', source=DataSource['raw'], dim=DataDim['Data1D'], \
|
|
588
|
-
distribution=DataDistribution
|
|
588
|
+
distribution=DataDistribution.uniform, data=[np.array([1.,2.,3.]), np.array([4.,5.,6.])],\
|
|
589
589
|
labels=['channel1', 'channel2'], origin='docutils code')
|
|
590
590
|
>>> data.dim
|
|
591
591
|
<DataDim.Data1D: 1>
|
|
@@ -603,7 +603,7 @@ class DataBase(DataLowLevel, NDArrayOperatorsMixin):
|
|
|
603
603
|
|
|
604
604
|
def __init__(self, name: str,
|
|
605
605
|
source: DataSource = None, dim: DataDim = None,
|
|
606
|
-
distribution: DataDistribution = DataDistribution
|
|
606
|
+
distribution: DataDistribution = DataDistribution.uniform,
|
|
607
607
|
data: List[np.ndarray] = None,
|
|
608
608
|
labels: List[str] = None, origin: str = '',
|
|
609
609
|
units: str = '',
|
|
@@ -678,6 +678,49 @@ class DataBase(DataLowLevel, NDArrayOperatorsMixin):
|
|
|
678
678
|
""" Change immediately the units to whatever else. Use this with care!"""
|
|
679
679
|
self._units = units
|
|
680
680
|
|
|
681
|
+
def value(self, units: str = None) -> float:
|
|
682
|
+
"""Returns the underlying float value (of the first elt in the data list) if this data
|
|
683
|
+
holds only a float otherwise returns a mean of the underlying data
|
|
684
|
+
|
|
685
|
+
Parameters
|
|
686
|
+
----------
|
|
687
|
+
|
|
688
|
+
units: str
|
|
689
|
+
if unit is compatible with self.units, convert the data to these new units before
|
|
690
|
+
getting the value
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
"""
|
|
694
|
+
if self.length == 1 and self.size == 1:
|
|
695
|
+
if units is not None:
|
|
696
|
+
data = Q_(float(self.data[0][0]), self.units)
|
|
697
|
+
return data.m_as(units)
|
|
698
|
+
else:
|
|
699
|
+
return float(self.data[0][0])
|
|
700
|
+
else:
|
|
701
|
+
if units is not None:
|
|
702
|
+
data = Q_(float(np.mean(self.data[0])), self.units)
|
|
703
|
+
return data.m_as(units)
|
|
704
|
+
else:
|
|
705
|
+
return float(np.mean(self.data[0]))
|
|
706
|
+
|
|
707
|
+
def values(self, units: str = None) -> List[float]:
|
|
708
|
+
"""Returns the underlying float value (for each data array in the data list) if this data
|
|
709
|
+
holds only a float otherwise returns a mean of the underlying data"""
|
|
710
|
+
if self.length == 1 and self.size == 1:
|
|
711
|
+
if units is not None:
|
|
712
|
+
return [float(Q_(data_array[0], self.units).m_as(units))
|
|
713
|
+
for data_array in self.data]
|
|
714
|
+
else:
|
|
715
|
+
return [float(data_array[0])
|
|
716
|
+
for data_array in self.data]
|
|
717
|
+
else:
|
|
718
|
+
if units is not None:
|
|
719
|
+
return [float(Q_(np.mean(data_array), self.units).m_as(units))
|
|
720
|
+
for data_array in self.data]
|
|
721
|
+
else:
|
|
722
|
+
return [float(np.mean(data_array)) for data_array in self.data]
|
|
723
|
+
|
|
681
724
|
def as_dte(self, name: str = 'mydte') -> DataToExport:
|
|
682
725
|
"""Convenience method to wrap the DataWithAxes object into a DataToExport"""
|
|
683
726
|
return DataToExport(name, data=[self])
|
|
@@ -1668,6 +1711,19 @@ class DataWithAxes(DataBase):
|
|
|
1668
1711
|
#then use get_dim_from axes
|
|
1669
1712
|
self._check_errors(errors)
|
|
1670
1713
|
|
|
1714
|
+
def check_axes_linear(self, axes: List[Axis] = None) -> bool:
|
|
1715
|
+
""" Check if any axis may be non linear
|
|
1716
|
+
|
|
1717
|
+
Should trigger a spread like distribution except id dim is Data1D, in which cas, it doesn't
|
|
1718
|
+
matter
|
|
1719
|
+
"""
|
|
1720
|
+
if axes is None:
|
|
1721
|
+
axes = self._axes
|
|
1722
|
+
are_axes_linear = True
|
|
1723
|
+
for axis in axes:
|
|
1724
|
+
are_axes_linear = are_axes_linear and axis.is_axis_linear()
|
|
1725
|
+
return are_axes_linear
|
|
1726
|
+
|
|
1671
1727
|
def _check_errors(self, errors: Iterable[np.ndarray]):
|
|
1672
1728
|
""" Make sure the errors object is adapted to the len/shape of the dwa object
|
|
1673
1729
|
|
|
@@ -1734,12 +1790,12 @@ class DataWithAxes(DataBase):
|
|
|
1734
1790
|
return plotter_factory.get(plotter_backend).plot(self, *args, viewer=viewer, **kwargs)
|
|
1735
1791
|
|
|
1736
1792
|
def set_axes_manager(self, data_shape, axes, nav_indexes, **kwargs):
|
|
1737
|
-
if self.distribution.name ==
|
|
1738
|
-
self._distribution = DataDistribution
|
|
1793
|
+
if self.distribution.name == DataDistribution.uniform.name or len(nav_indexes) == 0:
|
|
1794
|
+
self._distribution = DataDistribution.uniform
|
|
1739
1795
|
self.axes_manager = AxesManagerUniform(data_shape=data_shape, axes=axes,
|
|
1740
1796
|
nav_indexes=nav_indexes,
|
|
1741
1797
|
**kwargs)
|
|
1742
|
-
elif self.distribution.name ==
|
|
1798
|
+
elif self.distribution.name == DataDistribution.spread.name:
|
|
1743
1799
|
self.axes_manager = AxesManagerSpread(data_shape=data_shape, axes=axes,
|
|
1744
1800
|
nav_indexes=nav_indexes,
|
|
1745
1801
|
**kwargs)
|
|
@@ -2050,6 +2106,7 @@ class DataWithAxes(DataBase):
|
|
|
2050
2106
|
self._dim = DataDim['DataND']
|
|
2051
2107
|
return self._dim
|
|
2052
2108
|
|
|
2109
|
+
|
|
2053
2110
|
@property
|
|
2054
2111
|
def n_axes(self):
|
|
2055
2112
|
"""Get the number of axes (even if not specified)"""
|
|
@@ -2064,6 +2121,7 @@ class DataWithAxes(DataBase):
|
|
|
2064
2121
|
def axes(self, axes: List[Axis]):
|
|
2065
2122
|
"""convenience property to set attribute from axis_manager"""
|
|
2066
2123
|
self.set_axes_manager(self.shape, axes=axes, nav_indexes=self.nav_indexes)
|
|
2124
|
+
self._axes = axes
|
|
2067
2125
|
|
|
2068
2126
|
def axes_limits(self, axes_indexes: List[int] = None) -> List[Tuple[float, float]]:
|
|
2069
2127
|
"""Get the limits of specified axes (all if axes_indexes is None)"""
|
|
@@ -2243,7 +2301,7 @@ class DataWithAxes(DataBase):
|
|
|
2243
2301
|
if len(nav_indexes) != 0:
|
|
2244
2302
|
distribution = self.distribution
|
|
2245
2303
|
else:
|
|
2246
|
-
distribution = DataDistribution
|
|
2304
|
+
distribution = DataDistribution.uniform
|
|
2247
2305
|
|
|
2248
2306
|
data = DataWithAxes(self.name, data=new_arrays_data, nav_indexes=tuple(nav_indexes),
|
|
2249
2307
|
axes=axes,
|
|
@@ -1001,7 +1001,7 @@ class DataLoader:
|
|
|
1001
1001
|
|
|
1002
1002
|
if isinstance(h5saver, Path) or isinstance(h5saver, str):
|
|
1003
1003
|
h5saver_tmp = H5SaverLowLevel()
|
|
1004
|
-
h5saver_tmp.init_file(
|
|
1004
|
+
h5saver_tmp.init_file(file_name=Path(h5saver))
|
|
1005
1005
|
h5saver = h5saver_tmp
|
|
1006
1006
|
|
|
1007
1007
|
self.h5saver = h5saver
|
|
@@ -89,7 +89,8 @@ class H5SaverLowLevel(H5Backend):
|
|
|
89
89
|
def h5_file(self):
|
|
90
90
|
return self._h5file
|
|
91
91
|
|
|
92
|
-
def init_file(self, file_name: Path, raw_group_name='RawData', new_file=False,
|
|
92
|
+
def init_file(self, file_name: Path, raw_group_name='RawData', new_file=False,
|
|
93
|
+
metadata: dict = None):
|
|
93
94
|
"""Initializes a new h5 file.
|
|
94
95
|
|
|
95
96
|
Parameters
|
|
@@ -100,6 +101,8 @@ class H5SaverLowLevel(H5Backend):
|
|
|
100
101
|
Base node name
|
|
101
102
|
new_file: bool
|
|
102
103
|
If True create a new file, otherwise append to a potential existing one
|
|
104
|
+
metadata: dict
|
|
105
|
+
A dictionary to be saved as attributes
|
|
103
106
|
|
|
104
107
|
Returns
|
|
105
108
|
-------
|
|
@@ -18,7 +18,7 @@ from pymodaq_utils.factory import ObjectFactory
|
|
|
18
18
|
logger = set_logger(get_module_name(__file__))
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def register_plotter(parent_module_name: str = '
|
|
21
|
+
def register_plotter(parent_module_name: str = 'pymodaq_data.plotting.plotter'):
|
|
22
22
|
plotters = []
|
|
23
23
|
try:
|
|
24
24
|
plotter_module = import_module(f'{parent_module_name}.plotters')
|
|
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.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/plotting/plotter/plotters/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pymodaq_data-5.0.2 → pymodaq_data-5.0.4}/src/pymodaq_data/post_treatment/process_to_scalar.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|