shepherd-data 2023.12.1__tar.gz → 2024.4.1__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. shepherd_data-2024.4.1/PKG-INFO +88 -0
  2. shepherd_data-2024.4.1/README.md +38 -0
  3. shepherd_data-2024.4.1/pyproject.toml +101 -0
  4. shepherd_data-2024.4.1/setup.cfg +4 -0
  5. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data/__init__.py +2 -1
  6. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data/cli.py +3 -3
  7. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data/ivonne.py +11 -8
  8. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data/mppt.py +22 -15
  9. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data/reader.py +31 -23
  10. shepherd_data-2024.4.1/shepherd_data.egg-info/PKG-INFO +88 -0
  11. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data.egg-info/SOURCES.txt +6 -17
  12. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data.egg-info/requires.txt +6 -4
  13. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data.egg-info/top_level.txt +0 -1
  14. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/tests/test_examples.py +3 -2
  15. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/tests/test_ivonne.py +1 -1
  16. shepherd_data-2023.12.1/PKG-INFO +0 -274
  17. shepherd_data-2023.12.1/README.md +0 -224
  18. shepherd_data-2023.12.1/pyproject.toml +0 -7
  19. shepherd_data-2023.12.1/setup.cfg +0 -82
  20. shepherd_data-2023.12.1/shepherd_data.egg-info/PKG-INFO +0 -274
  21. shepherd_data-2023.12.1/tests/__init__.py +0 -0
  22. shepherd_data-2023.12.1/tests/conftest.py +0 -33
  23. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data/debug_resampler.py +0 -0
  24. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data.egg-info/dependency_links.txt +0 -0
  25. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data.egg-info/entry_points.txt +0 -0
  26. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/shepherd_data.egg-info/zip-safe +0 -0
  27. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/tests/test_cli.py +0 -0
  28. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/tests/test_cli_downsample.py +0 -0
  29. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/tests/test_cli_extract.py +0 -0
  30. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/tests/test_cli_plot.py +0 -0
  31. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/tests/test_cli_validate.py +0 -0
  32. {shepherd_data-2023.12.1 → shepherd_data-2024.4.1}/tests/test_reader.py +0 -0
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.1
2
+ Name: shepherd_data
3
+ Version: 2024.4.1
4
+ Summary: Programming- and CLI-Interface for the h5-dataformat of the Shepherd-Testbed
5
+ Author-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
6
+ Maintainer-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
7
+ Project-URL: Documentation, https://github.com/orgua/shepherd-datalib/blob/main/README.md
8
+ Project-URL: Issues, https://pypi.org/project/shepherd-data/issues
9
+ Project-URL: Source, https://pypi.org/project/shepherd-data/
10
+ Keywords: testbed,beaglebone,pru,batteryless,energyharvesting,solar
11
+ Platform: unix
12
+ Platform: linux
13
+ Platform: osx
14
+ Platform: cygwin
15
+ Platform: win32
16
+ Platform: win64
17
+ Classifier: Development Status :: 5 - Production/Stable
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Intended Audience :: Information Technology
20
+ Classifier: Intended Audience :: Science/Research
21
+ Classifier: Programming Language :: Python :: 3.8
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: License :: OSI Approved :: MIT License
27
+ Classifier: Operating System :: OS Independent
28
+ Classifier: Natural Language :: English
29
+ Requires-Python: >=3.8
30
+ Description-Content-Type: text/markdown
31
+ Requires-Dist: click
32
+ Requires-Dist: h5py
33
+ Requires-Dist: matplotlib
34
+ Requires-Dist: numpy
35
+ Requires-Dist: pandas>=2.0.0
36
+ Requires-Dist: pyYAML
37
+ Requires-Dist: scipy
38
+ Requires-Dist: shepherd-core[inventory]>=2024.04.1
39
+ Requires-Dist: tqdm
40
+ Provides-Extra: elf
41
+ Requires-Dist: shepherd-core[elf]; extra == "elf"
42
+ Provides-Extra: dev
43
+ Requires-Dist: shepherd-core[dev]; extra == "dev"
44
+ Requires-Dist: pandas-stubs; extra == "dev"
45
+ Provides-Extra: test
46
+ Requires-Dist: shepherd-core[test]; extra == "test"
47
+ Requires-Dist: pytest; extra == "test"
48
+ Requires-Dist: pytest-click; extra == "test"
49
+ Requires-Dist: coverage; extra == "test"
50
+
51
+ # Shepherd-Data-Tool
52
+
53
+ [![PyPiVersion](https://img.shields.io/pypi/v/shepherd_data.svg)](https://pypi.org/project/shepherd_data)
54
+ [![image](https://img.shields.io/pypi/pyversions/shepherd_data.svg)](https://pypi.python.org/pypi/shepherd-data)
55
+ [![Pytest](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml/badge.svg)](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml)
56
+ [![CodeStyle](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
57
+
58
+ **Main Documentation**: <https://orgua.github.io/shepherd>
59
+
60
+ **Source Code**: <https://github.com/orgua/shepherd-datalib>
61
+
62
+ **Main Project**: <https://github.com/orgua/shepherd>
63
+
64
+ ---
65
+
66
+ `shepherd-data` eases the handling of hdf5-recordings used by the [shepherd](https://github.com/orgua/shepherd)-testbed. Users can read, validate and create files and also extract, down-sample and plot information.
67
+
68
+ ## Installation
69
+
70
+ ### PIP - Online
71
+
72
+ ```shell
73
+ pip3 install shepherd-data -U
74
+ ```
75
+
76
+ For bleeding-edge-features or dev-work it is possible to install directly from GitHub-Sources (here `dev`-branch):
77
+
78
+ ```Shell
79
+ pip install git+https://github.com/orgua/shepherd-datalib.git@dev#subdirectory=shepherd_data -U
80
+ ```
81
+
82
+ ## More
83
+
84
+ Please consult the [official documentation](https://orgua.github.io/shepherd) for more, it covers:
85
+
86
+ - general context
87
+ - command-line interface
88
+ - programming interface
@@ -0,0 +1,38 @@
1
+ # Shepherd-Data-Tool
2
+
3
+ [![PyPiVersion](https://img.shields.io/pypi/v/shepherd_data.svg)](https://pypi.org/project/shepherd_data)
4
+ [![image](https://img.shields.io/pypi/pyversions/shepherd_data.svg)](https://pypi.python.org/pypi/shepherd-data)
5
+ [![Pytest](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml/badge.svg)](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml)
6
+ [![CodeStyle](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
7
+
8
+ **Main Documentation**: <https://orgua.github.io/shepherd>
9
+
10
+ **Source Code**: <https://github.com/orgua/shepherd-datalib>
11
+
12
+ **Main Project**: <https://github.com/orgua/shepherd>
13
+
14
+ ---
15
+
16
+ `shepherd-data` eases the handling of hdf5-recordings used by the [shepherd](https://github.com/orgua/shepherd)-testbed. Users can read, validate and create files and also extract, down-sample and plot information.
17
+
18
+ ## Installation
19
+
20
+ ### PIP - Online
21
+
22
+ ```shell
23
+ pip3 install shepherd-data -U
24
+ ```
25
+
26
+ For bleeding-edge-features or dev-work it is possible to install directly from GitHub-Sources (here `dev`-branch):
27
+
28
+ ```Shell
29
+ pip install git+https://github.com/orgua/shepherd-datalib.git@dev#subdirectory=shepherd_data -U
30
+ ```
31
+
32
+ ## More
33
+
34
+ Please consult the [official documentation](https://orgua.github.io/shepherd) for more, it covers:
35
+
36
+ - general context
37
+ - command-line interface
38
+ - programming interface
@@ -0,0 +1,101 @@
1
+ [project]
2
+ name = "shepherd_data"
3
+ description = "Programming- and CLI-Interface for the h5-dataformat of the Shepherd-Testbed"
4
+ keywords = ["testbed", "beaglebone", "pru", "batteryless", "energyharvesting", "solar"]
5
+
6
+ authors = [
7
+ {name = "Ingmar Splitt", email = "ingmar.splitt@tu-dresden.de"},
8
+ ]
9
+ maintainers = [
10
+ {name = "Ingmar Splitt", email = "ingmar.splitt@tu-dresden.de"},
11
+ ]
12
+
13
+ readme = {file = "README.md", content-type = "text/markdown"}
14
+ license = {file = "LICENSE"}
15
+ dynamic = ["version"]
16
+
17
+ classifiers = [
18
+ "Development Status :: 5 - Production/Stable",
19
+ "Intended Audience :: Developers",
20
+ "Intended Audience :: Information Technology",
21
+ "Intended Audience :: Science/Research",
22
+ "Programming Language :: Python :: 3.8",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Operating System :: OS Independent",
29
+ "Natural Language :: English",
30
+ ]
31
+
32
+ requires-python = ">=3.8"
33
+ dependencies = [
34
+ "click",
35
+ "h5py",
36
+ "matplotlib", # full-version
37
+ "numpy",
38
+ "pandas>=2.0.0", # full-version, v2 is OK
39
+ "pyYAML",
40
+ "scipy", # full-version
41
+ "shepherd-core[inventory]>=2024.04.1",
42
+ "tqdm", # full-version
43
+ ]
44
+
45
+ [project.optional-dependencies]
46
+ elf = [
47
+ "shepherd-core[elf]"
48
+ ]
49
+
50
+ dev = [
51
+ "shepherd-core[dev]",
52
+ "pandas-stubs", # for pyright with pandas
53
+ ]
54
+
55
+ test = [
56
+ "shepherd-core[test]",
57
+ "pytest",
58
+ "pytest-click",
59
+ "coverage",
60
+ ]
61
+
62
+ [project.urls]
63
+ Documentation = "https://github.com/orgua/shepherd-datalib/blob/main/README.md"
64
+ Issues = "https://pypi.org/project/shepherd-data/issues"
65
+ Source = "https://pypi.org/project/shepherd-data/"
66
+
67
+ [project.scripts]
68
+ shepherd-data = "shepherd_data.cli:cli"
69
+
70
+ [build-system]
71
+ requires = ["setuptools"]
72
+ build-backend = "setuptools.build_meta"
73
+
74
+ [tool.setuptools]
75
+ platforms = ["unix", "linux", "osx", "cygwin", "win32", "win64"]
76
+ zip-safe = true
77
+ #include-package-data = true
78
+
79
+ [tool.setuptools.package-dir]
80
+ shepherd_data = "shepherd_data"
81
+
82
+ [tool.setuptools.package-data]
83
+ shepherd_data = [
84
+ "README.md",
85
+ "src/examples/*.py",
86
+ "src/examples/*.iv",
87
+ ]
88
+
89
+ [tool.setuptools.dynamic]
90
+ version = {attr = "shepherd_data.__version__"}
91
+
92
+ [tool.pytest.ini_options]
93
+ addopts = "-vvv --stepwise" # opts: verbose result for each tests
94
+ # TODO: add something like "--cov --cov-report html --cov-report term-missing --cov-fail-under 95"
95
+
96
+ [tool.coverage.run]
97
+ source = ["shepherd_data"]
98
+
99
+ [tool.mypy]
100
+ python_version = 3.8
101
+ ignore_missing_imports = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -4,11 +4,12 @@ Provides classes for storing and retrieving sampled IV data to/from
4
4
  HDF5 files.
5
5
 
6
6
  """
7
+
7
8
  from shepherd_core import Writer
8
9
 
9
10
  from .reader import Reader
10
11
 
11
- __version__ = "2023.12.1"
12
+ __version__ = "2024.04.1"
12
13
 
13
14
  __all__ = [
14
15
  "Reader",
@@ -1,5 +1,5 @@
1
- """Command definitions for CLI
2
- """
1
+ """Command definitions for CLI"""
2
+
3
3
  import logging
4
4
  import os
5
5
  import sys
@@ -365,7 +365,7 @@ def plot(
365
365
  else:
366
366
  shpr.plot_to_file(start, end, width, height)
367
367
  except TypeError as _xpc:
368
- logger.error("ERROR: will skip file, caught exception: %s", _xpc)
368
+ logger.exception("ERROR: will skip file, caught exception: %s", _xpc)
369
369
  if multiplot:
370
370
  logger.info("Got %d datasets to plot", len(data))
371
371
  mpl_path = Reader.multiplot_to_file(data, in_data, width, height)
@@ -2,6 +2,7 @@
2
2
  to generate valid shepherd-data for emulation
3
3
 
4
4
  """
5
+
5
6
  import errno
6
7
  import logging
7
8
  import math
@@ -34,7 +35,7 @@ def get_isc(coeffs: pd.DataFrame): # noqa: ANN201
34
35
 
35
36
 
36
37
  class Reader:
37
- """container for converters to shepherd-data"""
38
+ """Container for converters that bridge the gap to shepherds data-files."""
38
39
 
39
40
  _logger: logging.Logger = logging.getLogger("SHPData.IVonne.Reader")
40
41
 
@@ -102,8 +103,9 @@ class Reader:
102
103
  pts_per_curve: int = 1000,
103
104
  duration_s: Optional[float] = None,
104
105
  ) -> None:
105
- """Transforms previously recorded parameters to shepherd hdf database with IV curves.
106
- Shepherd should work with IV 'surfaces', where we have a stream of IV curves
106
+ """Transform recorded parameters to shepherd hdf database with IV curves.
107
+
108
+ Shepherd works with IV 'surfaces', which is a stream of IV curves.
107
109
 
108
110
  :param shp_output: Path where the resulting hdf file shall be stored
109
111
  :param v_max: Maximum voltage supported by shepherd
@@ -134,7 +136,7 @@ class Reader:
134
136
  for idx in job_iter:
135
137
  idx_top = min(idx + max_elements, df_elements_n)
136
138
  df_slice = self._df.iloc[idx : idx_top + 1].copy()
137
- df_slice["timestamp"] = pd.TimedeltaIndex(data=df_slice["time"], unit="s")
139
+ df_slice["timestamp"] = pd.to_timedelta(df_slice["time"], unit="s")
138
140
  df_slice = df_slice.set_index("timestamp")
139
141
  # warning: .interpolate does crash in debug-mode with typeError
140
142
  df_slice = (
@@ -163,7 +165,7 @@ class Reader:
163
165
  duration_s: Optional[float] = None,
164
166
  tracker: Optional[MPPTracker] = None,
165
167
  ) -> None:
166
- """Transforms shepherd IV curves to shepherd IV traces.
168
+ """Transform shepherd IV curves to shepherd IV samples / traces.
167
169
 
168
170
  For the 'buck' and 'buck-boost' modes, shepherd takes voltage and current traces.
169
171
  These can be recorded with shepherd or generated from existing IV curves by, for
@@ -180,6 +182,7 @@ class Reader:
180
182
  :param v_max: Maximum voltage supported by shepherd
181
183
  :param duration_s: time to stop in seconds, counted from beginning
182
184
  :param tracker: VOC or OPT
185
+
183
186
  """
184
187
  if self._df is None:
185
188
  raise RuntimeError("IVonne Context was not entered - file not open!")
@@ -213,7 +216,7 @@ class Reader:
213
216
  df_slice.loc[:, "voc"] = get_voc(df_slice)
214
217
  df_slice.loc[df_slice["voc"] >= v_max, "voc"] = v_max
215
218
  df_slice = tracker.process(df_slice)
216
- df_slice["timestamp"] = pd.TimedeltaIndex(data=df_slice["time"], unit="s")
219
+ df_slice["timestamp"] = pd.to_timedelta(df_slice["time"], unit="s")
217
220
  df_slice = df_slice[["time", "v", "i", "timestamp"]].set_index("timestamp")
218
221
  # warning: .interpolate does crash in debug-mode with typeError
219
222
  df_slice = (
@@ -231,7 +234,7 @@ class Reader:
231
234
  v_max: float = 5.0,
232
235
  duration_s: Optional[float] = None,
233
236
  ) -> None:
234
- """Transforms ivonne-parameters to upsampled version for shepherd
237
+ """Transform ivonne-parameters to up-sampled versions for shepherd.
235
238
 
236
239
  :param shp_output: Path where the resulting hdf file shall be stored
237
240
  :param v_max: Maximum voltage supported by shepherd
@@ -264,7 +267,7 @@ class Reader:
264
267
  df_slice.loc[:, "voc"] = get_voc(df_slice)
265
268
  df_slice.loc[df_slice["voc"] >= v_max, "voc"] = v_max
266
269
  df_slice.loc[:, "isc"] = get_isc(df_slice)
267
- df_slice["timestamp"] = pd.TimedeltaIndex(data=df_slice["time"], unit="s")
270
+ df_slice["timestamp"] = pd.to_timedelta(df_slice["time"], unit="s")
268
271
  df_slice = df_slice[["time", "voc", "isc", "timestamp"]].set_index("timestamp")
269
272
  # warning: .interpolate does crash in debug-mode with typeError
270
273
  df_slice = (
@@ -1,6 +1,8 @@
1
1
  """Harvesters, simple and fast approach.
2
- Might be exchanged by shepherds py-model of pru-harvesters
2
+
3
+ Might be exchanged by shepherds py-model of pru-harvesters.
3
4
  """
5
+
4
6
  import numpy as np
5
7
  import pandas as pd
6
8
 
@@ -8,16 +10,11 @@ from shepherd_core import Calc_t
8
10
 
9
11
 
10
12
  def iv_model(voltages: Calc_t, coeffs: pd.Series) -> Calc_t:
11
- """Simple diode based model of a solar panel IV curve.
12
-
13
- Args:
14
- ----
15
- :param voltages: Load voltage of the solar panel
16
- :param coeffs: three generic coefficients
13
+ """Calculate simple diode based model (equivalent circuit diagram) of a solar panel IV curve.
17
14
 
18
- Returns:
19
- -------
20
- Solar current at given load voltage
15
+ :param voltages: Load voltage of the solar panel
16
+ :param coeffs: three generic coefficients
17
+ :return: Solar current at given load voltage
21
18
  """
22
19
  currents = float(coeffs["a"]) - float(coeffs["b"]) * (
23
20
  np.exp(float(coeffs["c"]) * voltages) - 1.0
@@ -40,7 +37,7 @@ def find_oc(v_arr: np.ndarray, i_arr: np.ndarray, ratio: float = 0.05) -> np.nda
40
37
 
41
38
 
42
39
  class MPPTracker:
43
- """Prototype
40
+ """Prototype for a MPPT-class.
44
41
 
45
42
  :param v_max: Maximum voltage supported by shepherd
46
43
  :param pts_per_curve: resolution of internal ivcurve
@@ -52,15 +49,15 @@ class MPPTracker:
52
49
  self.v_proto: np.ndarray = np.linspace(0, v_max, pts_per_curve)
53
50
 
54
51
  def process(self, coeffs: pd.DataFrame) -> pd.DataFrame:
55
- """Apply harvesting model to input data
52
+ """Apply harvesting model to input data.
56
53
 
57
54
  :param coeffs: ivonne coefficients
58
- :return:
55
+ :return: ivsample-data
59
56
  """
60
57
 
61
58
 
62
59
  class OpenCircuitTracker(MPPTracker):
63
- """Open-circuit based MPPT
60
+ """Open-circuit (-voltage) based MPPT.
64
61
 
65
62
  :param v_max: Maximum voltage supported by shepherd
66
63
  :param pts_per_curve: resolution of internal ivcurve
@@ -72,6 +69,11 @@ class OpenCircuitTracker(MPPTracker):
72
69
  self.ratio = ratio
73
70
 
74
71
  def process(self, coeffs: pd.DataFrame) -> pd.DataFrame:
72
+ """Apply harvesting model to input data.
73
+
74
+ :param coeffs: ivonne coefficients
75
+ :return: ivsample-data
76
+ """
75
77
  coeffs["icurve"] = coeffs.apply(lambda x: iv_model(self.v_proto, x), axis=1)
76
78
  if "voc" not in coeffs.columns:
77
79
  coeffs["voc"] = coeffs.apply(lambda x: find_oc(self.v_proto, x["ivcurve"]), axis=1)
@@ -85,7 +87,7 @@ class OpenCircuitTracker(MPPTracker):
85
87
 
86
88
 
87
89
  class OptimalTracker(MPPTracker):
88
- """Optimal MPPT
90
+ """Optimal MPPT by looking at the whole curve.
89
91
 
90
92
  Calculates optimal harvesting voltage for every time and corresponding IV curve.
91
93
 
@@ -97,6 +99,11 @@ class OptimalTracker(MPPTracker):
97
99
  super().__init__(v_max, pts_per_curve)
98
100
 
99
101
  def process(self, coeffs: pd.DataFrame) -> pd.DataFrame:
102
+ """Apply harvesting model to input data.
103
+
104
+ :param coeffs: ivonne coefficients
105
+ :return: ivsample-data
106
+ """
100
107
  coeffs["icurve"] = coeffs.apply(lambda x: iv_model(self.v_proto, x), axis=1)
101
108
  coeffs["pcurve"] = coeffs.apply(lambda x: self.v_proto * x["icurve"], axis=1)
102
109
  coeffs["max_pos"] = coeffs.apply(lambda x: np.argmax(x["pcurve"]), axis=1)
@@ -1,5 +1,5 @@
1
- """Reader-Baseclass
2
- """
1
+ """Reader-Baseclass for opening shepherds hdf5-files."""
2
+
3
3
  import math
4
4
  from datetime import datetime
5
5
  from pathlib import Path
@@ -26,6 +26,7 @@ class Reader(CoreReader):
26
26
  ----
27
27
  file_path: Path of hdf5 file containing shepherd data with iv-samples, iv-curves or isc&voc
28
28
  verbose: more info during usage, 'None' skips the setter
29
+
29
30
  """
30
31
 
31
32
  def __init__(
@@ -37,7 +38,7 @@ class Reader(CoreReader):
37
38
  super().__init__(file_path, verbose=verbose)
38
39
 
39
40
  def save_csv(self, h5_group: h5py.Group, separator: str = ";") -> int:
40
- """Extract numerical data via csv
41
+ """Extract numerical data from group and store it into csv.
41
42
 
42
43
  :param h5_group: can be external and should probably be downsampled
43
44
  :param separator: used between columns
@@ -73,7 +74,7 @@ class Reader(CoreReader):
73
74
  return h5_group["time"][:].shape[0]
74
75
 
75
76
  def save_log(self, h5_group: h5py.Group, *, add_timestamp: bool = True) -> int:
76
- """Save dataset in group as log, optimal for logged dmesg and exceptions
77
+ """Save dataset from group as log, optimal for logged 'dmesg' and console-output.
77
78
 
78
79
  :param h5_group: can be external
79
80
  :param add_timestamp: can be external
@@ -114,6 +115,7 @@ class Reader(CoreReader):
114
115
  *,
115
116
  show: bool = True,
116
117
  ) -> int:
118
+ """Print warning messages from log in data-group."""
117
119
  _count = self.count_errors_in_log(group_name, min_level)
118
120
  if _count < 1:
119
121
  return 0
@@ -145,7 +147,7 @@ class Reader(CoreReader):
145
147
 
146
148
  def downsample(
147
149
  self,
148
- data_src: h5py.Dataset,
150
+ data_src: Union[h5py.Dataset, np.ndarray],
149
151
  data_dst: Union[None, h5py.Dataset, np.ndarray],
150
152
  start_n: int = 0,
151
153
  end_n: Optional[int] = None,
@@ -153,15 +155,17 @@ class Reader(CoreReader):
153
155
  *,
154
156
  is_time: bool = False,
155
157
  ) -> Union[h5py.Dataset, np.ndarray]:
156
- """Warning: only valid for IV-Stream, not IV-Curves
158
+ """Sample down iv-data.
159
+
160
+ Warning: only valid for IV-Stream, not IV-Curves
157
161
 
158
162
  :param data_src: a h5-dataset to digest, can be external
159
163
  :param data_dst: can be a dataset, numpy-array or None (will be created internally then)
160
164
  :param start_n: start-sample
161
165
  :param end_n: ending-sample (not included)
162
- :param ds_factor: downsampling-factor
163
- :param is_time: time is not really downsamples, but just decimated
164
- :return: downsampled h5-dataset or numpy-array
166
+ :param ds_factor: sampling-factor
167
+ :param is_time: time is not really down-sampled, but decimated
168
+ :return: resampled h5-dataset or numpy-array
165
169
  """
166
170
  from scipy import signal # here due to massive delay
167
171
 
@@ -222,7 +226,7 @@ class Reader(CoreReader):
222
226
 
223
227
  def resample(
224
228
  self,
225
- data_src: h5py.Dataset,
229
+ data_src: Union[h5py.Dataset, np.ndarray],
226
230
  data_dst: Union[None, h5py.Dataset, np.ndarray],
227
231
  start_n: int = 0,
228
232
  end_n: Optional[int] = None,
@@ -230,13 +234,15 @@ class Reader(CoreReader):
230
234
  *,
231
235
  is_time: bool = False,
232
236
  ) -> Union[h5py.Dataset, np.ndarray]:
233
- """:param data_src:
234
- :param data_dst:
235
- :param start_n:
236
- :param end_n:
237
- :param samplerate_dst:
238
- :param is_time:
239
- :return:
237
+ """Up- or down-sample the original trace-data.
238
+
239
+ :param data_src: original iv-data
240
+ :param data_dst: resampled iv-traces
241
+ :param start_n: start index of the source
242
+ :param end_n: end index of the source
243
+ :param samplerate_dst: desired sampling rate
244
+ :param is_time: time-array is handled differently than IV-Samples
245
+ :return: resampled iv-data
240
246
  """
241
247
  self._logger.error("Resampling is still under construction - do not use for now!")
242
248
  if self.get_datatype() == "ivcurve":
@@ -327,7 +333,7 @@ class Reader(CoreReader):
327
333
  *,
328
334
  relative_timestamp: bool = True,
329
335
  ) -> Dict:
330
- """Provides down-sampled iv-data that can be feed into plot_to_file()
336
+ """Provide down-sampled iv-data that can be fed into plot_to_file().
331
337
 
332
338
  :param start_s: time in seconds, relative to start of recording
333
339
  :param end_s: time in seconds, relative to start of recording
@@ -371,14 +377,15 @@ class Reader(CoreReader):
371
377
 
372
378
  @staticmethod
373
379
  def assemble_plot(data: Union[dict, list], width: int = 20, height: int = 10) -> plt.Figure:
374
- """TODO: add power (if wanted)
380
+ """Create the actual figure.
375
381
 
376
382
  :param data: plottable / down-sampled iv-data with some meta-data
377
383
  -> created with generate_plot_data()
378
384
  :param width: plot-width
379
385
  :param height: plot-height
380
- :return:
386
+ :return: figure
381
387
  """
388
+ # TODO: add power (if wanted)
382
389
  if isinstance(data, dict):
383
390
  data = [data]
384
391
  fig, axes = plt.subplots(2, 1, sharex="all")
@@ -403,8 +410,9 @@ class Reader(CoreReader):
403
410
  width: int = 20,
404
411
  height: int = 10,
405
412
  ) -> None:
406
- """Creates (down-sampled) IV-Plot
407
- -> omitting start- and end-time will use the whole duration
413
+ """Create (down-sampled) IV-Plots.
414
+
415
+ Omitting start- and end-time will use the whole trace (full duration).
408
416
 
409
417
  :param start_s: time in seconds, relative to start of recording, optional
410
418
  :param end_s: time in seconds, relative to start of recording, optional
@@ -432,7 +440,7 @@ class Reader(CoreReader):
432
440
  def multiplot_to_file(
433
441
  data: list, plot_path: Path, width: int = 20, height: int = 10
434
442
  ) -> Optional[Path]:
435
- """Creates (down-sampled) IV-Multi-Plot
443
+ """Create (down-sampled) IV-Multi-Plots (of more than one trace).
436
444
 
437
445
  :param data: plottable / down-sampled iv-data with some meta-data
438
446
  -> created with generate_plot_data()
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.1
2
+ Name: shepherd_data
3
+ Version: 2024.4.1
4
+ Summary: Programming- and CLI-Interface for the h5-dataformat of the Shepherd-Testbed
5
+ Author-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
6
+ Maintainer-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
7
+ Project-URL: Documentation, https://github.com/orgua/shepherd-datalib/blob/main/README.md
8
+ Project-URL: Issues, https://pypi.org/project/shepherd-data/issues
9
+ Project-URL: Source, https://pypi.org/project/shepherd-data/
10
+ Keywords: testbed,beaglebone,pru,batteryless,energyharvesting,solar
11
+ Platform: unix
12
+ Platform: linux
13
+ Platform: osx
14
+ Platform: cygwin
15
+ Platform: win32
16
+ Platform: win64
17
+ Classifier: Development Status :: 5 - Production/Stable
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Intended Audience :: Information Technology
20
+ Classifier: Intended Audience :: Science/Research
21
+ Classifier: Programming Language :: Python :: 3.8
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: License :: OSI Approved :: MIT License
27
+ Classifier: Operating System :: OS Independent
28
+ Classifier: Natural Language :: English
29
+ Requires-Python: >=3.8
30
+ Description-Content-Type: text/markdown
31
+ Requires-Dist: click
32
+ Requires-Dist: h5py
33
+ Requires-Dist: matplotlib
34
+ Requires-Dist: numpy
35
+ Requires-Dist: pandas>=2.0.0
36
+ Requires-Dist: pyYAML
37
+ Requires-Dist: scipy
38
+ Requires-Dist: shepherd-core[inventory]>=2024.04.1
39
+ Requires-Dist: tqdm
40
+ Provides-Extra: elf
41
+ Requires-Dist: shepherd-core[elf]; extra == "elf"
42
+ Provides-Extra: dev
43
+ Requires-Dist: shepherd-core[dev]; extra == "dev"
44
+ Requires-Dist: pandas-stubs; extra == "dev"
45
+ Provides-Extra: test
46
+ Requires-Dist: shepherd-core[test]; extra == "test"
47
+ Requires-Dist: pytest; extra == "test"
48
+ Requires-Dist: pytest-click; extra == "test"
49
+ Requires-Dist: coverage; extra == "test"
50
+
51
+ # Shepherd-Data-Tool
52
+
53
+ [![PyPiVersion](https://img.shields.io/pypi/v/shepherd_data.svg)](https://pypi.org/project/shepherd_data)
54
+ [![image](https://img.shields.io/pypi/pyversions/shepherd_data.svg)](https://pypi.python.org/pypi/shepherd-data)
55
+ [![Pytest](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml/badge.svg)](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml)
56
+ [![CodeStyle](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
57
+
58
+ **Main Documentation**: <https://orgua.github.io/shepherd>
59
+
60
+ **Source Code**: <https://github.com/orgua/shepherd-datalib>
61
+
62
+ **Main Project**: <https://github.com/orgua/shepherd>
63
+
64
+ ---
65
+
66
+ `shepherd-data` eases the handling of hdf5-recordings used by the [shepherd](https://github.com/orgua/shepherd)-testbed. Users can read, validate and create files and also extract, down-sample and plot information.
67
+
68
+ ## Installation
69
+
70
+ ### PIP - Online
71
+
72
+ ```shell
73
+ pip3 install shepherd-data -U
74
+ ```
75
+
76
+ For bleeding-edge-features or dev-work it is possible to install directly from GitHub-Sources (here `dev`-branch):
77
+
78
+ ```Shell
79
+ pip install git+https://github.com/orgua/shepherd-datalib.git@dev#subdirectory=shepherd_data -U
80
+ ```
81
+
82
+ ## More
83
+
84
+ Please consult the [official documentation](https://orgua.github.io/shepherd) for more, it covers:
85
+
86
+ - general context
87
+ - command-line interface
88
+ - programming interface