shepherd-data 2024.4.1__py3-none-any.whl → 2024.4.2__py3-none-any.whl
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/__init__.py +7 -5
- shepherd_data/cli.py +28 -28
- shepherd_data/ivonne.py +1 -4
- {shepherd_data-2024.4.1.dist-info → shepherd_data-2024.4.2.dist-info}/METADATA +2 -2
- shepherd_data-2024.4.2.dist-info/RECORD +11 -0
- shepherd_data/debug_resampler.py +0 -30
- shepherd_data-2024.4.1.dist-info/RECORD +0 -12
- {shepherd_data-2024.4.1.dist-info → shepherd_data-2024.4.2.dist-info}/WHEEL +0 -0
- {shepherd_data-2024.4.1.dist-info → shepherd_data-2024.4.2.dist-info}/entry_points.txt +0 -0
- {shepherd_data-2024.4.1.dist-info → shepherd_data-2024.4.2.dist-info}/top_level.txt +0 -0
- {shepherd_data-2024.4.1.dist-info → shepherd_data-2024.4.2.dist-info}/zip-safe +0 -0
shepherd_data/__init__.py
CHANGED
|
@@ -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.4.2"
|
|
13
15
|
|
|
14
16
|
__all__ = [
|
|
15
17
|
"Reader",
|
shepherd_data/cli.py
CHANGED
|
@@ -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,14 +161,14 @@ 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
|
|
171
|
+
# TODO: remove deprecated timesync; "shepherd-log", "dmesg", "exceptions"
|
|
170
172
|
try:
|
|
171
173
|
with Reader(file, verbose=verbose_level > 2) as shpr:
|
|
172
174
|
shpr.save_metadata()
|
|
@@ -181,8 +183,8 @@ def extract_meta(in_data: Path, separator: str) -> None:
|
|
|
181
183
|
# TODO: allow omitting timestamp,
|
|
182
184
|
# also test if segmented uart is correctly written
|
|
183
185
|
shpr.warn_logs(element, show=True)
|
|
184
|
-
except TypeError
|
|
185
|
-
logger.
|
|
186
|
+
except TypeError:
|
|
187
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
186
188
|
|
|
187
189
|
|
|
188
190
|
@cli.command(
|
|
@@ -190,7 +192,7 @@ def extract_meta(in_data: Path, separator: str) -> None:
|
|
|
190
192
|
)
|
|
191
193
|
@click.argument("in_data", type=click.Path(exists=True, resolve_path=True))
|
|
192
194
|
def extract_uart(in_data: Path) -> None:
|
|
193
|
-
"""
|
|
195
|
+
"""Extract UART from GPIO-trace in file or directory containing shepherd-recordings."""
|
|
194
196
|
files = path_to_flist(in_data)
|
|
195
197
|
verbose_level = get_verbose_level()
|
|
196
198
|
for file in files:
|
|
@@ -213,8 +215,8 @@ def extract_uart(in_data: Path) -> None:
|
|
|
213
215
|
# TODO: allow to skip Timestamp and export raw text
|
|
214
216
|
log_file.write(f"\t{str.encode(line[1])}")
|
|
215
217
|
log_file.write("\n")
|
|
216
|
-
except TypeError
|
|
217
|
-
logger.
|
|
218
|
+
except TypeError:
|
|
219
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
218
220
|
|
|
219
221
|
|
|
220
222
|
@cli.command(short_help="Extracts gpio-trace from file or directory containing shepherd-recordings")
|
|
@@ -227,7 +229,7 @@ def extract_uart(in_data: Path) -> None:
|
|
|
227
229
|
help="Set an individual csv-separator",
|
|
228
230
|
)
|
|
229
231
|
def extract_gpio(in_data: Path, separator: str) -> None:
|
|
230
|
-
"""
|
|
232
|
+
"""Extract UART from gpio-trace in file or directory containing shepherd-recordings."""
|
|
231
233
|
files = path_to_flist(in_data)
|
|
232
234
|
verbose_level = get_verbose_level()
|
|
233
235
|
for file in files:
|
|
@@ -237,8 +239,8 @@ def extract_gpio(in_data: Path, separator: str) -> None:
|
|
|
237
239
|
wfs = shpr.gpio_to_waveforms()
|
|
238
240
|
for name, wf in wfs.items():
|
|
239
241
|
shpr.waveform_to_csv(name, wf, separator)
|
|
240
|
-
except TypeError
|
|
241
|
-
logger.
|
|
242
|
+
except TypeError:
|
|
243
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
242
244
|
|
|
243
245
|
|
|
244
246
|
@cli.command(
|
|
@@ -261,9 +263,7 @@ def extract_gpio(in_data: Path, separator: str) -> None:
|
|
|
261
263
|
help="Alternative Input to determine a downsample-factor (Choose One)",
|
|
262
264
|
)
|
|
263
265
|
def downsample(in_data: Path, ds_factor: Optional[float], sample_rate: Optional[int]) -> None:
|
|
264
|
-
"""
|
|
265
|
-
or directory containing shepherd-recordings
|
|
266
|
-
"""
|
|
266
|
+
"""Create an array of down-sampled files from file or dir containing shepherd-recordings."""
|
|
267
267
|
if ds_factor is None and sample_rate is not None and sample_rate >= 1:
|
|
268
268
|
ds_factor = int(samplerate_sps_default / sample_rate)
|
|
269
269
|
# TODO: shouldn't current sps be based on file rather than default?
|
|
@@ -303,8 +303,8 @@ def downsample(in_data: Path, ds_factor: Optional[float], sample_rate: Optional[
|
|
|
303
303
|
shpr.downsample(shpr.ds_time, shpw.ds_time, ds_factor=_factor, is_time=True)
|
|
304
304
|
shpr.downsample(shpr.ds_voltage, shpw.ds_voltage, ds_factor=_factor)
|
|
305
305
|
shpr.downsample(shpr.ds_current, shpw.ds_current, ds_factor=_factor)
|
|
306
|
-
except TypeError
|
|
307
|
-
logger.
|
|
306
|
+
except TypeError:
|
|
307
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
308
308
|
|
|
309
309
|
|
|
310
310
|
@cli.command(short_help="Plots IV-trace from file or directory containing shepherd-recordings")
|
|
@@ -351,7 +351,7 @@ def plot(
|
|
|
351
351
|
height: int,
|
|
352
352
|
multiplot: bool, # noqa: FBT001
|
|
353
353
|
) -> None:
|
|
354
|
-
"""
|
|
354
|
+
"""Plot IV-trace from file or directory containing shepherd-recordings."""
|
|
355
355
|
files = path_to_flist(in_data)
|
|
356
356
|
verbose_level = get_verbose_level()
|
|
357
357
|
multiplot = multiplot and len(files) > 1
|
|
@@ -364,8 +364,8 @@ def plot(
|
|
|
364
364
|
data.append(shpr.generate_plot_data(start, end, relative_timestamp=True))
|
|
365
365
|
else:
|
|
366
366
|
shpr.plot_to_file(start, end, width, height)
|
|
367
|
-
except TypeError
|
|
368
|
-
logger.exception("ERROR:
|
|
367
|
+
except TypeError:
|
|
368
|
+
logger.exception("ERROR: Will skip file. It caused an exception.")
|
|
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)
|
shepherd_data/ivonne.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: shepherd_data
|
|
3
|
-
Version: 2024.4.
|
|
3
|
+
Version: 2024.4.2
|
|
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.4.2
|
|
39
39
|
Requires-Dist: tqdm
|
|
40
40
|
Provides-Extra: dev
|
|
41
41
|
Requires-Dist: shepherd-core[dev] ; extra == 'dev'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
shepherd_data/__init__.py,sha256=EVDwIGGT7VHG4hZ8WScG5aUFIokNAxmd8fR0ZR22hmA,352
|
|
2
|
+
shepherd_data/cli.py,sha256=GD9yxRToqi5fDhfwPZrXQUGlRz5G65A9K1j3Kr6x-zI,14981
|
|
3
|
+
shepherd_data/ivonne.py,sha256=_tys7LNnUStj-zV56DZxxx3Ku-ILdrNJqLXst7PXcxU,11584
|
|
4
|
+
shepherd_data/mppt.py,sha256=588KSrLuJfNRKKnnL6ewePLi3zrwaO_PAZypikACrks,3925
|
|
5
|
+
shepherd_data/reader.py,sha256=JKTVemjH_6678MCNf2cDzRIsCyfD2B6CTUzBiG110QY,18531
|
|
6
|
+
shepherd_data-2024.4.2.dist-info/METADATA,sha256=R9-bdFb5pm8FR8Rg6CTwInx-LOIifJHyBRIP0uxoj3s,3387
|
|
7
|
+
shepherd_data-2024.4.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
8
|
+
shepherd_data-2024.4.2.dist-info/entry_points.txt,sha256=6PBfY36A1xNOdzLiz-Qoukya_UzFZAwOapwmRNnPeZ8,56
|
|
9
|
+
shepherd_data-2024.4.2.dist-info/top_level.txt,sha256=7-SCTY-TG1mLY72OVKCaqte1hy-X8woxknIUAD3OIxs,14
|
|
10
|
+
shepherd_data-2024.4.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
11
|
+
shepherd_data-2024.4.2.dist-info/RECORD,,
|
shepherd_data/debug_resampler.py
DELETED
|
@@ -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()
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
shepherd_data/__init__.py,sha256=EZ_RzvcBkL2fMTCCWtKcbzMcrmmwgDb7SD-GZhvqUnA,243
|
|
2
|
-
shepherd_data/cli.py,sha256=2GDpTgd9cHJQS-GZJSvn2bhyeh6oG_srtITfc3FGAmg,15017
|
|
3
|
-
shepherd_data/debug_resampler.py,sha256=0VNGuUqOeKii6fvkRJUpv-27uv9p1VFsvShU3tvxwYQ,961
|
|
4
|
-
shepherd_data/ivonne.py,sha256=ArojlpWWYwaetkDtBhi-RdFidt79GHoMLZLRR6KljRo,11600
|
|
5
|
-
shepherd_data/mppt.py,sha256=588KSrLuJfNRKKnnL6ewePLi3zrwaO_PAZypikACrks,3925
|
|
6
|
-
shepherd_data/reader.py,sha256=JKTVemjH_6678MCNf2cDzRIsCyfD2B6CTUzBiG110QY,18531
|
|
7
|
-
shepherd_data-2024.4.1.dist-info/METADATA,sha256=ZuZcImaE9O7tvzyibfM4wVcToX_p7nImzS4lq8DEUoA,3388
|
|
8
|
-
shepherd_data-2024.4.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
9
|
-
shepherd_data-2024.4.1.dist-info/entry_points.txt,sha256=6PBfY36A1xNOdzLiz-Qoukya_UzFZAwOapwmRNnPeZ8,56
|
|
10
|
-
shepherd_data-2024.4.1.dist-info/top_level.txt,sha256=7-SCTY-TG1mLY72OVKCaqte1hy-X8woxknIUAD3OIxs,14
|
|
11
|
-
shepherd_data-2024.4.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
12
|
-
shepherd_data-2024.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|