shepherd-core 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.
@@ -32,45 +32,48 @@ RAW_MAX_ADC = 2**M_ADC - 1
32
32
  RAW_MAX_DAC = 2**M_DAC - 1
33
33
 
34
34
 
35
- def adc_current_to_raw(current: float) -> int:
35
+ def adc_current_to_raw(current: float, *, limited: bool = True) -> int:
36
36
  """Convert back a current [A] to raw ADC value."""
37
37
  # voltage on input of adc
38
38
  val_adc = G_INST_AMP * R_SHT * current
39
39
  # digital value according to ADC gain
40
40
  val_raw = int(val_adc * (2**M_ADC) / (G_ADC_I * V_REF_ADC))
41
- return min(max(val_raw, 0), 2**M_ADC - 1)
41
+ return min(max(val_raw, 0), 2**M_ADC - 1) if limited else val_raw
42
42
 
43
43
 
44
- def adc_raw_to_current(value: int) -> float:
44
+ def adc_raw_to_current(value: int, *, limited: bool = True) -> float:
45
45
  """Convert a raw ADC value to a current [A]."""
46
- value = min(max(value, 0), 2**M_ADC - 1)
46
+ if limited:
47
+ value = min(max(value, 0), 2**M_ADC - 1)
47
48
  # voltage on input of adc
48
49
  val_adc = float(value) * (G_ADC_I * V_REF_ADC) / (2**M_ADC)
49
50
  # current according to adc value
50
51
  return val_adc / (R_SHT * G_INST_AMP)
51
52
 
52
53
 
53
- def adc_voltage_to_raw(voltage: float) -> int:
54
+ def adc_voltage_to_raw(voltage: float, *, limited: bool = True) -> int:
54
55
  """Convert back a voltage [V] to raw ADC value."""
55
56
  # digital value according to ADC gain
56
57
  val_raw = int(voltage * (2**M_ADC) / (G_ADC_V * V_REF_ADC))
57
- return min(max(val_raw, 0), 2**M_ADC - 1)
58
+ return min(max(val_raw, 0), 2**M_ADC - 1) if limited else val_raw
58
59
 
59
60
 
60
- def adc_raw_to_voltage(value: int) -> float:
61
+ def adc_raw_to_voltage(value: int, *, limited: bool = True) -> float:
61
62
  """Convert a raw ADC value to a voltage [V]."""
62
- value = min(max(value, 0), 2**M_ADC - 1)
63
+ if limited:
64
+ value = min(max(value, 0), 2**M_ADC - 1)
63
65
  # voltage according to ADC value
64
66
  return float(value) * (G_ADC_V * V_REF_ADC) / (2**M_ADC)
65
67
 
66
68
 
67
- def dac_raw_to_voltage(value: int) -> float:
69
+ def dac_raw_to_voltage(value: int, *, limited: bool = True) -> float:
68
70
  """Convert back a raw DAC value to a voltage [V]."""
69
- value = min(max(value, 0), 2**M_DAC - 1)
71
+ if limited:
72
+ value = min(max(value, 0), 2**M_DAC - 1)
70
73
  return float(value) * (V_REF_DAC * G_DAC) / (2**M_DAC)
71
74
 
72
75
 
73
- def dac_voltage_to_raw(voltage: float) -> int:
76
+ def dac_voltage_to_raw(voltage: float, *, limited: bool = True) -> int:
74
77
  """Convert a voltage [V] to raw DAC value."""
75
78
  val_raw = int(voltage * (2**M_DAC) / (V_REF_DAC * G_DAC))
76
- return min(max(val_raw, 0), 2**M_DAC - 1)
79
+ return min(max(val_raw, 0), 2**M_DAC - 1) if limited else val_raw
@@ -51,6 +51,7 @@ class CalibrationPair(ShpModel):
51
51
 
52
52
  gain: PositiveFloat
53
53
  offset: float = 0
54
+ # TODO: add unit
54
55
 
55
56
  def raw_to_si(self, values_raw: Calc_t, *, allow_negative: bool = True) -> Calc_t:
56
57
  """Convert between physical units and raw unsigned integers."""
@@ -79,8 +80,8 @@ class CalibrationPair(ShpModel):
79
80
  @classmethod
80
81
  def from_fn(cls, fn: Callable) -> Self:
81
82
  """Probe linear function to determine scaling values."""
82
- offset = fn(0)
83
- gain_inv = fn(1.0) - offset
83
+ offset = fn(0, limited=False)
84
+ gain_inv = fn(1.0, limited=False) - offset
84
85
  return cls(
85
86
  gain=1.0 / float(gain_inv),
86
87
  offset=-float(offset) / gain_inv,
@@ -274,7 +275,7 @@ class CalibrationSeries(ShpModel):
274
275
  emu_port_a: bool = True,
275
276
  ) -> Self:
276
277
  if isinstance(cal, CalibrationHarvester):
277
- return cls(voltage=cal.adc_V_Sense, current=cal.dac_V_Hrv)
278
+ return cls(voltage=cal.adc_V_Sense, current=cal.adc_C_Hrv)
278
279
  if emu_port_a:
279
280
  return cls(voltage=cal.dac_V_A, current=cal.adc_C_A)
280
281
  return cls(voltage=cal.dac_V_B, current=cal.adc_C_B)
shepherd_core/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Separated string avoids circular imports."""
2
2
 
3
- version: str = "2024.7.3"
3
+ version: str = "2024.7.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: shepherd_core
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>
@@ -136,28 +136,30 @@ Notes:
136
136
  The Library is available via PyPI and can be installed with
137
137
 
138
138
  ```shell
139
- pip install shepherd-core -U
139
+ pip install shepherd-core -U
140
140
 
141
- # or for the full experience (includes core)
142
- pip install shepherd-data -U
141
+ # or for the full experience (includes core)
142
+ pip install shepherd-data -U
143
143
  ```
144
144
 
145
145
  For bleeding-edge-features or dev-work it is possible to install directly from GitHub-Sources (here `dev`-branch):
146
146
 
147
147
  ```Shell
148
148
  pip install git+https://github.com/orgua/shepherd-datalib.git@dev#subdirectory=shepherd_core -U
149
+ # and on sheep with newer debian
150
+ pip install git+https://github.com/orgua/shepherd-datalib.git@dev#subdirectory=shepherd_core -U --break-system-packages
149
151
  ```
150
152
 
151
153
  If you are working with ``.elf``-files (embedding into experiments) you make "objcopy" accessible to python. In Ubuntu, you can either install ``build-essential`` or ``binutils-$ARCH`` with arch being ``msp430`` or ``arm-none-eabi`` for the nRF52.
152
154
 
153
155
  ```shell
154
- sudo apt install build-essential
156
+ sudo apt install build-essential
155
157
  ```
156
158
 
157
159
  For more advanced work with ``.elf``-files (modify value of symbols / target-ID) you should install
158
160
 
159
161
  ```shell
160
- pip install shepherd-core[elf]
162
+ pip install shepherd-core[elf]
161
163
  ```
162
164
 
163
165
  and also make sure the prereqs for the [pwntools](https://docs.pwntools.com/en/stable/install.html) are met.
@@ -165,7 +167,7 @@ and also make sure the prereqs for the [pwntools](https://docs.pwntools.com/en/s
165
167
  For creating an inventory of the host-system you should install
166
168
 
167
169
  ```shell
168
- pip install shepherd-core[inventory]
170
+ pip install shepherd-core[inventory]
169
171
  ```
170
172
 
171
173
  ## Unittests
@@ -1,16 +1,16 @@
1
1
  shepherd_core/__init__.py,sha256=QyqENyf508XfZQ4vDU5o6UL9rmIqkf8kzwgTF9XU1-Y,1270
2
- shepherd_core/calibration_hw_def.py,sha256=m5HDxHJ_blnn-C0Og5v6by1ApJRDT7RhytFbL-P5730,2548
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
5
  shepherd_core/reader.py,sha256=9BuArqou5pmPKUrJH9oiPYlU1DkMxUScL4nftDJuFIs,26790
6
- shepherd_core/version.py,sha256=_g69sZNO8AhbkOwQt8KmcgsSbdI6Yyb6XSYvZKHehC0,75
6
+ shepherd_core/version.py,sha256=nuk8f6h1RBadV7-koFp4yLk1jExaUHnFqMTtxlKZyCo,75
7
7
  shepherd_core/writer.py,sha256=xcLCw-YokKaN8TrkwD0IjRmn8xZU0Q8wwWp_1K8JFVY,14475
8
8
  shepherd_core/data_models/__init__.py,sha256=IVjKbT2Ilz5bev325EvAuuhd9LfQgQ1u7qKo6dhVA2k,1866
9
9
  shepherd_core/data_models/readme.md,sha256=1bdfEypY_0NMhXLxOPRnLAsFca0HuHdq7_01yEWxvUs,2470
10
10
  shepherd_core/data_models/virtual_source_doc.txt,sha256=KizMcfGKj7BnHIbaJHT7KeTF01SV__UXv01qV_DGHSs,6057
11
11
  shepherd_core/data_models/base/__init__.py,sha256=PSJ6acWViqBm0Eiom8DIgKfFVrp5lzYr8OsDvP79vwI,94
12
12
  shepherd_core/data_models/base/cal_measurement.py,sha256=YScPG7QLynbUHdjcznYqU8O5KRh0XiROGxGSk9BETMk,3357
13
- shepherd_core/data_models/base/calibration.py,sha256=HPhDEaApOCKxfX2q9RD8YCvA3Gqls-2bHqvLLvOM7kY,10415
13
+ shepherd_core/data_models/base/calibration.py,sha256=iy04ajChReqrRNLoNDEH01CM-iCvb5XepBIlyFSWeII,10466
14
14
  shepherd_core/data_models/base/content.py,sha256=13j7GSgT73xn27jgDP508thUEJR4U-nCb5n7CJ50c9Y,2463
15
15
  shepherd_core/data_models/base/shepherd.py,sha256=DNrx59o1VBuy_liJuUzZRzmTTYB73D_pUWiNyMQyjYY,6112
16
16
  shepherd_core/data_models/base/timezone.py,sha256=2T6E46hJ1DAvmqKfu6uIgCK3RSoAKjGXRyzYNaqKyjY,665
@@ -70,8 +70,8 @@ shepherd_core/vsource/__init__.py,sha256=dS33KYLq5GQ9_D8HfdP8iWSocWTghCi2ZZG2AJW
70
70
  shepherd_core/vsource/virtual_converter_model.py,sha256=ZSoWVLfRmFEjeCNoQCg3BctzhdfayINUBDU_AJK1CR0,10404
71
71
  shepherd_core/vsource/virtual_harvester_model.py,sha256=wCbFfsqDRC5Rfu8qANkmkP9XGJOPHJY9-iSnI850JI4,7817
72
72
  shepherd_core/vsource/virtual_source_model.py,sha256=fjN8myTY3I_LpikF_aGAcxes3RGu1GP23P7XKC_UIyA,2737
73
- shepherd_core-2024.7.3.dist-info/METADATA,sha256=dbgRhKRkV3GkLlSKX6qbbIFloUtGQuPdM-Sjmx-Vt2Y,7630
74
- shepherd_core-2024.7.3.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
75
- shepherd_core-2024.7.3.dist-info/top_level.txt,sha256=wy-t7HRBrKARZxa-Y8_j8d49oVHnulh-95K9ikxVhew,14
76
- shepherd_core-2024.7.3.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
77
- shepherd_core-2024.7.3.dist-info/RECORD,,
73
+ shepherd_core-2024.7.4.dist-info/METADATA,sha256=zFRCTLQEf-XN8Szx8fxb2JwCA6H0F26oUU5UMgWxVaA,7771
74
+ shepherd_core-2024.7.4.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
75
+ shepherd_core-2024.7.4.dist-info/top_level.txt,sha256=wy-t7HRBrKARZxa-Y8_j8d49oVHnulh-95K9ikxVhew,14
76
+ shepherd_core-2024.7.4.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
77
+ shepherd_core-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