Commit 67e20718 authored by Henri Payno's avatar Henri Payno
Browse files

current: only register current with start_time if find only one electric current

parent 33fa0a94
Pipeline #74674 passed with stages
in 3 minutes and 45 seconds
......@@ -520,15 +520,19 @@ class StandardAcquisition(BaseAcquisition):
new_know_electric_currents = {}
if start_time is None or end_time is None:
_logger.warning(
"Unable to find start_time and / or end_time. Will pick the first available electricl_current for the frame"
)
if start_time != end_time:
_logger.warning(
f"Unable to find {'start_time' if start_time is None else 'end_time'}. Will pick the first available electric_current for the frame"
)
t_time = start_time or end_time
# if at least one can find out
new_know_electric_currents[
str_datetime_to_numpy_datetime64(t_time)
] = (electric_currents[0] * unit_factor)
else:
_logger.error(
"Unable to find start_time and end_time. Will not register any machine electric current"
)
elif len(electric_currents) == 1:
# if we have only one value, consider the machine electric current is constant during this time
# might be improved later if we can know if current is determine at the
......@@ -537,9 +541,6 @@ class StandardAcquisition(BaseAcquisition):
new_know_electric_currents[
str_datetime_to_numpy_datetime64(start_time)
] = (electric_currents[0] * unit_factor)
new_know_electric_currents[
str_datetime_to_numpy_datetime64(end_time)
] = (electric_currents[0] * unit_factor)
else:
# linspace from datetime within ms precision.
# see https://localcoder.org/creating-numpy-linspace-out-of-datetime#credit_4
......
......@@ -1035,16 +1035,12 @@ def test_machine_electric_current():
"2022-01-15T21:07:58.360095+02:00",
"2022-01-15T21:07:59.360095+02:00",
)
end_times = ("2022-01-15T21:07:59.170095+02:00", None)
for (node_name, machine_elec_current_ma, st, et) in zip(
node_names, machine_elec_current, start_times, end_times
for (node_name, machine_elec_current_ma, st) in zip(
node_names, machine_elec_current, start_times
):
h5f[f"{node_name}/instrument/machine/current"] = machine_elec_current_ma
h5f[f"{node_name}/instrument/machine/current"].attrs["unit"] = "mA"
if st is not None:
h5f[node_name]["start_time"] = st
if et is not None:
h5f[node_name]["end_time"] = et
h5f[node_name]["start_time"] = st
assert "4.1" in h5f
assert "5.1" in h5f
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment