EV6_HW_Imp/scripts/helper.py

18 lines
538 B
Python
Raw Normal View History

2024-03-22 13:55:14 +01:00
# {'TIME': [data], 'CH1': [data], 'CH2': [data]}
def cut_time(data : dict, start : float, end : float) -> dict:
idx_start = 0
idx_end = 0
for idx, t in enumerate(data['TIME']):
if t > start and idx_start == 0:
idx_start = idx
if t > end and idx_end == 0:
idx_end = idx
if idx_end != 0 and idx_start != 0:
break
if idx_end != 0 and idx_start != 0:
return {key: value[idx_start:idx_end] for key, value in data.items()}
else:
return None