shepherd-core 2024.11.2__py3-none-any.whl → 2024.11.3__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),
shepherd_core/reader.py CHANGED
@@ -270,6 +270,26 @@ class Reader:
270
270
  else:
271
271
  return None
272
272
 
273
+ def get_voltage_step(self) -> Optional[float]:
274
+ """Informs about the voltage step (in volts) used during harvesting the ivcurve.
275
+
276
+ Options for figuring out the real step:
277
+ - look into config (if available)
278
+ - analyze recorded data for most often used delta
279
+ - calculate with 'steps_n * (1 + wait_cycles)' (done for calculating window_size)
280
+ """
281
+ voltage_step: Optional[float] = (
282
+ self.get_config().get("virtual_harvester", {}).get("voltage_step_mV", None)
283
+ )
284
+ if voltage_step is None:
285
+ dsv = self.ds_voltage[0:2000]
286
+ diffs_np = np.unique(dsv[1:] - dsv[0:-1], return_counts=False)
287
+ diffs_ls = [_e for _e in list(np.array(diffs_np)) if _e > 0]
288
+ voltage_step = min(diffs_ls)
289
+ if voltage_step is not None:
290
+ voltage_step = 1e-3 * voltage_step
291
+ return voltage_step
292
+
273
293
  def get_hrv_config(self) -> dict:
274
294
  """Essential info for harvester.
275
295
 
@@ -278,6 +298,7 @@ class Reader:
278
298
  return {
279
299
  "datatype": self.get_datatype(),
280
300
  "window_samples": self.get_window_samples(),
301
+ "voltage_step_V": self.get_voltage_step(),
281
302
  }
282
303
 
283
304
  def is_valid(self) -> bool:
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 = "2024.11.3"
@@ -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
1
  Metadata-Version: 2.1
2
2
  Name: shepherd_core
3
- Version: 2024.11.2
3
+ Version: 2024.11.3
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=OBjvvo-R_68RPAlgTWfYkNeIW-wEeHVcSzScxLhYhvg,28021
6
+ shepherd_core/version.py,sha256=efgburSXJlcrRhiL0_hKDFmBgNSmAdHw7BRzTIN918M,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
@@ -71,11 +71,11 @@ shepherd_core/vsource/__init__.py,sha256=vTvFWuJn4eurPNzEiMd15c1Rd6o3DTWzCfbhOom
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-2024.11.3.dist-info/METADATA,sha256=OBSLkOgbXMb_mhTym-Dk2p_GoPkGQyzMbYlaRhRhicU,7807
78
+ shepherd_core-2024.11.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
79
+ shepherd_core-2024.11.3.dist-info/top_level.txt,sha256=wy-t7HRBrKARZxa-Y8_j8d49oVHnulh-95K9ikxVhew,14
80
+ shepherd_core-2024.11.3.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
81
+ shepherd_core-2024.11.3.dist-info/RECORD,,