shepherd-core 2024.11.2__py3-none-any.whl → 2025.2.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.
@@ -239,6 +239,7 @@ class HarvesterPRUConfig(ShpModel):
239
239
  data: VirtualHarvesterConfig,
240
240
  dtype_in: Optional[EnergyDType] = EnergyDType.ivsample,
241
241
  window_size: Optional[u32] = None,
242
+ voltage_step_V: Optional[float] = None,
242
243
  *,
243
244
  for_emu: bool = False,
244
245
  ) -> Self:
@@ -247,17 +248,36 @@ class HarvesterPRUConfig(ShpModel):
247
248
  if for_emu and dtype_in not in {EnergyDType.ivsample, EnergyDType.ivcurve}:
248
249
  raise NotImplementedError
249
250
 
251
+ if for_emu and dtype_in == EnergyDType.ivcurve and voltage_step_V is None:
252
+ raise ValueError(
253
+ "For correct emulation specify voltage_step used by harvester "
254
+ "e.g. via file_src.get_voltage_step()"
255
+ )
256
+
257
+ if for_emu and dtype_in == EnergyDType.ivcurve and window_size is None:
258
+ raise ValueError(
259
+ "For correct emulation specify window_size used by harvester "
260
+ "e.g. via file_src.get_window_size()"
261
+ )
262
+
250
263
  interval_ms, duration_ms = data.calc_timings_ms(for_emu=for_emu)
264
+ window_size = (
265
+ window_size
266
+ if window_size is not None
267
+ else data.calc_window_size(dtype_in, for_emu=for_emu)
268
+ )
269
+ voltage_step_mV = (
270
+ 1e3 * voltage_step_V if voltage_step_V is not None else data.voltage_step_mV
271
+ )
272
+
251
273
  return cls(
252
274
  algorithm=data.calc_algorithm_num(for_emu=for_emu),
253
275
  hrv_mode=data.calc_hrv_mode(for_emu=for_emu),
254
- window_size=window_size
255
- if window_size is not None
256
- else data.calc_window_size(dtype_in, for_emu=for_emu),
276
+ window_size=window_size,
257
277
  voltage_uV=round(data.voltage_mV * 10**3),
258
278
  voltage_min_uV=round(data.voltage_min_mV * 10**3),
259
279
  voltage_max_uV=round(data.voltage_max_mV * 10**3),
260
- voltage_step_uV=round(data.voltage_step_mV * 10**3),
280
+ voltage_step_uV=round(voltage_step_mV * 10**3),
261
281
  current_limit_nA=round(data.current_limit_uA * 10**3),
262
282
  setpoint_n8=round(min(255, data.setpoint_n * 2**8)),
263
283
  interval_n=round(interval_ms * samplerate_sps_default * 1e-3),
@@ -59,8 +59,7 @@ def prepare_task(config: Union[ShpModel, Path, str], observer: Optional[str] = N
59
59
  if shp_wrap.datatype == TestbedTasks.__name__:
60
60
  if observer is None:
61
61
  logger.debug(
62
- "Task-Set contained TestbedTasks & no observer was provided "
63
- "-> will return TB-Tasks"
62
+ "Task-Set contained TestbedTasks & no observer was provided -> will return TB-Tasks"
64
63
  )
65
64
  return shp_wrap
66
65
  tbt = TestbedTasks(**shp_wrap.parameters)
@@ -93,7 +93,7 @@ class SystemInventory(ShpModel):
93
93
  reply = subprocess.run( # noqa: S603
94
94
  ptp_cmd, timeout=30, capture_output=True, check=False
95
95
  )
96
- ptp_out = f"{ reply.stdout }, { reply.stderr }"
96
+ ptp_out = f"{reply.stdout}, {reply.stderr}"
97
97
  # alternative: check_output - seems to be lighter
98
98
 
99
99
  model_dict = {
shepherd_core/reader.py CHANGED
@@ -172,7 +172,10 @@ class Reader:
172
172
  """Update internal states, helpful after resampling or other changes in data-group."""
173
173
  self.h5file.flush()
174
174
  sample_count = self.ds_time.shape[0]
175
- duration_raw = self.ds_time[sample_count - 1] - self.ds_time[0] if sample_count > 0 else 0
175
+ duration_raw = (
176
+ (int(self.ds_time[sample_count - 1]) - int(self.ds_time[0])) if sample_count > 0 else 0
177
+ )
178
+ # above's typecasting prevents overflow in u64-format
176
179
  if (sample_count > 0) and (duration_raw > 0):
177
180
  # this assumes iso-chronous sampling
178
181
  duration_s = self._cal.time.raw_to_si(duration_raw)
@@ -270,6 +273,29 @@ class Reader:
270
273
  else:
271
274
  return None
272
275
 
276
+ def get_voltage_step(self) -> Optional[float]:
277
+ """Informs about the voltage step (in volts) used during harvesting the ivcurve.
278
+
279
+ Options for figuring out the real step:
280
+ - look into config (if available)
281
+ - analyze recorded data for most often used delta
282
+ - calculate with 'steps_n * (1 + wait_cycles)' (done for calculating window_size)
283
+ """
284
+ voltage_step: Optional[float] = (
285
+ self.get_config().get("virtual_harvester", {}).get("voltage_step_mV", None)
286
+ )
287
+ if voltage_step is None:
288
+ dsv = self.ds_voltage[0:2000]
289
+ diffs_np = np.unique(dsv[1:] - dsv[0:-1], return_counts=False)
290
+ diffs_ls = [_e for _e in list(np.array(diffs_np)) if _e > 0]
291
+ # static voltages have 0 steps, so
292
+ if len(diffs_ls) == 0:
293
+ return None # or is 0 better? that may provoke div0
294
+ voltage_step = min(diffs_ls)
295
+ if voltage_step is not None:
296
+ voltage_step = 1e-3 * voltage_step
297
+ return voltage_step
298
+
273
299
  def get_hrv_config(self) -> dict:
274
300
  """Essential info for harvester.
275
301
 
@@ -278,6 +304,7 @@ class Reader:
278
304
  return {
279
305
  "datatype": self.get_datatype(),
280
306
  "window_samples": self.get_window_samples(),
307
+ "voltage_step_V": self.get_voltage_step(),
281
308
  }
282
309
 
283
310
  def is_valid(self) -> bool:
@@ -36,7 +36,7 @@ class WebClient(AbcClient):
36
36
  super().__init__()
37
37
  if not hasattr(self, "_token"):
38
38
  # add default values
39
- self._token: str = "basic_public_access"
39
+ self._token: str = "basic_public_access" # noqa: S105
40
40
  self._server: str = testbed_server_default
41
41
  self._user: Optional[User] = None
42
42
  self._key: Optional[str] = None
shepherd_core/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Separated string avoids circular imports."""
2
2
 
3
- version: str = "2024.11.2"
3
+ version: str = "2025.02.1"
@@ -47,6 +47,7 @@ def simulate_harvester(
47
47
  for_emu=True,
48
48
  dtype_in=file_inp.get_datatype(),
49
49
  window_size=file_inp.get_window_samples(),
50
+ voltage_step_V=file_inp.get_voltage_step(),
50
51
  )
51
52
  hrv = VirtualHarvesterModel(hrv_pru)
52
53
  e_out_Ws = 0.0
@@ -31,6 +31,7 @@ class VirtualSourceModel:
31
31
  cal_emu: CalibrationEmulator,
32
32
  dtype_in: EnergyDType = EnergyDType.ivsample,
33
33
  window_size: Optional[int] = None,
34
+ voltage_step_V: Optional[float] = None,
34
35
  *,
35
36
  log_intermediate: bool = False,
36
37
  ) -> None:
@@ -50,6 +51,7 @@ class VirtualSourceModel:
50
51
  for_emu=True,
51
52
  dtype_in=dtype_in,
52
53
  window_size=window_size,
54
+ voltage_step_V=voltage_step_V,
53
55
  )
54
56
 
55
57
  self.hrv: VirtualHarvesterModel = VirtualHarvesterModel(hrv_config)
@@ -56,6 +56,7 @@ def simulate_source(
56
56
  dtype_in=file_inp.get_datatype(),
57
57
  log_intermediate=False,
58
58
  window_size=file_inp.get_window_samples(),
59
+ voltage_step_V=file_inp.get_voltage_step(),
59
60
  )
60
61
  i_out_nA = 0
61
62
  e_out_Ws = 0.0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: shepherd_core
3
- Version: 2024.11.2
3
+ Version: 2025.2.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>
@@ -2,8 +2,8 @@ shepherd_core/__init__.py,sha256=fCld2mcl0y0h6kRyPal3DP-sWXnKl_0aYWYBdg4QuUk,127
2
2
  shepherd_core/calibration_hw_def.py,sha256=_nMzgNzSnYyqcLnVCGd4tfA2e0avUXbccjmNpFhiDgo,2830
3
3
  shepherd_core/commons.py,sha256=vymKXWcy_1bz7ChzzEATUkJ4p3czCzjIdsSehVjJOY8,218
4
4
  shepherd_core/logger.py,sha256=4Q4hTI-nccOZ1_A68fo4UEctfu3pJx3IeHfa9VuDDEo,1804
5
- shepherd_core/reader.py,sha256=Sg7s5UfV01CejI3_nolG7qrSDUBenmt1WPo2BPJee8o,27058
6
- shepherd_core/version.py,sha256=VcNt0axHoC1XdR-xRoXqeXfpY9UK9aTjZK9-wOWmzlc,76
5
+ shepherd_core/reader.py,sha256=BxVWE-4BfDUjVh03l0SZHT5PwVN0xPEy4aP8Kr858kI,28270
6
+ shepherd_core/version.py,sha256=o-7_x2K2hYD5ZqmJzGFJI_9bnBF0jpY08HmDCMNTfMA,76
7
7
  shepherd_core/writer.py,sha256=GMR-7vkOgpTNPoknBWsRsC7-b7iGMtT60-KtSKunNe8,14636
8
8
  shepherd_core/data_models/__init__.py,sha256=bnHSP_HBOYm4WuoiHs_vyiRsWlvkyDjsarMNfKedN-Q,1836
9
9
  shepherd_core/data_models/readme.md,sha256=1bdfEypY_0NMhXLxOPRnLAsFca0HuHdq7_01yEWxvUs,2470
@@ -21,7 +21,7 @@ shepherd_core/data_models/content/energy_environment.py,sha256=WuXMkKqnibGzM2WeW
21
21
  shepherd_core/data_models/content/energy_environment_fixture.yaml,sha256=UBXTdGT7MK98zx5w_RBCu-f9uNCKxRgiFBQFbmDUxPc,1301
22
22
  shepherd_core/data_models/content/firmware.py,sha256=MyEiaP6bkOm7i_oihDXTxHC7ajc5aqiIDLn7mhap6YY,5722
23
23
  shepherd_core/data_models/content/firmware_datatype.py,sha256=XPU9LOoT3h5qFOlE8WU0vAkw-vymNxzor9kVFyEqsWg,255
24
- shepherd_core/data_models/content/virtual_harvester.py,sha256=MXmSJ_nRp1mSzxfTNk60o9h5Yrp2lFMbLphUVSnNeNc,9999
24
+ shepherd_core/data_models/content/virtual_harvester.py,sha256=cf-DrSacZsct9e8eGoR4PX7S7RXlbxQfJHVsLR9njlM,10749
25
25
  shepherd_core/data_models/content/virtual_harvester_fixture.yaml,sha256=LZe5ue1xYhXZwB3a32sva-L4uKhkQA5AtG9JzW4B2hQ,4564
26
26
  shepherd_core/data_models/content/virtual_source.py,sha256=PPAphxEXvgMM7OVZ2dBkYAvJQkmj5Kb2BYFogVUs7B8,15354
27
27
  shepherd_core/data_models/content/virtual_source_fixture.yaml,sha256=1o-31mGgn7eyCNidKoOUp9vZh3K4Al0kJgmz54Q2DAE,11191
@@ -29,7 +29,7 @@ shepherd_core/data_models/experiment/__init__.py,sha256=lorsx0M-JWPIrt_UZfexsLwa
29
29
  shepherd_core/data_models/experiment/experiment.py,sha256=wnn6T3czuh4rz6OSYtMltCTbRpPX55TLVAtQcKO7Uhg,4044
30
30
  shepherd_core/data_models/experiment/observer_features.py,sha256=qxnb7anuQz9ZW5IUlPdUXYPIl5U7O9uXkJqZtMnAb0Y,5156
31
31
  shepherd_core/data_models/experiment/target_config.py,sha256=XIsjbbo7yn_A4q3GMxWbiNzEGA0Kk5gH7-XfQQ7Kg0E,3674
32
- shepherd_core/data_models/task/__init__.py,sha256=qZPoLdqnU2ffqP08wUdXzf0MC5hEdv5X2_XOIui0MM8,3314
32
+ shepherd_core/data_models/task/__init__.py,sha256=vOsSeB5IBYYwzOLKom8-XuZyjF86m_svtCsw-agiV7o,3295
33
33
  shepherd_core/data_models/task/emulation.py,sha256=tLb5auHOgdoG-e4hFljAYT49z7lMEaiimOy4UVZONi4,6440
34
34
  shepherd_core/data_models/task/firmware_mod.py,sha256=Rw_TA1ykQ7abUd_U0snqZlpZyrS8Nx6f4BEax1Xnji0,2818
35
35
  shepherd_core/data_models/task/harvest.py,sha256=HHnqWwRsJupaZJxuohs7NrK6VaDyoRzGOaG2h9y3s1Y,3360
@@ -59,23 +59,23 @@ shepherd_core/fw_tools/patcher.py,sha256=D6MHaCvKRRVQYSZozODAp_l7UnqxVsvnulPzpkf
59
59
  shepherd_core/fw_tools/validation.py,sha256=hBLCKIUumPTA6iuXMVbMYph2jamaxeSTxRqsvl3C4-I,4699
60
60
  shepherd_core/inventory/__init__.py,sha256=nRO11HG4eJ_FaXebSkE0dd1H6qvjrX5n3OQHOzKXVvk,3841
61
61
  shepherd_core/inventory/python.py,sha256=OWNnyEt0IDPW9XGW-WloU0FExwgZzYNA05VpRj4cZGc,1250
62
- shepherd_core/inventory/system.py,sha256=jRzko9QNPLaBiG7urVaeqqvb3GtCEYRwc0DAghRkLVo,3159
62
+ shepherd_core/inventory/system.py,sha256=Q_mtM2zhUsTvzELgpEVxSxL9aFS1RSGcCX6RFpyZ-r8,3155
63
63
  shepherd_core/inventory/target.py,sha256=Lq11j25tWieXheOxIDaQb-lc-2omxYVex5P6uGiLUyk,507
64
64
  shepherd_core/testbed_client/__init__.py,sha256=QtbsBUzHwOoM6rk0qa21ywuz63YV7af1fwUtWW8Vg_4,234
65
65
  shepherd_core/testbed_client/cache_path.py,sha256=tS0er9on5fw8wddMCt1jkc2uyYOdSTvX_UmfmYJf6tY,445
66
66
  shepherd_core/testbed_client/client_abc_fix.py,sha256=BsSkpvJHURRejlS-YPF1f6QRPC_X0fYEsJpinzsx6Jc,4079
67
- shepherd_core/testbed_client/client_web.py,sha256=iMh5T91152uugbFsqr2vvxLser0KIo5g426dp_6QWUE,5774
67
+ shepherd_core/testbed_client/client_web.py,sha256=rOg0Gf-s3S8U0z2ssh9_bNnq4aRQINfuuVHionPf38M,5788
68
68
  shepherd_core/testbed_client/fixtures.py,sha256=4Uk583R4r6I5IB78HxOn-9UNH3sbFha7OPEdcSXvMCU,9939
69
69
  shepherd_core/testbed_client/user_model.py,sha256=5M3vWkAGBwdGDUYAanAjrZwpzMBlh3XLOVvNYWiLmms,2107
70
70
  shepherd_core/vsource/__init__.py,sha256=vTvFWuJn4eurPNzEiMd15c1Rd6o3DTWzCfbhOomflZU,771
71
71
  shepherd_core/vsource/target_model.py,sha256=LaB5ppi2-IIpIepDqDvOliR-BupzccJl44yRxjlF-ms,5113
72
72
  shepherd_core/vsource/virtual_converter_model.py,sha256=3TyxphUMunoGhMda7AWCHZQU8pjRSvxB-9R8lfZFnok,11592
73
73
  shepherd_core/vsource/virtual_harvester_model.py,sha256=GyA0uGl3r42t5c4roYtEaj22b0-b5DAHUr2e9DuNn-c,9765
74
- shepherd_core/vsource/virtual_harvester_simulation.py,sha256=EiBrvmc6D2N7Z0DqFBWPdRJK6hR8Q3iQaj7EYP9pLA0,2405
75
- shepherd_core/vsource/virtual_source_model.py,sha256=-JSYUfsnYlNo5RfPBhx2G33fo5AjSeFSf2O6unroyFw,2945
76
- shepherd_core/vsource/virtual_source_simulation.py,sha256=k1v2zpNdJTqiO9uY8TXaq-IUKK6m5l-LEWebYva0skk,5088
77
- shepherd_core-2024.11.2.dist-info/METADATA,sha256=yeF95R5lUvrrwsbogULe4EUG01YQYexCCOfjPhPJ4vo,7807
78
- shepherd_core-2024.11.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
79
- shepherd_core-2024.11.2.dist-info/top_level.txt,sha256=wy-t7HRBrKARZxa-Y8_j8d49oVHnulh-95K9ikxVhew,14
80
- shepherd_core-2024.11.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
81
- shepherd_core-2024.11.2.dist-info/RECORD,,
74
+ shepherd_core/vsource/virtual_harvester_simulation.py,sha256=MFT583s73BJZYyhcqgnDUGTPr9s_lN_lKafzJG6kueE,2457
75
+ shepherd_core/vsource/virtual_source_model.py,sha256=9tiOzgrEgdEH5Uuhd8hjmmIkquNDuaNjLlblvInIlzg,3036
76
+ shepherd_core/vsource/virtual_source_simulation.py,sha256=ZOnFd2uPawY2G1salCiLGx9o1OBG99_-EHBtDjx4ZUo,5140
77
+ shepherd_core-2025.2.1.dist-info/METADATA,sha256=rYFb9DPtDYpbwy5xpIMWv7OtfQ87J12-pMQbvToPRpk,7806
78
+ shepherd_core-2025.2.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
79
+ shepherd_core-2025.2.1.dist-info/top_level.txt,sha256=wy-t7HRBrKARZxa-Y8_j8d49oVHnulh-95K9ikxVhew,14
80
+ shepherd_core-2025.2.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
81
+ shepherd_core-2025.2.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5