shepherd-data 2023.11.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_data/__init__.py +2 -1
- shepherd_data/cli.py +20 -43
- shepherd_data/debug_resampler.py +1 -3
- shepherd_data/ivonne.py +20 -41
- shepherd_data/mppt.py +24 -22
- shepherd_data/reader.py +45 -67
- shepherd_data-2024.4.1.dist-info/METADATA +88 -0
- shepherd_data-2024.4.1.dist-info/RECORD +12 -0
- {shepherd_data-2023.11.1.dist-info → shepherd_data-2024.4.1.dist-info}/WHEEL +1 -1
- {shepherd_data-2023.11.1.dist-info → shepherd_data-2024.4.1.dist-info}/top_level.txt +0 -1
- shepherd_data-2023.11.1.dist-info/METADATA +0 -274
- shepherd_data-2023.11.1.dist-info/RECORD +0 -22
- tests/__init__.py +0 -0
- tests/conftest.py +0 -33
- tests/test_cli.py +0 -8
- tests/test_cli_downsample.py +0 -51
- tests/test_cli_extract.py +0 -84
- tests/test_cli_plot.py +0 -128
- tests/test_cli_validate.py +0 -15
- tests/test_examples.py +0 -26
- tests/test_ivonne.py +0 -42
- tests/test_reader.py +0 -3
- {shepherd_data-2023.11.1.dist-info → shepherd_data-2024.4.1.dist-info}/entry_points.txt +0 -0
- {shepherd_data-2023.11.1.dist-info → shepherd_data-2024.4.1.dist-info}/zip-safe +0 -0
tests/conftest.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
import pytest
|
|
5
|
-
|
|
6
|
-
from shepherd_core import Compression
|
|
7
|
-
from shepherd_data import Writer
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def generate_h5_file(file_path: Path, file_name: str = "harvest_example.h5") -> Path:
|
|
11
|
-
store_path = file_path / file_name
|
|
12
|
-
|
|
13
|
-
with Writer(store_path, compression=Compression.gzip1) as file:
|
|
14
|
-
file.store_hostname("artificial")
|
|
15
|
-
|
|
16
|
-
duration_s = 2
|
|
17
|
-
repetitions = 5
|
|
18
|
-
timestamp_vector = np.arange(0.0, duration_s, file.sample_interval_ns / 1e9)
|
|
19
|
-
|
|
20
|
-
# values in SI units
|
|
21
|
-
voltages = np.linspace(3.60, 1.90, int(file.samplerate_sps * duration_s))
|
|
22
|
-
currents = np.linspace(100e-6, 2000e-6, int(file.samplerate_sps * duration_s))
|
|
23
|
-
|
|
24
|
-
for idx in range(repetitions):
|
|
25
|
-
timestamps = idx * duration_s + timestamp_vector
|
|
26
|
-
file.append_iv_data_si(timestamps, voltages, currents)
|
|
27
|
-
|
|
28
|
-
return store_path
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
@pytest.fixture
|
|
32
|
-
def data_h5(tmp_path: Path) -> Path:
|
|
33
|
-
return generate_h5_file(tmp_path)
|
tests/test_cli.py
DELETED
tests/test_cli_downsample.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
from click.testing import CliRunner
|
|
4
|
-
|
|
5
|
-
from shepherd_data.cli import cli
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def test_cli_downsample_file_full(data_h5: Path) -> None:
|
|
9
|
-
res = CliRunner().invoke(
|
|
10
|
-
cli, ["--verbose", "downsample", "--ds-factor", "10", str(data_h5)]
|
|
11
|
-
)
|
|
12
|
-
assert res.exit_code == 0
|
|
13
|
-
assert data_h5.with_suffix(".downsampled_x10.h5").exists()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_cli_downsample_file_short(data_h5: Path) -> None:
|
|
17
|
-
res = CliRunner().invoke(cli, ["-v", "downsample", "-f", "20", str(data_h5)])
|
|
18
|
-
assert res.exit_code == 0
|
|
19
|
-
assert data_h5.with_suffix(".downsampled_x20.h5").exists()
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def test_cli_downsample_file_min(data_h5: Path) -> None:
|
|
23
|
-
res = CliRunner().invoke(cli, ["--verbose", "downsample", str(data_h5)])
|
|
24
|
-
assert res.exit_code == 0
|
|
25
|
-
assert data_h5.with_suffix(".downsampled_x5.h5").exists()
|
|
26
|
-
assert data_h5.with_suffix(".downsampled_x25.h5").exists()
|
|
27
|
-
assert data_h5.with_suffix(".downsampled_x100.h5").exists()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def test_cli_downsample_dir_full(data_h5: Path) -> None:
|
|
31
|
-
print(data_h5.parent)
|
|
32
|
-
print(data_h5.parent.is_dir())
|
|
33
|
-
res = CliRunner().invoke(
|
|
34
|
-
cli, ["--verbose", "downsample", "--ds-factor", "40", str(data_h5.parent)]
|
|
35
|
-
)
|
|
36
|
-
assert res.exit_code == 0
|
|
37
|
-
assert data_h5.with_suffix(".downsampled_x40.h5").exists()
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def test_cli_downsample_rate_file_full(data_h5: Path) -> None:
|
|
41
|
-
res = CliRunner().invoke(
|
|
42
|
-
cli, ["--verbose", "downsample", "--sample-rate", "100", str(data_h5)]
|
|
43
|
-
)
|
|
44
|
-
assert res.exit_code == 0
|
|
45
|
-
assert data_h5.with_suffix(".downsampled_x1000.h5").exists()
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def test_cli_downsample_rate_file_short(data_h5: Path) -> None:
|
|
49
|
-
res = CliRunner().invoke(cli, ["-v", "downsample", "-r", "200", str(data_h5)])
|
|
50
|
-
assert res.exit_code == 0
|
|
51
|
-
assert data_h5.with_suffix(".downsampled_x500.h5").exists()
|
tests/test_cli_extract.py
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
from click.testing import CliRunner
|
|
4
|
-
|
|
5
|
-
from shepherd_data.cli import cli
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def test_cli_extract_file_full(data_h5: Path) -> None:
|
|
9
|
-
res = CliRunner().invoke(
|
|
10
|
-
cli,
|
|
11
|
-
[
|
|
12
|
-
"--verbose",
|
|
13
|
-
"extract",
|
|
14
|
-
"--ds-factor",
|
|
15
|
-
"100",
|
|
16
|
-
"--separator",
|
|
17
|
-
",",
|
|
18
|
-
str(data_h5),
|
|
19
|
-
],
|
|
20
|
-
)
|
|
21
|
-
assert res.exit_code == 0
|
|
22
|
-
assert data_h5.with_suffix(".downsampled_x100.h5").exists()
|
|
23
|
-
assert data_h5.with_suffix(".downsampled_x100.data.csv").exists()
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def test_cli_extract_file_short(data_h5: Path) -> None:
|
|
27
|
-
res = CliRunner().invoke(
|
|
28
|
-
cli, ["-v", "extract", "-f", "200", "-s", ";", str(data_h5)]
|
|
29
|
-
)
|
|
30
|
-
assert res.exit_code == 0
|
|
31
|
-
assert data_h5.with_suffix(".downsampled_x200.h5").exists()
|
|
32
|
-
assert data_h5.with_suffix(".downsampled_x200.data.csv").exists()
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def test_cli_extract_file_min(data_h5: Path) -> None:
|
|
36
|
-
res = CliRunner().invoke(cli, ["-v", "extract", str(data_h5)])
|
|
37
|
-
assert res.exit_code == 0
|
|
38
|
-
assert data_h5.with_suffix(".downsampled_x1000.h5").exists()
|
|
39
|
-
assert data_h5.with_suffix(".downsampled_x1000.data.csv").exists()
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def test_cli_extract_dir_full(data_h5: Path) -> None:
|
|
43
|
-
print(data_h5.parent)
|
|
44
|
-
print(data_h5.parent.is_dir())
|
|
45
|
-
res = CliRunner().invoke(
|
|
46
|
-
cli,
|
|
47
|
-
[
|
|
48
|
-
"--verbose",
|
|
49
|
-
"extract",
|
|
50
|
-
"--ds-factor",
|
|
51
|
-
"2000",
|
|
52
|
-
"--separator",
|
|
53
|
-
";",
|
|
54
|
-
str(data_h5.parent),
|
|
55
|
-
],
|
|
56
|
-
)
|
|
57
|
-
assert res.exit_code == 0
|
|
58
|
-
assert data_h5.with_suffix(".downsampled_x2000.h5").exists()
|
|
59
|
-
assert data_h5.with_suffix(".downsampled_x2000.data.csv").exists()
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def test_cli_extract_meta_file_full(data_h5: Path) -> None:
|
|
63
|
-
res = CliRunner().invoke(
|
|
64
|
-
cli, ["--verbose", "extract-meta", "--separator", ";", str(data_h5)]
|
|
65
|
-
)
|
|
66
|
-
assert res.exit_code == 0
|
|
67
|
-
# TODO: nothing to grab here, add in base-file, same for tests below
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def test_cli_extract_meta_file_short(data_h5: Path) -> None:
|
|
71
|
-
res = CliRunner().invoke(cli, ["-v", "extract-meta", "-s", "-", str(data_h5)])
|
|
72
|
-
assert res.exit_code == 0
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def test_cli_extract_meta_file_min(data_h5: Path) -> None:
|
|
76
|
-
res = CliRunner().invoke(cli, ["-v", "extract-meta", "-s", "-", str(data_h5)])
|
|
77
|
-
assert res.exit_code == 0
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def test_cli_extract_meta_dir_full(data_h5: Path) -> None:
|
|
81
|
-
res = CliRunner().invoke(
|
|
82
|
-
cli, ["--verbose", "extract-meta", "--separator", ";", str(data_h5.parent)]
|
|
83
|
-
)
|
|
84
|
-
assert res.exit_code == 0
|
tests/test_cli_plot.py
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
from click.testing import CliRunner
|
|
4
|
-
|
|
5
|
-
from shepherd_data.cli import cli
|
|
6
|
-
|
|
7
|
-
from .conftest import generate_h5_file
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def test_cli_plot_file_full(data_h5: Path) -> None:
|
|
11
|
-
res = CliRunner().invoke(
|
|
12
|
-
cli,
|
|
13
|
-
[
|
|
14
|
-
"--verbose",
|
|
15
|
-
"plot",
|
|
16
|
-
"--start",
|
|
17
|
-
"0",
|
|
18
|
-
"--end",
|
|
19
|
-
"8",
|
|
20
|
-
"--width",
|
|
21
|
-
"50",
|
|
22
|
-
"--height",
|
|
23
|
-
"10",
|
|
24
|
-
str(data_h5),
|
|
25
|
-
],
|
|
26
|
-
)
|
|
27
|
-
assert res.exit_code == 0
|
|
28
|
-
assert data_h5.with_suffix(".plot_0s000_to_8s000.png").exists()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def test_cli_plot_file_short(data_h5: Path) -> None:
|
|
32
|
-
res = CliRunner().invoke(
|
|
33
|
-
cli,
|
|
34
|
-
[
|
|
35
|
-
"-v",
|
|
36
|
-
"plot",
|
|
37
|
-
"-s",
|
|
38
|
-
"2.345",
|
|
39
|
-
"-e",
|
|
40
|
-
"8.765",
|
|
41
|
-
"-w",
|
|
42
|
-
"30",
|
|
43
|
-
"-h",
|
|
44
|
-
"20",
|
|
45
|
-
str(data_h5),
|
|
46
|
-
],
|
|
47
|
-
)
|
|
48
|
-
assert res.exit_code == 0
|
|
49
|
-
assert data_h5.with_suffix(".plot_2s345_to_8s765.png").exists()
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def test_cli_plot_file_min(data_h5: Path) -> None:
|
|
53
|
-
res = CliRunner().invoke(cli, ["-v", "plot", str(data_h5)])
|
|
54
|
-
assert res.exit_code == 0
|
|
55
|
-
assert data_h5.with_suffix(
|
|
56
|
-
".plot_0s000_to_10s000.png"
|
|
57
|
-
).exists() # full duration of file
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def test_cli_plot_dir_min(tmp_path: Path) -> None:
|
|
61
|
-
file1_path = generate_h5_file(tmp_path, "hrv_file1.h5")
|
|
62
|
-
file2_path = generate_h5_file(tmp_path, "hrv_file2.h5")
|
|
63
|
-
res = CliRunner().invoke(cli, ["-v", "plot", str(tmp_path.resolve())])
|
|
64
|
-
assert res.exit_code == 0
|
|
65
|
-
assert file1_path.with_suffix(
|
|
66
|
-
".plot_0s000_to_10s000.png"
|
|
67
|
-
).exists() # full duration of file
|
|
68
|
-
assert file2_path.with_suffix(
|
|
69
|
-
".plot_0s000_to_10s000.png"
|
|
70
|
-
).exists() # full duration of file
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def test_cli_multiplot_dir_full(tmp_path: Path) -> None:
|
|
74
|
-
generate_h5_file(tmp_path, "hrv_file1.h5")
|
|
75
|
-
generate_h5_file(tmp_path, "hrv_file2.h5")
|
|
76
|
-
res = CliRunner().invoke(
|
|
77
|
-
cli,
|
|
78
|
-
[
|
|
79
|
-
"--verbose",
|
|
80
|
-
"plot",
|
|
81
|
-
"--start",
|
|
82
|
-
"1",
|
|
83
|
-
"--end",
|
|
84
|
-
"7",
|
|
85
|
-
"--width",
|
|
86
|
-
"40",
|
|
87
|
-
"--height",
|
|
88
|
-
"10",
|
|
89
|
-
"--multiplot",
|
|
90
|
-
str(tmp_path),
|
|
91
|
-
],
|
|
92
|
-
)
|
|
93
|
-
assert res.exit_code == 0
|
|
94
|
-
assert tmp_path.with_suffix(".multiplot_1s000_to_7s000.png").exists()
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def test_cli_multiplot_dir_short(tmp_path: Path) -> None:
|
|
98
|
-
generate_h5_file(tmp_path, "hrv_file1.h5")
|
|
99
|
-
generate_h5_file(tmp_path, "hrv_file2.h5")
|
|
100
|
-
res = CliRunner().invoke(
|
|
101
|
-
cli,
|
|
102
|
-
[
|
|
103
|
-
"-v",
|
|
104
|
-
"plot",
|
|
105
|
-
"-s",
|
|
106
|
-
"2.345",
|
|
107
|
-
"-e",
|
|
108
|
-
"8.765",
|
|
109
|
-
"-w",
|
|
110
|
-
"30",
|
|
111
|
-
"-h",
|
|
112
|
-
"20",
|
|
113
|
-
"-m",
|
|
114
|
-
str(tmp_path),
|
|
115
|
-
],
|
|
116
|
-
)
|
|
117
|
-
assert res.exit_code == 0
|
|
118
|
-
assert tmp_path.with_suffix(".multiplot_2s345_to_8s765.png").exists()
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def test_cli_multiplot_dir_min(tmp_path: Path) -> None:
|
|
122
|
-
generate_h5_file(tmp_path, "hrv_file1.h5")
|
|
123
|
-
generate_h5_file(tmp_path, "hrv_file2.h5")
|
|
124
|
-
res = CliRunner().invoke(cli, ["-v", "plot", "-m", str(tmp_path)])
|
|
125
|
-
assert res.exit_code == 0
|
|
126
|
-
assert tmp_path.with_suffix(
|
|
127
|
-
".multiplot_0s000_to_10s000.png"
|
|
128
|
-
).exists() # full duration of file
|
tests/test_cli_validate.py
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
from click.testing import CliRunner
|
|
4
|
-
|
|
5
|
-
from shepherd_data.cli import cli
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def test_cli_validate_file(data_h5: Path) -> None:
|
|
9
|
-
res = CliRunner().invoke(cli, ["-v", "validate", str(data_h5)])
|
|
10
|
-
assert res.exit_code == 0
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_cli_validate_dir(data_h5: Path) -> None:
|
|
14
|
-
res = CliRunner().invoke(cli, ["-v", "validate", str(data_h5.parent)])
|
|
15
|
-
assert res.exit_code == 0
|
tests/test_examples.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import subprocess
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
|
|
5
|
-
import pytest
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@pytest.fixture
|
|
9
|
-
def example_path() -> Path:
|
|
10
|
-
path = Path(__file__).resolve().parent.parent / "examples"
|
|
11
|
-
os.chdir(path)
|
|
12
|
-
return path
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
examples = [
|
|
16
|
-
"example_convert_ivonne.py",
|
|
17
|
-
"example_extract_logs.py",
|
|
18
|
-
"example_generate_sawtooth.py",
|
|
19
|
-
"example_plot_traces.py",
|
|
20
|
-
"example_repair_recordings.py",
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@pytest.mark.parametrize("file", examples)
|
|
25
|
-
def test_example_scripts(example_path: Path, file: str) -> None:
|
|
26
|
-
subprocess.check_call(f"python {example_path / file}", shell=True)
|
tests/test_ivonne.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from shepherd_data import Reader
|
|
6
|
-
from shepherd_data import ivonne
|
|
7
|
-
from shepherd_data import mppt
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@pytest.fixture
|
|
11
|
-
def example_path() -> Path:
|
|
12
|
-
here = Path(__file__).resolve().parent
|
|
13
|
-
return here.parent / "examples"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_convert_ivonne(tmp_path: Path, example_path: Path) -> None:
|
|
17
|
-
input_file = "jogging_10m"
|
|
18
|
-
inp_path = example_path / (input_file + ".iv")
|
|
19
|
-
isc_path = tmp_path / (input_file + "_isc.h5")
|
|
20
|
-
ivc_path = tmp_path / (input_file + "_ivc.h5")
|
|
21
|
-
voc_path = tmp_path / (input_file + "_voc.h5")
|
|
22
|
-
opt_path = tmp_path / (input_file + "_opt.h5")
|
|
23
|
-
|
|
24
|
-
with ivonne.Reader(inp_path) as ifr:
|
|
25
|
-
ifr.upsample_2_isc_voc(isc_path, duration_s=20)
|
|
26
|
-
ifr.convert_2_ivcurves(ivc_path, duration_s=20)
|
|
27
|
-
|
|
28
|
-
tr_voc = mppt.OpenCircuitTracker(ratio=0.76)
|
|
29
|
-
tr_opt = mppt.OptimalTracker()
|
|
30
|
-
|
|
31
|
-
ifr.convert_2_ivsamples(voc_path, tracker=tr_voc, duration_s=20)
|
|
32
|
-
ifr.convert_2_ivsamples(opt_path, tracker=tr_opt, duration_s=20)
|
|
33
|
-
|
|
34
|
-
energies = {}
|
|
35
|
-
for file_path in [isc_path, ivc_path, voc_path, opt_path]:
|
|
36
|
-
with Reader(file_path) as sfr:
|
|
37
|
-
assert sfr.runtime_s == 20
|
|
38
|
-
energies[file_path.stem[-3:]] = sfr.energy()
|
|
39
|
-
|
|
40
|
-
assert energies["isc"] > energies["opt"]
|
|
41
|
-
assert energies["opt"] > energies["voc"]
|
|
42
|
-
assert energies["voc"] > energies["ivc"]
|
tests/test_reader.py
DELETED
|
File without changes
|
|
File without changes
|