shepherd-data 2024.4.1__py3-none-any.whl → 2024.5.1__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 CHANGED
@@ -1,15 +1,17 @@
1
- """shepherd.datalib
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.04.1"
14
+ __version__ = "2024.5.1"
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
- """Validates a file or directory containing shepherd-recordings"""
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 as _xpc:
89
- logger.error("ERROR: will skip file, caught exception: %s", _xpc)
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
- """Extracts recorded IVSamples and stores it to csv"""
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 as _xpc:
147
- logger.error("ERROR: will skip file, caught exception: %s", _xpc)
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
- """Extracts metadata and logs from file or directory containing shepherd-recordings"""
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
- for element in ["ptp", "sysutil", "timesync"]:
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 as _xpc:
185
- logger.error("ERROR: will skip file, caught exception: %s", _xpc)
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
- """Extracts uart from gpio-trace in file or directory containing shepherd-recordings"""
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 as _xpc:
217
- logger.error("ERROR: will skip file, caught exception: %s", _xpc)
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
- """Extracts uart from gpio-trace in file or directory containing shepherd-recordings"""
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 as _xpc:
241
- logger.error("ERROR: will skip file, caught exception: %s", _xpc)
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
- """Creates an array of downsampling-files from file
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 as _xpc:
307
- logger.error("ERROR: will skip file, caught exception: %s", _xpc)
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
- """Plots IV-trace from file or directory containing shepherd-recordings"""
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 as _xpc:
368
- logger.exception("ERROR: will skip file, caught exception: %s", _xpc)
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)
shepherd_data/ivonne.py CHANGED
@@ -1,7 +1,4 @@
1
- """prototype of a file-reader with various converters
2
- to generate valid shepherd-data for emulation
3
-
4
- """
1
+ """file-reader with various converters to generate valid shepherd-data for emulation."""
5
2
 
6
3
  import errno
7
4
  import logging
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: shepherd_data
3
- Version: 2024.4.1
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.04.1
38
+ Requires-Dist: shepherd-core[inventory] >=2024.5.1
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=Ho7HbXghk0zgyYpk6OOJbKj0YJs3URe8goH31cdTpjI,352
2
+ shepherd_data/cli.py,sha256=Fp-wC44hKOkl-ssytsU0FNuKLsG6-St_azL7AXYRok4,14992
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.5.1.dist-info/METADATA,sha256=MBUl5KntgUzNZdKu8iiD31fU2379X6G6dGLF4KnS-Vk,3387
7
+ shepherd_data-2024.5.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
8
+ shepherd_data-2024.5.1.dist-info/entry_points.txt,sha256=6PBfY36A1xNOdzLiz-Qoukya_UzFZAwOapwmRNnPeZ8,56
9
+ shepherd_data-2024.5.1.dist-info/top_level.txt,sha256=7-SCTY-TG1mLY72OVKCaqte1hy-X8woxknIUAD3OIxs,14
10
+ shepherd_data-2024.5.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
11
+ shepherd_data-2024.5.1.dist-info/RECORD,,
@@ -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,,