shepherd-data 2024.4.1__tar.gz → 2024.5.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.
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/PKG-INFO +2 -2
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/pyproject.toml +1 -1
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data/__init__.py +7 -5
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data/cli.py +30 -29
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data/ivonne.py +1 -4
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data.egg-info/PKG-INFO +2 -2
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data.egg-info/SOURCES.txt +0 -1
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data.egg-info/requires.txt +1 -1
- shepherd_data-2024.4.1/shepherd_data/debug_resampler.py +0 -30
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/README.md +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/setup.cfg +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data/mppt.py +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data/reader.py +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data.egg-info/dependency_links.txt +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data.egg-info/entry_points.txt +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data.egg-info/top_level.txt +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data.egg-info/zip-safe +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/tests/test_cli.py +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/tests/test_cli_downsample.py +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/tests/test_cli_extract.py +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/tests/test_cli_plot.py +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/tests/test_cli_validate.py +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/tests/test_examples.py +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/tests/test_ivonne.py +0 -0
- {shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/tests/test_reader.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: shepherd_data
|
|
3
|
-
Version: 2024.
|
|
3
|
+
Version: 2024.5.1
|
|
4
4
|
Summary: Programming- and CLI-Interface for the h5-dataformat of the Shepherd-Testbed
|
|
5
5
|
Author-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
|
|
6
6
|
Maintainer-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
|
|
@@ -35,7 +35,7 @@ Requires-Dist: numpy
|
|
|
35
35
|
Requires-Dist: pandas>=2.0.0
|
|
36
36
|
Requires-Dist: pyYAML
|
|
37
37
|
Requires-Dist: scipy
|
|
38
|
-
Requires-Dist: shepherd-core[inventory]>=2024.
|
|
38
|
+
Requires-Dist: shepherd-core[inventory]>=2024.5.1
|
|
39
39
|
Requires-Dist: tqdm
|
|
40
40
|
Provides-Extra: elf
|
|
41
41
|
Requires-Dist: shepherd-core[elf]; extra == "elf"
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
"""
|
|
2
|
-
~~~~~
|
|
3
|
-
Provides classes for storing and retrieving sampled IV data to/from
|
|
4
|
-
HDF5 files.
|
|
1
|
+
"""Provides higher functionality compared to core, with additional lib-requirements.
|
|
5
2
|
|
|
3
|
+
Provides classes for storing and retrieving sampled IV data to/from
|
|
4
|
+
HDF5 files, with
|
|
5
|
+
- resampling
|
|
6
|
+
- plotting
|
|
7
|
+
- extracting metadata
|
|
6
8
|
"""
|
|
7
9
|
|
|
8
10
|
from shepherd_core import Writer
|
|
9
11
|
|
|
10
12
|
from .reader import Reader
|
|
11
13
|
|
|
12
|
-
__version__ = "2024.
|
|
14
|
+
__version__ = "2024.5.1"
|
|
13
15
|
|
|
14
16
|
__all__ = [
|
|
15
17
|
"Reader",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Command definitions for CLI"""
|
|
1
|
+
"""Command definitions for CLI."""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
import os
|
|
@@ -16,15 +16,17 @@ from shepherd_core import increase_verbose_level
|
|
|
16
16
|
from shepherd_core import local_tz
|
|
17
17
|
from shepherd_core.commons import samplerate_sps_default
|
|
18
18
|
|
|
19
|
-
from . import Reader
|
|
20
19
|
from . import Writer
|
|
21
20
|
from . import __version__
|
|
21
|
+
from .reader import Reader
|
|
22
22
|
|
|
23
23
|
logger = logging.getLogger("SHPData.cli")
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def path_to_flist(data_path: Path) -> List[Path]:
|
|
27
|
-
"""Every path gets transformed to a list of paths
|
|
27
|
+
"""Every path gets transformed to a list of paths.
|
|
28
|
+
|
|
29
|
+
Transformations:
|
|
28
30
|
- if directory: list of files inside
|
|
29
31
|
- if existing file: list with 1 element
|
|
30
32
|
- or else: empty list
|
|
@@ -57,7 +59,7 @@ def path_to_flist(data_path: Path) -> List[Path]:
|
|
|
57
59
|
)
|
|
58
60
|
@click.pass_context # TODO: is the ctx-type correct?
|
|
59
61
|
def cli(ctx: click.Context, verbose: bool, version: bool) -> None: # noqa: FBT001
|
|
60
|
-
"""Shepherd: Synchronized Energy Harvesting Emulator and Recorder"""
|
|
62
|
+
"""Shepherd: Synchronized Energy Harvesting Emulator and Recorder."""
|
|
61
63
|
if verbose:
|
|
62
64
|
increase_verbose_level(3)
|
|
63
65
|
if version:
|
|
@@ -71,7 +73,7 @@ def cli(ctx: click.Context, verbose: bool, version: bool) -> None: # noqa: FBT0
|
|
|
71
73
|
@cli.command(short_help="Validates a file or directory containing shepherd-recordings")
|
|
72
74
|
@click.argument("in_data", type=click.Path(exists=True, resolve_path=True))
|
|
73
75
|
def validate(in_data: Path) -> None:
|
|
74
|
-
"""
|
|
76
|
+
"""Validate a file or directory containing shepherd-recordings."""
|
|
75
77
|
files = path_to_flist(in_data)
|
|
76
78
|
verbose_level = get_verbose_level() # TODO: should be stored and passed in ctx
|
|
77
79
|
valid_dir = True
|
|
@@ -85,8 +87,8 @@ def validate(in_data: Path) -> None:
|
|
|
85
87
|
valid_dir &= valid_file
|
|
86
88
|
if not valid_file:
|
|
87
89
|
logger.error(" -> File '%s' was NOT valid", file.name)
|
|
88
|
-
except TypeError
|
|
89
|
-
logger.
|
|
90
|
+
except TypeError:
|
|
91
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
90
92
|
sys.exit(int(not valid_dir))
|
|
91
93
|
|
|
92
94
|
|
|
@@ -107,7 +109,7 @@ def validate(in_data: Path) -> None:
|
|
|
107
109
|
help="Set an individual csv-separator",
|
|
108
110
|
)
|
|
109
111
|
def extract(in_data: Path, ds_factor: float, separator: str) -> None:
|
|
110
|
-
"""
|
|
112
|
+
"""Extract recorded IVSamples and store them to csv."""
|
|
111
113
|
files = path_to_flist(in_data)
|
|
112
114
|
verbose_level = get_verbose_level()
|
|
113
115
|
if not isinstance(ds_factor, (float, int)) or ds_factor < 1:
|
|
@@ -143,8 +145,8 @@ def extract(in_data: Path, ds_factor: float, separator: str) -> None:
|
|
|
143
145
|
|
|
144
146
|
with Reader(ds_file, verbose=verbose_level > 2) as shpd:
|
|
145
147
|
shpd.save_csv(shpd["data"], separator)
|
|
146
|
-
except TypeError
|
|
147
|
-
logger.
|
|
148
|
+
except TypeError:
|
|
149
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
148
150
|
|
|
149
151
|
|
|
150
152
|
@cli.command(
|
|
@@ -159,18 +161,19 @@ def extract(in_data: Path, ds_factor: float, separator: str) -> None:
|
|
|
159
161
|
help="Set an individual csv-separator",
|
|
160
162
|
)
|
|
161
163
|
def extract_meta(in_data: Path, separator: str) -> None:
|
|
162
|
-
"""
|
|
164
|
+
"""Extract metadata and logs from file or directory containing shepherd-recordings."""
|
|
163
165
|
files = path_to_flist(in_data)
|
|
164
166
|
verbose_level = get_verbose_level()
|
|
165
167
|
for file in files:
|
|
166
168
|
logger.info("Extracting metadata & logs from '%s' ...", file.name)
|
|
167
169
|
# TODO: add default exports (user-centric) and allow specifying --all or specific ones
|
|
168
170
|
# TODO: could also be combined with other extractors (just have one)
|
|
169
|
-
# TODO remove deprecated: timesync; "shepherd-log", "dmesg", "exceptions"
|
|
170
171
|
try:
|
|
171
172
|
with Reader(file, verbose=verbose_level > 2) as shpr:
|
|
172
173
|
shpr.save_metadata()
|
|
173
|
-
|
|
174
|
+
csvs_depr = ["sysutil", "timesync"]
|
|
175
|
+
csvs = ["ptp", "sys_util", "pru_util"]
|
|
176
|
+
for element in csvs + csvs_depr:
|
|
174
177
|
if element in shpr.h5file:
|
|
175
178
|
shpr.save_csv(shpr[element], separator)
|
|
176
179
|
logs_depr = ["shepherd-log", "dmesg", "exceptions"]
|
|
@@ -181,8 +184,8 @@ def extract_meta(in_data: Path, separator: str) -> None:
|
|
|
181
184
|
# TODO: allow omitting timestamp,
|
|
182
185
|
# also test if segmented uart is correctly written
|
|
183
186
|
shpr.warn_logs(element, show=True)
|
|
184
|
-
except TypeError
|
|
185
|
-
logger.
|
|
187
|
+
except TypeError:
|
|
188
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
186
189
|
|
|
187
190
|
|
|
188
191
|
@cli.command(
|
|
@@ -190,7 +193,7 @@ def extract_meta(in_data: Path, separator: str) -> None:
|
|
|
190
193
|
)
|
|
191
194
|
@click.argument("in_data", type=click.Path(exists=True, resolve_path=True))
|
|
192
195
|
def extract_uart(in_data: Path) -> None:
|
|
193
|
-
"""
|
|
196
|
+
"""Extract UART from GPIO-trace in file or directory containing shepherd-recordings."""
|
|
194
197
|
files = path_to_flist(in_data)
|
|
195
198
|
verbose_level = get_verbose_level()
|
|
196
199
|
for file in files:
|
|
@@ -213,8 +216,8 @@ def extract_uart(in_data: Path) -> None:
|
|
|
213
216
|
# TODO: allow to skip Timestamp and export raw text
|
|
214
217
|
log_file.write(f"\t{str.encode(line[1])}")
|
|
215
218
|
log_file.write("\n")
|
|
216
|
-
except TypeError
|
|
217
|
-
logger.
|
|
219
|
+
except TypeError:
|
|
220
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
218
221
|
|
|
219
222
|
|
|
220
223
|
@cli.command(short_help="Extracts gpio-trace from file or directory containing shepherd-recordings")
|
|
@@ -227,7 +230,7 @@ def extract_uart(in_data: Path) -> None:
|
|
|
227
230
|
help="Set an individual csv-separator",
|
|
228
231
|
)
|
|
229
232
|
def extract_gpio(in_data: Path, separator: str) -> None:
|
|
230
|
-
"""
|
|
233
|
+
"""Extract UART from gpio-trace in file or directory containing shepherd-recordings."""
|
|
231
234
|
files = path_to_flist(in_data)
|
|
232
235
|
verbose_level = get_verbose_level()
|
|
233
236
|
for file in files:
|
|
@@ -237,8 +240,8 @@ def extract_gpio(in_data: Path, separator: str) -> None:
|
|
|
237
240
|
wfs = shpr.gpio_to_waveforms()
|
|
238
241
|
for name, wf in wfs.items():
|
|
239
242
|
shpr.waveform_to_csv(name, wf, separator)
|
|
240
|
-
except TypeError
|
|
241
|
-
logger.
|
|
243
|
+
except TypeError:
|
|
244
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
242
245
|
|
|
243
246
|
|
|
244
247
|
@cli.command(
|
|
@@ -261,9 +264,7 @@ def extract_gpio(in_data: Path, separator: str) -> None:
|
|
|
261
264
|
help="Alternative Input to determine a downsample-factor (Choose One)",
|
|
262
265
|
)
|
|
263
266
|
def downsample(in_data: Path, ds_factor: Optional[float], sample_rate: Optional[int]) -> None:
|
|
264
|
-
"""
|
|
265
|
-
or directory containing shepherd-recordings
|
|
266
|
-
"""
|
|
267
|
+
"""Create an array of down-sampled files from file or dir containing shepherd-recordings."""
|
|
267
268
|
if ds_factor is None and sample_rate is not None and sample_rate >= 1:
|
|
268
269
|
ds_factor = int(samplerate_sps_default / sample_rate)
|
|
269
270
|
# TODO: shouldn't current sps be based on file rather than default?
|
|
@@ -303,8 +304,8 @@ def downsample(in_data: Path, ds_factor: Optional[float], sample_rate: Optional[
|
|
|
303
304
|
shpr.downsample(shpr.ds_time, shpw.ds_time, ds_factor=_factor, is_time=True)
|
|
304
305
|
shpr.downsample(shpr.ds_voltage, shpw.ds_voltage, ds_factor=_factor)
|
|
305
306
|
shpr.downsample(shpr.ds_current, shpw.ds_current, ds_factor=_factor)
|
|
306
|
-
except TypeError
|
|
307
|
-
logger.
|
|
307
|
+
except TypeError:
|
|
308
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
308
309
|
|
|
309
310
|
|
|
310
311
|
@cli.command(short_help="Plots IV-trace from file or directory containing shepherd-recordings")
|
|
@@ -351,7 +352,7 @@ def plot(
|
|
|
351
352
|
height: int,
|
|
352
353
|
multiplot: bool, # noqa: FBT001
|
|
353
354
|
) -> None:
|
|
354
|
-
"""
|
|
355
|
+
"""Plot IV-trace from file or directory containing shepherd-recordings."""
|
|
355
356
|
files = path_to_flist(in_data)
|
|
356
357
|
verbose_level = get_verbose_level()
|
|
357
358
|
multiplot = multiplot and len(files) > 1
|
|
@@ -364,8 +365,8 @@ def plot(
|
|
|
364
365
|
data.append(shpr.generate_plot_data(start, end, relative_timestamp=True))
|
|
365
366
|
else:
|
|
366
367
|
shpr.plot_to_file(start, end, width, height)
|
|
367
|
-
except TypeError
|
|
368
|
-
logger.exception("ERROR:
|
|
368
|
+
except TypeError:
|
|
369
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
369
370
|
if multiplot:
|
|
370
371
|
logger.info("Got %d datasets to plot", len(data))
|
|
371
372
|
mpl_path = Reader.multiplot_to_file(data, in_data, width, height)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: shepherd_data
|
|
3
|
-
Version: 2024.
|
|
3
|
+
Version: 2024.5.1
|
|
4
4
|
Summary: Programming- and CLI-Interface for the h5-dataformat of the Shepherd-Testbed
|
|
5
5
|
Author-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
|
|
6
6
|
Maintainer-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
|
|
@@ -35,7 +35,7 @@ Requires-Dist: numpy
|
|
|
35
35
|
Requires-Dist: pandas>=2.0.0
|
|
36
36
|
Requires-Dist: pyYAML
|
|
37
37
|
Requires-Dist: scipy
|
|
38
|
-
Requires-Dist: shepherd-core[inventory]>=2024.
|
|
38
|
+
Requires-Dist: shepherd-core[inventory]>=2024.5.1
|
|
39
39
|
Requires-Dist: tqdm
|
|
40
40
|
Provides-Extra: elf
|
|
41
41
|
Requires-Dist: shepherd-core[elf]; extra == "elf"
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
import shepherd_data as shpd
|
|
5
|
-
|
|
6
|
-
file = Path("./hrv_sawtooth_1h.h5")
|
|
7
|
-
samplerate_sps = 1000
|
|
8
|
-
|
|
9
|
-
logger = logging.getLogger("SHPData.debug")
|
|
10
|
-
logger.setLevel(logging.DEBUG)
|
|
11
|
-
|
|
12
|
-
with shpd.Reader(file) as shpr:
|
|
13
|
-
out_file = file.with_suffix(f".fs_{samplerate_sps}.h5")
|
|
14
|
-
logger.info(
|
|
15
|
-
"Resampling '%s' from %d Hz to %d Hz ...",
|
|
16
|
-
file.name,
|
|
17
|
-
shpr.samplerate_sps,
|
|
18
|
-
samplerate_sps,
|
|
19
|
-
)
|
|
20
|
-
with shpd.Writer(
|
|
21
|
-
out_file,
|
|
22
|
-
mode=shpr.get_mode(),
|
|
23
|
-
datatype=shpr.get_datatype(),
|
|
24
|
-
window_samples=shpr.get_window_samples(),
|
|
25
|
-
cal_data=shpr.get_calibration_data(),
|
|
26
|
-
) as shpw:
|
|
27
|
-
shpr.resample(shpr.ds_time, shpw.ds_time, samplerate_dst=samplerate_sps, is_time=True)
|
|
28
|
-
shpr.resample(shpr.ds_voltage, shpw.ds_voltage, samplerate_dst=samplerate_sps)
|
|
29
|
-
shpr.resample(shpr.ds_current, shpw.ds_current, samplerate_dst=samplerate_sps)
|
|
30
|
-
shpw.save_metadata()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{shepherd_data-2024.4.1 → shepherd_data-2024.5.1}/shepherd_data.egg-info/dependency_links.txt
RENAMED
|
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
|