shepherd-data 2024.7.1__py3-none-any.whl → 2024.7.2__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 +1 -1
- shepherd_data/cli.py +15 -2
- shepherd_data/reader.py +21 -12
- {shepherd_data-2024.7.1.dist-info → shepherd_data-2024.7.2.dist-info}/METADATA +2 -2
- shepherd_data-2024.7.2.dist-info/RECORD +11 -0
- shepherd_data-2024.7.1.dist-info/RECORD +0 -11
- {shepherd_data-2024.7.1.dist-info → shepherd_data-2024.7.2.dist-info}/WHEEL +0 -0
- {shepherd_data-2024.7.1.dist-info → shepherd_data-2024.7.2.dist-info}/entry_points.txt +0 -0
- {shepherd_data-2024.7.1.dist-info → shepherd_data-2024.7.2.dist-info}/top_level.txt +0 -0
- {shepherd_data-2024.7.1.dist-info → shepherd_data-2024.7.2.dist-info}/zip-safe +0 -0
shepherd_data/__init__.py
CHANGED
shepherd_data/cli.py
CHANGED
|
@@ -119,6 +119,14 @@ def extract(in_data: Path, ds_factor: float, separator: str) -> None:
|
|
|
119
119
|
logger.info("Extracting IV-Samples from '%s' ...", file.name)
|
|
120
120
|
try:
|
|
121
121
|
with Reader(file, verbose=verbose_level > 2) as shpr:
|
|
122
|
+
# TODO: this code is very similar to data.reader.downsample()
|
|
123
|
+
if (shpr.ds_voltage.shape[0] / ds_factor) < 10:
|
|
124
|
+
logger.warning(
|
|
125
|
+
"will skip downsampling for %s because "
|
|
126
|
+
"resulting sample-size is too small",
|
|
127
|
+
file.name,
|
|
128
|
+
)
|
|
129
|
+
continue
|
|
122
130
|
# will create a downsampled h5-file (if not existing) and then saving to csv
|
|
123
131
|
ds_file = file.with_suffix(f".downsampled_x{round(ds_factor)}.h5")
|
|
124
132
|
if not ds_file.exists():
|
|
@@ -203,6 +211,8 @@ def extract_uart(in_data: Path) -> None:
|
|
|
203
211
|
with Reader(file, verbose=verbose_level > 2) as shpr:
|
|
204
212
|
# TODO: move into separate fn OR add to h5-file and use .save_log(), ALSO TEST
|
|
205
213
|
lines = shpr.gpio_to_uart()
|
|
214
|
+
if lines is None:
|
|
215
|
+
continue
|
|
206
216
|
# TODO: could also add parameter to get symbols instead of lines
|
|
207
217
|
log_path = Path(file).with_suffix(".uart_from_wf.log")
|
|
208
218
|
if log_path.exists():
|
|
@@ -280,7 +290,7 @@ def downsample(in_data: Path, ds_factor: Optional[float], sample_rate: Optional[
|
|
|
280
290
|
try:
|
|
281
291
|
with Reader(file, verbose=verbose_level > 2) as shpr:
|
|
282
292
|
for _factor in ds_list:
|
|
283
|
-
if shpr.ds_voltage.shape[0] / _factor < 1000:
|
|
293
|
+
if (shpr.ds_voltage.shape[0] / _factor) < 1000:
|
|
284
294
|
logger.warning(
|
|
285
295
|
"will skip downsampling for %s because "
|
|
286
296
|
"resulting sample-size is too small",
|
|
@@ -363,7 +373,10 @@ def plot(
|
|
|
363
373
|
try:
|
|
364
374
|
with Reader(file, verbose=verbose_level > 2) as shpr:
|
|
365
375
|
if multiplot:
|
|
366
|
-
|
|
376
|
+
date = shpr.generate_plot_data(start, end, relative_timestamp=True)
|
|
377
|
+
if date is None:
|
|
378
|
+
continue
|
|
379
|
+
data.append(date)
|
|
367
380
|
else:
|
|
368
381
|
shpr.plot_to_file(start, end, width, height)
|
|
369
382
|
except TypeError:
|
shepherd_data/reader.py
CHANGED
|
@@ -44,7 +44,7 @@ class Reader(CoreReader):
|
|
|
44
44
|
:param separator: used between columns
|
|
45
45
|
:return: number of processed entries
|
|
46
46
|
"""
|
|
47
|
-
if h5_group["time"].shape[0] < 1:
|
|
47
|
+
if ("time" not in h5_group) or (h5_group["time"].shape[0] < 1):
|
|
48
48
|
self._logger.warning("%s is empty, no csv generated", h5_group.name)
|
|
49
49
|
return 0
|
|
50
50
|
if not isinstance(self.file_path, Path):
|
|
@@ -80,7 +80,7 @@ class Reader(CoreReader):
|
|
|
80
80
|
:param add_timestamp: can be external
|
|
81
81
|
:return: number of processed entries
|
|
82
82
|
"""
|
|
83
|
-
if h5_group["time"].shape[0] < 1:
|
|
83
|
+
if ("time" not in h5_group) or (h5_group["time"].shape[0] < 1):
|
|
84
84
|
self._logger.warning("%s is empty, no log generated", h5_group.name)
|
|
85
85
|
return 0
|
|
86
86
|
if not isinstance(self.file_path, Path):
|
|
@@ -117,7 +117,7 @@ class Reader(CoreReader):
|
|
|
117
117
|
) -> int:
|
|
118
118
|
"""Print warning messages from log in data-group."""
|
|
119
119
|
_count = self.count_errors_in_log(group_name, min_level)
|
|
120
|
-
if _count < 1:
|
|
120
|
+
if (_count < 1) or ("level" not in self.h5file[group_name]):
|
|
121
121
|
return 0
|
|
122
122
|
if not show:
|
|
123
123
|
return _count
|
|
@@ -154,7 +154,7 @@ class Reader(CoreReader):
|
|
|
154
154
|
ds_factor: float = 5,
|
|
155
155
|
*,
|
|
156
156
|
is_time: bool = False,
|
|
157
|
-
) -> Union[h5py.Dataset, np.ndarray]:
|
|
157
|
+
) -> Union[None, h5py.Dataset, np.ndarray]:
|
|
158
158
|
"""Sample down iv-data.
|
|
159
159
|
|
|
160
160
|
Warning: only valid for IV-Stream, not IV-Curves
|
|
@@ -171,6 +171,7 @@ class Reader(CoreReader):
|
|
|
171
171
|
|
|
172
172
|
if self.get_datatype() == "ivcurve":
|
|
173
173
|
self._logger.warning("Downsampling-Function was not written for IVCurves")
|
|
174
|
+
return data_dst
|
|
174
175
|
ds_factor = max(1, math.floor(ds_factor))
|
|
175
176
|
|
|
176
177
|
if isinstance(end_n, (int, float)):
|
|
@@ -182,6 +183,7 @@ class Reader(CoreReader):
|
|
|
182
183
|
data_len = _end_n - start_n # TODO: one-off to calculation below ?
|
|
183
184
|
if data_len == 0:
|
|
184
185
|
self._logger.warning("downsampling failed because of data_len = 0")
|
|
186
|
+
return data_dst
|
|
185
187
|
iblock_len = min(self.max_elements, data_len)
|
|
186
188
|
oblock_len = round(iblock_len / ds_factor)
|
|
187
189
|
iterations = math.ceil(data_len / iblock_len)
|
|
@@ -233,7 +235,7 @@ class Reader(CoreReader):
|
|
|
233
235
|
samplerate_dst: float = 1000,
|
|
234
236
|
*,
|
|
235
237
|
is_time: bool = False,
|
|
236
|
-
) -> Union[h5py.Dataset, np.ndarray]:
|
|
238
|
+
) -> Union[None, h5py.Dataset, np.ndarray]:
|
|
237
239
|
"""Up- or down-sample the original trace-data.
|
|
238
240
|
|
|
239
241
|
:param data_src: original iv-data
|
|
@@ -247,7 +249,7 @@ class Reader(CoreReader):
|
|
|
247
249
|
self._logger.error("Resampling is still under construction - do not use for now!")
|
|
248
250
|
if self.get_datatype() == "ivcurve":
|
|
249
251
|
self._logger.warning("Resampling-Function was not written for IVCurves")
|
|
250
|
-
|
|
252
|
+
return data_dst
|
|
251
253
|
if isinstance(end_n, (int, float)):
|
|
252
254
|
_end_n = min(data_src.shape[0], round(end_n))
|
|
253
255
|
else:
|
|
@@ -257,11 +259,12 @@ class Reader(CoreReader):
|
|
|
257
259
|
data_len = _end_n - start_n
|
|
258
260
|
if data_len == 0:
|
|
259
261
|
self._logger.warning("resampling failed because of data_len = 0")
|
|
262
|
+
return data_dst
|
|
260
263
|
fs_ratio = samplerate_dst / self.samplerate_sps
|
|
261
264
|
dest_len = math.floor(data_len * fs_ratio) + 1
|
|
262
265
|
if fs_ratio <= 1.0: # down-sampling
|
|
263
266
|
slice_inp_len = min(self.max_elements, data_len)
|
|
264
|
-
slice_out_len = round(slice_inp_len * fs_ratio)
|
|
267
|
+
slice_out_len = round(slice_inp_len * fs_ratio) # TODO: is that correct?
|
|
265
268
|
else: # up-sampling
|
|
266
269
|
slice_out_len = min(self.max_elements, data_len * fs_ratio)
|
|
267
270
|
slice_inp_len = round(slice_out_len / fs_ratio)
|
|
@@ -332,7 +335,7 @@ class Reader(CoreReader):
|
|
|
332
335
|
end_s: Optional[float] = None,
|
|
333
336
|
*,
|
|
334
337
|
relative_timestamp: bool = True,
|
|
335
|
-
) -> Dict:
|
|
338
|
+
) -> Optional[Dict]:
|
|
336
339
|
"""Provide down-sampled iv-data that can be fed into plot_to_file().
|
|
337
340
|
|
|
338
341
|
:param start_s: time in seconds, relative to start of recording
|
|
@@ -341,13 +344,17 @@ class Reader(CoreReader):
|
|
|
341
344
|
:return: down-sampled size of ~ self.max_elements
|
|
342
345
|
"""
|
|
343
346
|
if self.get_datatype() == "ivcurve":
|
|
344
|
-
self._logger.warning("Plot-Function was not written for IVCurves")
|
|
347
|
+
self._logger.warning("Plot-Function was not written for IVCurves.")
|
|
348
|
+
return None
|
|
345
349
|
if not isinstance(start_s, (float, int)):
|
|
346
350
|
start_s = 0
|
|
347
351
|
if not isinstance(end_s, (float, int)):
|
|
348
352
|
end_s = self.runtime_s
|
|
349
353
|
start_sample = round(start_s * self.samplerate_sps)
|
|
350
354
|
end_sample = round(end_s * self.samplerate_sps)
|
|
355
|
+
if end_sample - start_sample < 5:
|
|
356
|
+
self._logger.warning("Skip plot, because of small sample-size.")
|
|
357
|
+
return None
|
|
351
358
|
samplerate_dst = max(round(self.max_elements / (end_s - start_s), 3), 0.001)
|
|
352
359
|
ds_factor = float(self.samplerate_sps / samplerate_dst)
|
|
353
360
|
data = {
|
|
@@ -422,10 +429,12 @@ class Reader(CoreReader):
|
|
|
422
429
|
if not isinstance(self.file_path, Path):
|
|
423
430
|
return
|
|
424
431
|
|
|
425
|
-
data =
|
|
432
|
+
data = self.generate_plot_data(start_s, end_s)
|
|
433
|
+
if data is None:
|
|
434
|
+
return
|
|
426
435
|
|
|
427
|
-
start_str = f"{data[
|
|
428
|
-
end_str = f"{data[
|
|
436
|
+
start_str = f"{data['start_s']:.3f}".replace(".", "s")
|
|
437
|
+
end_str = f"{data['end_s']:.3f}".replace(".", "s")
|
|
429
438
|
plot_path = self.file_path.resolve().with_suffix(f".plot_{start_str}_to_{end_str}.png")
|
|
430
439
|
if plot_path.exists():
|
|
431
440
|
self._logger.warning("Plot exists, will skip & not overwrite!")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: shepherd_data
|
|
3
|
-
Version: 2024.7.
|
|
3
|
+
Version: 2024.7.2
|
|
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>
|
|
@@ -35,7 +35,7 @@ Requires-Dist: numpy
|
|
|
35
35
|
Requires-Dist: pandas >=2.0.0
|
|
36
36
|
Requires-Dist: pyYAML
|
|
37
37
|
Requires-Dist: scipy
|
|
38
|
-
Requires-Dist: shepherd-core[inventory] >=2024.7.
|
|
38
|
+
Requires-Dist: shepherd-core[inventory] >=2024.7.2
|
|
39
39
|
Requires-Dist: tqdm
|
|
40
40
|
Provides-Extra: dev
|
|
41
41
|
Requires-Dist: shepherd-core[dev] ; extra == 'dev'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
shepherd_data/__init__.py,sha256=kbHJcBM_nHRN51web7bn50DBWak8vV1VqEK7KYeW9mQ,352
|
|
2
|
+
shepherd_data/cli.py,sha256=p_SS_LRn6PxvIJRqpubCWM-qw2GCsn24evrdCCtynfY,15589
|
|
3
|
+
shepherd_data/ivonne.py,sha256=5EryExMQ8E8PTgX5xkZUyLqhvhCcLT17rdC0POv4NLI,11831
|
|
4
|
+
shepherd_data/mppt.py,sha256=588KSrLuJfNRKKnnL6ewePLi3zrwaO_PAZypikACrks,3925
|
|
5
|
+
shepherd_data/reader.py,sha256=Sh33PlaafGGXVr8n2I7pM-b-vmkxYhJALsmBfpUbvHc,19000
|
|
6
|
+
shepherd_data-2024.7.2.dist-info/METADATA,sha256=Z6AFosmQiXEkdM-845BApEiFQXnbM7EHTAgotoTLC1U,3387
|
|
7
|
+
shepherd_data-2024.7.2.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
|
|
8
|
+
shepherd_data-2024.7.2.dist-info/entry_points.txt,sha256=6PBfY36A1xNOdzLiz-Qoukya_UzFZAwOapwmRNnPeZ8,56
|
|
9
|
+
shepherd_data-2024.7.2.dist-info/top_level.txt,sha256=7-SCTY-TG1mLY72OVKCaqte1hy-X8woxknIUAD3OIxs,14
|
|
10
|
+
shepherd_data-2024.7.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
11
|
+
shepherd_data-2024.7.2.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
shepherd_data/__init__.py,sha256=D-QyEhYdKu0NrfxtHZmRg71QC6jFOoIsLJRiGSO2Ufg,352
|
|
2
|
-
shepherd_data/cli.py,sha256=21BzQMhPfHocpExmXb8BXTk58zZzc4Up7tLzjpyFwjI,15031
|
|
3
|
-
shepherd_data/ivonne.py,sha256=5EryExMQ8E8PTgX5xkZUyLqhvhCcLT17rdC0POv4NLI,11831
|
|
4
|
-
shepherd_data/mppt.py,sha256=588KSrLuJfNRKKnnL6ewePLi3zrwaO_PAZypikACrks,3925
|
|
5
|
-
shepherd_data/reader.py,sha256=JKTVemjH_6678MCNf2cDzRIsCyfD2B6CTUzBiG110QY,18531
|
|
6
|
-
shepherd_data-2024.7.1.dist-info/METADATA,sha256=RSM7L3RAj0zCeM9kX0X3KIz2KWgh3y4ZF2IaZordgtI,3387
|
|
7
|
-
shepherd_data-2024.7.1.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
|
|
8
|
-
shepherd_data-2024.7.1.dist-info/entry_points.txt,sha256=6PBfY36A1xNOdzLiz-Qoukya_UzFZAwOapwmRNnPeZ8,56
|
|
9
|
-
shepherd_data-2024.7.1.dist-info/top_level.txt,sha256=7-SCTY-TG1mLY72OVKCaqte1hy-X8woxknIUAD3OIxs,14
|
|
10
|
-
shepherd_data-2024.7.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
11
|
-
shepherd_data-2024.7.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|