shepherd-core 2023.12.1__py3-none-any.whl → 2024.4.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_core/__init__.py +3 -2
- shepherd_core/data_models/base/calibration.py +3 -1
- shepherd_core/data_models/base/content.py +11 -4
- shepherd_core/data_models/base/shepherd.py +2 -0
- shepherd_core/data_models/content/energy_environment.py +1 -1
- shepherd_core/data_models/content/virtual_harvester.py +1 -1
- shepherd_core/data_models/content/virtual_source.py +18 -13
- shepherd_core/data_models/experiment/experiment.py +10 -10
- shepherd_core/data_models/experiment/observer_features.py +5 -6
- shepherd_core/data_models/task/observer_tasks.py +1 -1
- shepherd_core/data_models/task/testbed_tasks.py +7 -3
- shepherd_core/data_models/testbed/cape.py +1 -1
- shepherd_core/data_models/testbed/gpio.py +1 -1
- shepherd_core/data_models/testbed/mcu.py +1 -1
- shepherd_core/data_models/testbed/observer.py +1 -1
- shepherd_core/data_models/testbed/target.py +1 -1
- shepherd_core/data_models/testbed/testbed.py +1 -1
- shepherd_core/decoder_waveform/uart.py +1 -0
- shepherd_core/fw_tools/validation.py +1 -2
- shepherd_core/inventory/__init__.py +51 -1
- shepherd_core/inventory/system.py +8 -0
- shepherd_core/reader.py +19 -16
- shepherd_core/testbed_client/cache_path.py +15 -0
- shepherd_core/testbed_client/client.py +2 -3
- shepherd_core/testbed_client/fixtures.py +4 -1
- shepherd_core/testbed_client/user_model.py +6 -4
- shepherd_core/vsource/virtual_converter_model.py +1 -1
- shepherd_core/vsource/virtual_harvester_model.py +1 -0
- shepherd_core/vsource/virtual_source_model.py +1 -0
- shepherd_core/writer.py +5 -2
- {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.1.dist-info}/METADATA +49 -34
- shepherd_core-2024.4.1.dist-info/RECORD +64 -0
- {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.1.dist-info}/WHEEL +1 -1
- {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.1.dist-info}/top_level.txt +0 -1
- shepherd_core/data_models/content/_external_fixtures.yaml +0 -394
- shepherd_core/data_models/content/energy_environment_fixture.yaml +0 -50
- shepherd_core/data_models/content/virtual_harvester_fixture.yaml +0 -159
- shepherd_core/data_models/content/virtual_source_fixture.yaml +0 -229
- shepherd_core/data_models/testbed/cape_fixture.yaml +0 -94
- shepherd_core/data_models/testbed/gpio_fixture.yaml +0 -166
- shepherd_core/data_models/testbed/mcu_fixture.yaml +0 -19
- shepherd_core/data_models/testbed/observer_fixture.yaml +0 -220
- shepherd_core/data_models/testbed/target_fixture.yaml +0 -137
- shepherd_core/data_models/testbed/testbed_fixture.yaml +0 -25
- shepherd_core-2023.12.1.dist-info/RECORD +0 -117
- tests/__init__.py +0 -0
- tests/conftest.py +0 -64
- tests/data_models/__init__.py +0 -0
- tests/data_models/conftest.py +0 -14
- tests/data_models/example_cal_data.yaml +0 -31
- tests/data_models/example_cal_data_faulty.yaml +0 -29
- tests/data_models/example_cal_meas.yaml +0 -178
- tests/data_models/example_cal_meas_faulty1.yaml +0 -142
- tests/data_models/example_cal_meas_faulty2.yaml +0 -136
- tests/data_models/example_config_emulator.yaml +0 -41
- tests/data_models/example_config_experiment.yaml +0 -16
- tests/data_models/example_config_experiment_alternative.yaml +0 -14
- tests/data_models/example_config_harvester.yaml +0 -15
- tests/data_models/example_config_testbed.yaml +0 -26
- tests/data_models/example_config_virtsource.yaml +0 -78
- tests/data_models/test_base_models.py +0 -205
- tests/data_models/test_content_fixtures.py +0 -41
- tests/data_models/test_content_models.py +0 -282
- tests/data_models/test_examples.py +0 -48
- tests/data_models/test_experiment_models.py +0 -277
- tests/data_models/test_task_generation.py +0 -52
- tests/data_models/test_task_models.py +0 -131
- tests/data_models/test_testbed_fixtures.py +0 -47
- tests/data_models/test_testbed_models.py +0 -187
- tests/decoder_waveform/__init__.py +0 -0
- tests/decoder_waveform/test_decoder.py +0 -34
- tests/fw_tools/__init__.py +0 -0
- tests/fw_tools/conftest.py +0 -5
- tests/fw_tools/test_converter.py +0 -76
- tests/fw_tools/test_patcher.py +0 -66
- tests/fw_tools/test_validation.py +0 -56
- tests/inventory/__init__.py +0 -0
- tests/inventory/test_inventory.py +0 -20
- tests/test_cal_hw.py +0 -34
- tests/test_examples.py +0 -40
- tests/test_logger.py +0 -15
- tests/test_reader.py +0 -283
- tests/test_writer.py +0 -169
- tests/testbed_client/__init__.py +0 -0
- tests/vsource/__init__.py +0 -0
- tests/vsource/conftest.py +0 -49
- tests/vsource/test_converter.py +0 -161
- tests/vsource/test_harvester.py +0 -73
- tests/vsource/test_z.py +0 -5
- {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.1.dist-info}/zip-safe +0 -0
tests/test_writer.py
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from typing import Optional
|
|
3
|
-
from typing import Union
|
|
4
|
-
|
|
5
|
-
import numpy as np
|
|
6
|
-
import pytest
|
|
7
|
-
|
|
8
|
-
from shepherd_core import Reader
|
|
9
|
-
from shepherd_core import Writer
|
|
10
|
-
from shepherd_core.data_models import CalibrationEmulator as CalEmu
|
|
11
|
-
from shepherd_core.data_models import CalibrationHarvester as CalHrv
|
|
12
|
-
from shepherd_core.data_models import CalibrationSeries as CalSeries
|
|
13
|
-
from shepherd_core.data_models.task import Compression
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def generate_shp_file(
|
|
17
|
-
store_path: Path,
|
|
18
|
-
mode: Optional[str] = None,
|
|
19
|
-
datatype: Optional[str] = None,
|
|
20
|
-
window_samples: Optional[int] = None,
|
|
21
|
-
cal_data: Union[CalSeries, CalEmu, CalHrv, None] = None,
|
|
22
|
-
config: Optional[dict] = None,
|
|
23
|
-
compression: Optional[Compression] = Compression.default,
|
|
24
|
-
hostname: str = "unknown",
|
|
25
|
-
) -> Path:
|
|
26
|
-
if config is None:
|
|
27
|
-
config = {}
|
|
28
|
-
with Writer(
|
|
29
|
-
store_path,
|
|
30
|
-
mode=mode,
|
|
31
|
-
datatype=datatype,
|
|
32
|
-
window_samples=window_samples,
|
|
33
|
-
cal_data=cal_data,
|
|
34
|
-
compression=compression,
|
|
35
|
-
verbose=True,
|
|
36
|
-
) as file:
|
|
37
|
-
file.store_hostname(hostname)
|
|
38
|
-
file.store_config(config)
|
|
39
|
-
duration_s = 2
|
|
40
|
-
timestamps = np.arange(0.0, duration_s, file.sample_interval_ns / 1e9)
|
|
41
|
-
voltages = np.linspace(3.60, 1.90, int(file.samplerate_sps * duration_s))
|
|
42
|
-
currents = np.linspace(100e-6, 2000e-6, int(file.samplerate_sps * duration_s))
|
|
43
|
-
file.append_iv_data_si(timestamps, voltages, currents)
|
|
44
|
-
return store_path
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
@pytest.fixture
|
|
48
|
-
def h5_path(tmp_path: Path) -> Path:
|
|
49
|
-
return tmp_path / "hrv_test.h5"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
@pytest.fixture
|
|
53
|
-
def h5_file(h5_path: Path) -> Path:
|
|
54
|
-
generate_shp_file(h5_path)
|
|
55
|
-
return h5_path
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def test_writer_basics(h5_path: Path) -> None:
|
|
59
|
-
generate_shp_file(h5_path)
|
|
60
|
-
with Reader(h5_path, verbose=True) as file:
|
|
61
|
-
assert round(file.runtime_s) == 2
|
|
62
|
-
assert file.get_window_samples() == 0
|
|
63
|
-
assert file.get_mode() == "harvester"
|
|
64
|
-
assert file.get_config() == {}
|
|
65
|
-
assert file.get_datatype() == "ivsample"
|
|
66
|
-
assert file.get_hostname() == "unknown"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def test_writer_compression_1(h5_path: Path) -> None:
|
|
70
|
-
generate_shp_file(h5_path, compression=Compression.gzip1)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def test_writer_unique_path(h5_file: Path) -> None:
|
|
74
|
-
with Writer(h5_file) as sfw:
|
|
75
|
-
assert sfw.file_path != h5_path
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def test_writer_faulty_mode(h5_path: Path) -> None:
|
|
79
|
-
with pytest.raises(ValueError):
|
|
80
|
-
generate_shp_file(h5_path, mode="excavator", datatype="ivcurve")
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def test_writer_faulty_datatype(h5_path: Path) -> None:
|
|
84
|
-
with pytest.raises(ValueError):
|
|
85
|
-
generate_shp_file(h5_path, mode="emulator", datatype="ivcurve")
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def test_writer_faulty_path(tmp_path: Path) -> None:
|
|
89
|
-
with pytest.raises(TypeError):
|
|
90
|
-
generate_shp_file(tmp_path)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def test_writer_modify(h5_file: Path) -> None:
|
|
94
|
-
with Writer(h5_file, modify_existing=True) as sfw:
|
|
95
|
-
sfw.store_hostname("sheep")
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def test_writer_init_cal_emu(h5_path: Path) -> None:
|
|
99
|
-
generate_shp_file(h5_path, cal_data=CalEmu())
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def test_writer_init_cal_hrv(h5_path: Path) -> None:
|
|
103
|
-
generate_shp_file(h5_path, cal_data=CalHrv())
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def test_writer_init_cal_series(h5_path: Path) -> None:
|
|
107
|
-
cs = CalSeries.from_cal(CalHrv())
|
|
108
|
-
generate_shp_file(h5_path, cal_data=cs)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def test_writer_faulty_window(h5_path: Path) -> None:
|
|
112
|
-
with pytest.raises(ValueError):
|
|
113
|
-
generate_shp_file(h5_path, mode="harvester", datatype="ivcurve")
|
|
114
|
-
with pytest.raises(ValueError):
|
|
115
|
-
generate_shp_file(
|
|
116
|
-
h5_path,
|
|
117
|
-
mode="harvester",
|
|
118
|
-
datatype="ivcurve",
|
|
119
|
-
window_samples=0,
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def test_writer_append_raw(h5_path: Path) -> None:
|
|
124
|
-
with Writer(h5_path) as sfw:
|
|
125
|
-
data_nd = np.zeros((sfw.samples_per_buffer,))
|
|
126
|
-
time_float = 5.5
|
|
127
|
-
time_int = 3
|
|
128
|
-
time_nd = 3 + data_nd
|
|
129
|
-
sfw.append_iv_data_raw(time_float, data_nd, data_nd)
|
|
130
|
-
sfw.append_iv_data_raw(time_int, data_nd, data_nd)
|
|
131
|
-
sfw.append_iv_data_raw(time_nd, data_nd, data_nd)
|
|
132
|
-
with pytest.raises(ValueError):
|
|
133
|
-
sfw.append_iv_data_raw(None, data_nd, data_nd)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def test_writer_align(h5_path: Path) -> None:
|
|
137
|
-
with Writer(h5_path) as sfw:
|
|
138
|
-
length = int(5.5 * sfw.samples_per_buffer)
|
|
139
|
-
time_nd = np.arange(0, length * sfw.sample_interval_ns, sfw.sample_interval_ns)
|
|
140
|
-
data_nd = np.zeros((int(length),))
|
|
141
|
-
sfw.append_iv_data_raw(time_nd, data_nd, data_nd)
|
|
142
|
-
with Reader(h5_path) as sfr:
|
|
143
|
-
assert sfr.ds_voltage.size < length
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def test_writer_not_align(h5_path: Path) -> None:
|
|
147
|
-
with Writer(h5_path) as sfw:
|
|
148
|
-
length = int(5.5 * sfw.samples_per_buffer)
|
|
149
|
-
sample_interval = 10 * sfw.sample_interval_ns
|
|
150
|
-
time_nd = np.arange(0, length * sample_interval, sample_interval)
|
|
151
|
-
data_nd = np.zeros((int(length),))
|
|
152
|
-
sfw.append_iv_data_raw(time_nd, data_nd, data_nd)
|
|
153
|
-
with Reader(h5_path) as sfr:
|
|
154
|
-
assert sfr.ds_voltage.size == length
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def test_writer_setter(h5_path: Path) -> None:
|
|
158
|
-
name = "pingu"
|
|
159
|
-
with Writer(h5_path) as sfw:
|
|
160
|
-
sfw["hostname"] = name
|
|
161
|
-
with Reader(h5_path) as sfr:
|
|
162
|
-
assert sfr.get_hostname() == name
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
# TODO:
|
|
166
|
-
# - test writing different and confirming them
|
|
167
|
-
# - different compressions and their size relative to each other
|
|
168
|
-
# - also invalid
|
|
169
|
-
# - read raw-data
|
tests/testbed_client/__init__.py
DELETED
|
File without changes
|
tests/vsource/__init__.py
DELETED
|
File without changes
|
tests/vsource/conftest.py
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
|
|
6
|
-
from shepherd_data import ivonne
|
|
7
|
-
from shepherd_data import mppt
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@pytest.fixture
|
|
11
|
-
def file_ivonne() -> Path:
|
|
12
|
-
path = Path(__file__).resolve().parent.parent.parent.parent / "shepherd_data/examples"
|
|
13
|
-
os.chdir(path)
|
|
14
|
-
return path / "./jogging_10m.iv"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@pytest.fixture
|
|
18
|
-
def file_isc_voc(file_ivonne: Path) -> Path:
|
|
19
|
-
path = file_ivonne.parent / "jogging_10m_isc_voc.h5"
|
|
20
|
-
if not path.exists():
|
|
21
|
-
with ivonne.Reader(file_ivonne) as db:
|
|
22
|
-
db.upsample_2_isc_voc(path, duration_s=1)
|
|
23
|
-
return path
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@pytest.fixture
|
|
27
|
-
def file_ivcurve(file_ivonne: Path) -> Path:
|
|
28
|
-
path = file_ivonne.parent / "jogging_10m_ivcurve.h5"
|
|
29
|
-
if not path.exists():
|
|
30
|
-
with ivonne.Reader(file_ivonne) as db:
|
|
31
|
-
db.convert_2_ivcurves(path, duration_s=1)
|
|
32
|
-
return path
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@pytest.fixture
|
|
36
|
-
def file_ivsample(file_ivonne: Path) -> Path:
|
|
37
|
-
path = file_ivonne.parent / "jogging_10m_ivsample.h5"
|
|
38
|
-
if not path.exists():
|
|
39
|
-
with ivonne.Reader(file_ivonne) as db:
|
|
40
|
-
tr_opt = mppt.OptimalTracker()
|
|
41
|
-
db.convert_2_ivsamples(path, tracker=tr_opt, duration_s=1)
|
|
42
|
-
return path
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
@pytest.fixture
|
|
46
|
-
def file_cleanup(file_isc_voc: Path, file_ivcurve: Path, file_ivsample: Path) -> None:
|
|
47
|
-
file_isc_voc.unlink(missing_ok=True)
|
|
48
|
-
file_ivcurve.unlink(missing_ok=True)
|
|
49
|
-
file_ivsample.unlink(missing_ok=True)
|
tests/vsource/test_converter.py
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from typing import Optional
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
from pytest import approx
|
|
6
|
-
|
|
7
|
-
from shepherd_core import CalibrationEmulator
|
|
8
|
-
from shepherd_core import Reader
|
|
9
|
-
from shepherd_core.data_models import EnergyDType
|
|
10
|
-
from shepherd_core.data_models import VirtualSourceConfig
|
|
11
|
-
from shepherd_core.vsource import VirtualSourceModel
|
|
12
|
-
|
|
13
|
-
# virtual_converter_model gets tested below with vsrc_model
|
|
14
|
-
|
|
15
|
-
src_list = [
|
|
16
|
-
"direct",
|
|
17
|
-
"diode+capacitor",
|
|
18
|
-
"diode+resistor+capacitor",
|
|
19
|
-
"BQ25504",
|
|
20
|
-
"BQ25504s",
|
|
21
|
-
"BQ25570",
|
|
22
|
-
"BQ25570s",
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def src_model(
|
|
27
|
-
name: str,
|
|
28
|
-
dtype_in: EnergyDType = EnergyDType.ivsample,
|
|
29
|
-
window_size: Optional[int] = None,
|
|
30
|
-
) -> VirtualSourceModel:
|
|
31
|
-
src_config = VirtualSourceConfig(name=name)
|
|
32
|
-
cal_emu = CalibrationEmulator()
|
|
33
|
-
return VirtualSourceModel(
|
|
34
|
-
src_config,
|
|
35
|
-
cal_emu,
|
|
36
|
-
log_intermediate=False,
|
|
37
|
-
dtype_in=dtype_in,
|
|
38
|
-
window_size=window_size,
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def c_leak_fWs(src: VirtualSourceModel, iterations: int) -> float:
|
|
43
|
-
return iterations * src.cnv.V_mid_uV * src.cfg_src.I_intermediate_leak_nA
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
@pytest.mark.parametrize("src_name", src_list)
|
|
47
|
-
def test_vsource_vsrc_min(src_name: str) -> None:
|
|
48
|
-
src = src_model(src_name)
|
|
49
|
-
src.iterate_sampling()
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def test_vsource_vsrc_static1() -> None:
|
|
53
|
-
iterations = 2_000
|
|
54
|
-
src = src_model("BQ25504")
|
|
55
|
-
for _ in range(iterations):
|
|
56
|
-
src.iterate_sampling(V_inp_uV=3_000_000, I_inp_nA=0)
|
|
57
|
-
assert src.W_inp_fWs == 0.0
|
|
58
|
-
assert src.W_out_fWs == approx(c_leak_fWs(src, iterations), rel=1e-4, abs=1e-6)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def test_vsource_vsrc_static2() -> None:
|
|
62
|
-
iterations = 2_000
|
|
63
|
-
src = src_model("BQ25504")
|
|
64
|
-
for _ in range(iterations):
|
|
65
|
-
src.iterate_sampling(V_inp_uV=0, I_inp_nA=3_000_000)
|
|
66
|
-
assert src.W_inp_fWs == 0.0
|
|
67
|
-
assert src.W_out_fWs == approx(c_leak_fWs(src, iterations), rel=1e-4, abs=1e-6)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@pytest.mark.parametrize("src_name", src_list[2:])
|
|
71
|
-
def test_vsource_charge(src_name: str) -> None:
|
|
72
|
-
iterations = 4_000
|
|
73
|
-
src = src_model(src_name)
|
|
74
|
-
for v_mV in range(iterations):
|
|
75
|
-
src.iterate_sampling(V_inp_uV=v_mV * 1000, I_inp_nA=1_000_000)
|
|
76
|
-
v_out = src.iterate_sampling(V_inp_uV=1_000_000, I_inp_nA=1_000_000)
|
|
77
|
-
assert src.W_inp_fWs > 0.0
|
|
78
|
-
assert src.W_out_fWs == approx(c_leak_fWs(src, iterations), rel=0.12, abs=1e-3)
|
|
79
|
-
assert v_out > 0.0
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
@pytest.mark.parametrize("src_name", src_list[4:])
|
|
83
|
-
def test_vsource_drain(src_name: str) -> None:
|
|
84
|
-
iterations = 4_000
|
|
85
|
-
src = src_model(src_name)
|
|
86
|
-
for c_uA in range(iterations):
|
|
87
|
-
src.iterate_sampling(I_out_nA=c_uA * 1000)
|
|
88
|
-
v_out = src.iterate_sampling()
|
|
89
|
-
assert src.W_inp_fWs == 0.0
|
|
90
|
-
assert src.W_out_fWs > c_leak_fWs(src, iterations)
|
|
91
|
-
assert v_out >= 0.0
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def test_vsource_vsrc_over_voltage() -> None:
|
|
95
|
-
iterations = 100
|
|
96
|
-
src = src_model("BQ25504")
|
|
97
|
-
for _ in range(iterations):
|
|
98
|
-
src.iterate_sampling(V_inp_uV=10 * 10**6, I_inp_nA=3_000_000)
|
|
99
|
-
assert src.cnv.V_input_uV <= 5 * 10**6
|
|
100
|
-
assert src.W_inp_fWs > 0.0
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def test_vsource_vsrc_over_current() -> None:
|
|
104
|
-
iterations = 100
|
|
105
|
-
src = src_model("BQ25504")
|
|
106
|
-
for _ in range(iterations):
|
|
107
|
-
src.iterate_sampling(V_inp_uV=5 * 10**6, I_inp_nA=100 * 10**6)
|
|
108
|
-
assert src.W_inp_fWs > 0.0
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def test_vsource_vsrc_cycle() -> None:
|
|
112
|
-
iterations = 2000
|
|
113
|
-
src = src_model("BQ25504s")
|
|
114
|
-
|
|
115
|
-
for _ in range(iterations):
|
|
116
|
-
src.iterate_sampling(V_inp_uV=5 * 10**6, I_inp_nA=4 * 10**6)
|
|
117
|
-
v_out = src.iterate_sampling()
|
|
118
|
-
assert v_out > 0
|
|
119
|
-
|
|
120
|
-
for _ in range(iterations):
|
|
121
|
-
src.iterate_sampling(I_out_nA=40 * 10**6)
|
|
122
|
-
v_out = src.iterate_sampling()
|
|
123
|
-
assert v_out == 0
|
|
124
|
-
|
|
125
|
-
for _ in range(iterations):
|
|
126
|
-
src.iterate_sampling(V_inp_uV=5 * 10**6, I_inp_nA=4 * 10**6)
|
|
127
|
-
v_out = src.iterate_sampling()
|
|
128
|
-
assert v_out > 0
|
|
129
|
-
|
|
130
|
-
assert src.W_out_fWs > 3 * c_leak_fWs(src, iterations)
|
|
131
|
-
assert src.W_inp_fWs > src.W_out_fWs
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
def test_vsource_vsrc_create_files(
|
|
135
|
-
file_ivcurve: Path, file_ivsample: Path, file_isc_voc: Path
|
|
136
|
-
) -> None:
|
|
137
|
-
pass
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
@pytest.mark.parametrize("src_name", src_list)
|
|
141
|
-
def test_vsource_vsrc_sim_curve(src_name: str, file_ivcurve: Path) -> None:
|
|
142
|
-
with Reader(file_ivcurve) as file:
|
|
143
|
-
window_size = file.get_window_samples()
|
|
144
|
-
dtype = file.get_datatype()
|
|
145
|
-
src = src_model("BQ25504s", dtype_in=dtype, window_size=window_size)
|
|
146
|
-
for _t, _v, _i in file.read_buffers():
|
|
147
|
-
length = max(_v.size, _i.size)
|
|
148
|
-
for _n in range(length):
|
|
149
|
-
src.iterate_sampling(V_inp_uV=_v[_n] * 10**6, I_inp_nA=_i[_n] * 10**9)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
@pytest.mark.parametrize("src_name", src_list)
|
|
153
|
-
def test_vsource_vsrc_sim_sample(src_name: str, file_ivsample: Path) -> None:
|
|
154
|
-
with Reader(file_ivsample) as file:
|
|
155
|
-
window_size = file.get_window_samples()
|
|
156
|
-
dtype = file.get_datatype()
|
|
157
|
-
src = src_model("BQ25504s", dtype_in=dtype, window_size=window_size)
|
|
158
|
-
for _t, _v, _i in file.read_buffers():
|
|
159
|
-
length = max(_v.size, _i.size)
|
|
160
|
-
for _n in range(length):
|
|
161
|
-
src.iterate_sampling(V_inp_uV=_v[_n] * 10**6, I_inp_nA=_i[_n] * 10**9)
|
tests/vsource/test_harvester.py
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from shepherd_core import Reader
|
|
6
|
-
from shepherd_core.data_models import EnergyDType
|
|
7
|
-
from shepherd_core.data_models import VirtualHarvesterConfig
|
|
8
|
-
from shepherd_core.data_models.content.virtual_harvester import HarvesterPRUConfig
|
|
9
|
-
from shepherd_core.vsource import VirtualHarvesterModel
|
|
10
|
-
|
|
11
|
-
hrv_list = [
|
|
12
|
-
"ivcurve",
|
|
13
|
-
"iv1000",
|
|
14
|
-
"isc_voc",
|
|
15
|
-
"cv20",
|
|
16
|
-
"mppt_voc",
|
|
17
|
-
"mppt_bq",
|
|
18
|
-
"mppt_bq_solar",
|
|
19
|
-
"mppt_po",
|
|
20
|
-
"mppt_opt",
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@pytest.mark.parametrize("hrv_name", hrv_list)
|
|
25
|
-
def test_vsource_hrv_min(hrv_name: str) -> None:
|
|
26
|
-
hrv_config = VirtualHarvesterConfig(name=hrv_name)
|
|
27
|
-
hrv_pru = HarvesterPRUConfig.from_vhrv(hrv_config)
|
|
28
|
-
_ = VirtualHarvesterModel(hrv_pru)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def test_vsource_hrv_create_files(
|
|
32
|
-
file_ivcurve: Path, file_ivsample: Path, file_isc_voc: Path
|
|
33
|
-
) -> None:
|
|
34
|
-
pass
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@pytest.mark.parametrize("hrv_name", hrv_list[:3])
|
|
38
|
-
def test_vsource_hrv_fail_ivcurve(hrv_name: str) -> None:
|
|
39
|
-
# the first algos are not usable for ivcurve
|
|
40
|
-
with pytest.raises(ValueError):
|
|
41
|
-
hrv_config = VirtualHarvesterConfig(name=hrv_name)
|
|
42
|
-
_ = HarvesterPRUConfig.from_vhrv(hrv_config, for_emu=True, dtype_in=EnergyDType.ivcurve)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
@pytest.mark.parametrize("hrv_name", hrv_list[3:])
|
|
46
|
-
def test_vsource_hrv_sim(hrv_name: str, file_ivcurve: Path) -> None:
|
|
47
|
-
with Reader(file_ivcurve) as file:
|
|
48
|
-
hrv_config = VirtualHarvesterConfig(name=hrv_name)
|
|
49
|
-
hrv_pru = HarvesterPRUConfig.from_vhrv(
|
|
50
|
-
hrv_config,
|
|
51
|
-
for_emu=True,
|
|
52
|
-
dtype_in=file.get_datatype(),
|
|
53
|
-
window_size=file.get_window_samples(),
|
|
54
|
-
)
|
|
55
|
-
hrv = VirtualHarvesterModel(hrv_pru)
|
|
56
|
-
for _t, _v, _i in file.read_buffers():
|
|
57
|
-
length = max(_v.size, _i.size)
|
|
58
|
-
for _n in range(length):
|
|
59
|
-
hrv.ivcurve_sample(_voltage_uV=_v[_n] * 10**6, _current_nA=_i[_n] * 10**9)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
@pytest.mark.parametrize("hrv_name", hrv_list[3:])
|
|
63
|
-
def test_vsource_hrv_fail_isc_voc(hrv_name: str) -> None:
|
|
64
|
-
# not implemented ATM
|
|
65
|
-
with pytest.raises(ValueError):
|
|
66
|
-
hrv_config = VirtualHarvesterConfig(name=hrv_name)
|
|
67
|
-
_ = HarvesterPRUConfig.from_vhrv(hrv_config, for_emu=True, dtype_in=EnergyDType.isc_voc)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def test_vsource_hrv_fail_unknown_type() -> None:
|
|
71
|
-
with pytest.raises(KeyError):
|
|
72
|
-
hrv_config = VirtualHarvesterConfig(name="mppt_voc")
|
|
73
|
-
_ = HarvesterPRUConfig.from_vhrv(hrv_config, for_emu=True, dtype_in="xyz")
|
tests/vsource/test_z.py
DELETED
|
File without changes
|