shepherd-data 2024.7.3__py3-none-any.whl → 2024.7.4__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
@@ -11,7 +11,7 @@ from shepherd_core import Writer
11
11
 
12
12
  from .reader import Reader
13
13
 
14
- __version__ = "2024.7.3"
14
+ __version__ = "2024.7.4"
15
15
 
16
16
  __all__ = [
17
17
  "Reader",
shepherd_data/cli.py CHANGED
@@ -58,7 +58,7 @@ def path_to_flist(data_path: Path) -> List[Path]:
58
58
  help="Prints version-info at start (combinable with -v)",
59
59
  )
60
60
  @click.pass_context # TODO: is the ctx-type correct?
61
- def cli(ctx: click.Context, verbose: bool, version: bool) -> None: # noqa: FBT001
61
+ def cli(ctx: click.Context, *, verbose: bool, version: bool) -> None:
62
62
  """Shepherd: Synchronized Energy Harvesting Emulator and Recorder."""
63
63
  if verbose:
64
64
  increase_verbose_level(3)
@@ -355,13 +355,21 @@ def downsample(in_data: Path, ds_factor: Optional[float], sample_rate: Optional[
355
355
  is_flag=True,
356
356
  help="Plot all files (in directory) into one Multiplot",
357
357
  )
358
+ @click.option(
359
+ "--only-power",
360
+ "-p",
361
+ is_flag=True,
362
+ help="Plot only power instead of voltage, current & power",
363
+ )
358
364
  def plot(
359
365
  in_data: Path,
360
366
  start: Optional[float],
361
367
  end: Optional[float],
362
368
  width: int,
363
369
  height: int,
364
- multiplot: bool, # noqa: FBT001
370
+ *,
371
+ multiplot: bool,
372
+ only_power: bool,
365
373
  ) -> None:
366
374
  """Plot IV-trace from file or directory containing shepherd-recordings."""
367
375
  files = path_to_flist(in_data)
@@ -378,12 +386,12 @@ def plot(
378
386
  continue
379
387
  data.append(date)
380
388
  else:
381
- shpr.plot_to_file(start, end, width, height)
389
+ shpr.plot_to_file(start, end, width, height, only_pwr=only_power)
382
390
  except TypeError:
383
391
  logger.exception("ERROR: Will skip file. It caused an exception.")
384
392
  if multiplot:
385
393
  logger.info("Got %d datasets to plot", len(data))
386
- mpl_path = Reader.multiplot_to_file(data, in_data, width, height)
394
+ mpl_path = Reader.multiplot_to_file(data, in_data, width, height, only_pwr=only_power)
387
395
  if mpl_path:
388
396
  logger.info("Plot generated and saved to '%s'", mpl_path.name)
389
397
  else:
shepherd_data/reader.py CHANGED
@@ -171,7 +171,6 @@ class Reader(CoreReader):
171
171
 
172
172
  if self.get_datatype() == "ivcurve":
173
173
  self._logger.warning("Downsampling-Function was not written for IVCurves")
174
- return data_dst
175
174
  ds_factor = max(1, math.floor(ds_factor))
176
175
 
177
176
  if isinstance(end_n, (int, float)):
@@ -345,7 +344,6 @@ class Reader(CoreReader):
345
344
  """
346
345
  if self.get_datatype() == "ivcurve":
347
346
  self._logger.warning("Plot-Function was not written for IVCurves.")
348
- return None
349
347
  if not isinstance(start_s, (float, int)):
350
348
  start_s = 0
351
349
  if not isinstance(end_s, (float, int)):
@@ -357,7 +355,7 @@ class Reader(CoreReader):
357
355
  return None
358
356
  samplerate_dst = max(round(self.max_elements / (end_s - start_s), 3), 0.001)
359
357
  ds_factor = float(self.samplerate_sps / samplerate_dst)
360
- data = {
358
+ data: dict = {
361
359
  "name": self.get_hostname(),
362
360
  "time": self._cal.time.raw_to_si(
363
361
  self.downsample(
@@ -383,28 +381,49 @@ class Reader(CoreReader):
383
381
  return data
384
382
 
385
383
  @staticmethod
386
- def assemble_plot(data: Union[dict, list], width: int = 20, height: int = 10) -> plt.Figure:
384
+ def assemble_plot(
385
+ data: Union[dict, list], width: int = 20, height: int = 10, *, only_pwr: bool = False
386
+ ) -> plt.Figure:
387
387
  """Create the actual figure.
388
388
 
389
+ Due to the 50 mA limits of the cape the default units for current & power are mA & mW.
390
+
389
391
  :param data: plottable / down-sampled iv-data with some meta-data
390
392
  -> created with generate_plot_data()
391
393
  :param width: plot-width
392
394
  :param height: plot-height
395
+ :param only_pwr: plot power-trace instead of voltage, current & power
393
396
  :return: figure
394
397
  """
395
- # TODO: add power (if wanted)
398
+ # TODO: allow choosing freely from I, V, P, GPIO
396
399
  if isinstance(data, dict):
397
400
  data = [data]
398
- fig, axes = plt.subplots(2, 1, sharex="all")
399
- fig.suptitle("Voltage and current")
400
- for date in data:
401
- axes[0].plot(date["time"], date["voltage"], label=date["name"])
402
- axes[1].plot(date["time"], date["current"] * 10**6, label=date["name"])
403
- axes[0].set_ylabel("voltage [V]")
404
- axes[1].set_ylabel(r"current [$\mu$A]")
405
- if len(data) > 1:
406
- axes[0].legend(loc="lower center", ncol=len(data))
407
- axes[1].set_xlabel("time [s]")
401
+ if only_pwr:
402
+ fig = plt.figure(figsize=(width, height))
403
+ fig.suptitle("Power-Trace")
404
+ plt.xlabel("time [s]")
405
+ plt.ylabel("power [mW]")
406
+ for date in data:
407
+ plt.plot(
408
+ date["time"], date["voltage"] * date["current"] * 10**3, label=date["name"]
409
+ )
410
+ if len(data) > 1:
411
+ plt.legend(loc="lower center", ncol=len(data))
412
+ else:
413
+ fig, axes = plt.subplots(3, 1, sharex="all")
414
+ fig.suptitle("Voltage, current & power")
415
+ for date in data:
416
+ axes[0].plot(date["time"], date["voltage"], label=date["name"])
417
+ axes[1].plot(date["time"], date["current"] * 10**3, label=date["name"])
418
+ axes[2].plot(
419
+ date["time"], date["voltage"] * date["current"] * 10**3, label=date["name"]
420
+ )
421
+ axes[0].set_ylabel("voltage [V]")
422
+ axes[1].set_ylabel("current [mA]")
423
+ axes[2].set_ylabel("power [mW]")
424
+ if len(data) > 1:
425
+ axes[0].legend(loc="lower center", ncol=len(data))
426
+ axes[2].set_xlabel("time [s]")
408
427
  fig.set_figwidth(width)
409
428
  fig.set_figheight(height)
410
429
  fig.tight_layout()
@@ -416,6 +435,8 @@ class Reader(CoreReader):
416
435
  end_s: Optional[float] = None,
417
436
  width: int = 20,
418
437
  height: int = 10,
438
+ *,
439
+ only_pwr: bool = False,
419
440
  ) -> None:
420
441
  """Create (down-sampled) IV-Plots.
421
442
 
@@ -425,6 +446,7 @@ class Reader(CoreReader):
425
446
  :param end_s: time in seconds, relative to start of recording, optional
426
447
  :param width: plot-width
427
448
  :param height: plot-height
449
+ :param only_pwr: plot power-trace instead of voltage, current & power
428
450
  """
429
451
  if not isinstance(self.file_path, Path):
430
452
  return
@@ -440,14 +462,19 @@ class Reader(CoreReader):
440
462
  self._logger.warning("Plot exists, will skip & not overwrite!")
441
463
  return
442
464
  self._logger.info("Plot generated, will be saved to '%s'", plot_path.name)
443
- fig = self.assemble_plot(data, width, height)
465
+ fig = self.assemble_plot(data, width, height, only_pwr=only_pwr)
444
466
  plt.savefig(plot_path)
445
467
  plt.close(fig)
446
468
  plt.clf()
447
469
 
448
470
  @staticmethod
449
471
  def multiplot_to_file(
450
- data: list, plot_path: Path, width: int = 20, height: int = 10
472
+ data: list,
473
+ plot_path: Path,
474
+ width: int = 20,
475
+ height: int = 10,
476
+ *,
477
+ only_pwr: bool = False,
451
478
  ) -> Optional[Path]:
452
479
  """Create (down-sampled) IV-Multi-Plots (of more than one trace).
453
480
 
@@ -456,6 +483,7 @@ class Reader(CoreReader):
456
483
  :param plot_path: optional
457
484
  :param width: plot-width
458
485
  :param height: plot-height
486
+ :param only_pwr: plot power-trace instead of voltage, current & power
459
487
  """
460
488
  start_str = f"{data[0]['start_s']:.3f}".replace(".", "s")
461
489
  end_str = f"{data[0]['end_s']:.3f}".replace(".", "s")
@@ -465,7 +493,7 @@ class Reader(CoreReader):
465
493
  if plot_path.exists():
466
494
  logger.warning("Plot exists, will skip & not overwrite!")
467
495
  return None
468
- fig = Reader.assemble_plot(data, width, height)
496
+ fig = Reader.assemble_plot(data, width, height, only_pwr=only_pwr)
469
497
  plt.savefig(plot_path)
470
498
  plt.close(fig)
471
499
  plt.clf()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: shepherd_data
3
- Version: 2024.7.3
3
+ Version: 2024.7.4
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.7.3
38
+ Requires-Dist: shepherd-core[inventory] >=2024.7.4
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=6-KKBydEEYJAB_sME8Lu0_GfyUchSr5W6p4TcLaM6so,352
2
+ shepherd_data/cli.py,sha256=pv17ILFQCdPSyWgmw0rQIhdsYucqeiWFwJn8hft4ga0,15760
3
+ shepherd_data/ivonne.py,sha256=5EryExMQ8E8PTgX5xkZUyLqhvhCcLT17rdC0POv4NLI,11831
4
+ shepherd_data/mppt.py,sha256=588KSrLuJfNRKKnnL6ewePLi3zrwaO_PAZypikACrks,3925
5
+ shepherd_data/reader.py,sha256=l9Kcx1YHqkd_ef_QRTNpWE5ZEmxPeiVkOPw680Klzkk,20186
6
+ shepherd_data-2024.7.4.dist-info/METADATA,sha256=ZkPJrT_VxcNqVo7baBOx1cSlk9KzswnzSIFg-4tc4Rk,3387
7
+ shepherd_data-2024.7.4.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
8
+ shepherd_data-2024.7.4.dist-info/entry_points.txt,sha256=6PBfY36A1xNOdzLiz-Qoukya_UzFZAwOapwmRNnPeZ8,56
9
+ shepherd_data-2024.7.4.dist-info/top_level.txt,sha256=7-SCTY-TG1mLY72OVKCaqte1hy-X8woxknIUAD3OIxs,14
10
+ shepherd_data-2024.7.4.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
11
+ shepherd_data-2024.7.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.3.0)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,11 +0,0 @@
1
- shepherd_data/__init__.py,sha256=w0ul7JHLugSUkft5dURi3zowh6Qc7_1Yzu_PNmmcVgo,352
2
- shepherd_data/cli.py,sha256=p_SS_LRn6PxvIJRqpubCWM-qw2GCsn24evrdCCtynfY,15589
3
- shepherd_data/ivonne.py,sha256=5EryExMQ8E8PTgX5xkZUyLqhvhCcLT17rdC0POv4NLI,11831
4
- shepherd_data/mppt.py,sha256=588KSrLuJfNRKKnnL6ewePLi3zrwaO_PAZypikACrks,3925
5
- shepherd_data/reader.py,sha256=Sh33PlaafGGXVr8n2I7pM-b-vmkxYhJALsmBfpUbvHc,19000
6
- shepherd_data-2024.7.3.dist-info/METADATA,sha256=polL3ZZTD2NccYOBAXg6IxhkJs5jui86_JRMJpcXvsk,3387
7
- shepherd_data-2024.7.3.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
8
- shepherd_data-2024.7.3.dist-info/entry_points.txt,sha256=6PBfY36A1xNOdzLiz-Qoukya_UzFZAwOapwmRNnPeZ8,56
9
- shepherd_data-2024.7.3.dist-info/top_level.txt,sha256=7-SCTY-TG1mLY72OVKCaqte1hy-X8woxknIUAD3OIxs,14
10
- shepherd_data-2024.7.3.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
11
- shepherd_data-2024.7.3.dist-info/RECORD,,