Commit f3866b22 authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

Encoder processor. Detect move-up events. Return DataFrame instead of dict

parent 0b120c09
Pipeline #118953 passed with stages
in 49 seconds
......@@ -36,7 +36,7 @@ def add_cmmin_conversion(encoder_df: pd.DataFrame) -> pd.DataFrame:
def get_moveup_events(encoder_df: pd.DataFrame,
normal_speed_range: typing.Tuple[float, float]) -> typing.List[dict]:
normal_speed_range: typing.Tuple[float, float]) -> pd.DataFrame:
"""Get encoder's upwards movement events.
In normal melting, the encoder's speed is within ``normal_speed_range``. But it also occur some fast upwards
......@@ -51,9 +51,9 @@ def get_moveup_events(encoder_df: pd.DataFrame,
List of dict
One dict per event, with for each event the ``start_datetime`` and ``end_datetime``, the ``start_position`` and
``end_position`` (in mm) and the ``event_type``.
One line per event, with the following columns: ``start_datetime``, ``end_datetime``, ``start_position`` and
``end_position`` (in mm) and ``event_type``.
encoder_df = encoder_df.copy()
encoder_df["pos_diff"] = encoder_df["position"].diff()
......@@ -106,7 +106,8 @@ def get_moveup_events(encoder_df: pd.DataFrame,
"end_datetime": end_datetime,
"end_position": end_position})
return events_list
events_df = pd.DataFrame(events_list)
return events_df
......@@ -27,7 +27,7 @@ class TestEncoder(TestCase):
inst_reader = InstrumentReader(self.base_path)
encoder_df = inst_reader.get_timeseries("20210506_test_encoder_mock_core4", "ENCODER_periodic")
events_list = encoder.get_moveup_events(encoder_df, (-3.0, -0.01))
events_df = encoder.get_moveup_events(encoder_df, (-3.0, -0.01))
except:"Exception raised!")
......@@ -41,6 +41,6 @@ class TestEncoder(TestCase):
'start_position': 136.65,
'end_datetime': None,
'end_position': None}]
self.assertListEqual(events_list, expected_events_list)
expected_events_df = pd.DataFrame(expected_events_list)
Markdown is supported
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