Commit 4a70ad90 authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

Flow Processor. Get continuous melting height. Not finished.

parent f3866b22
Pipeline #119001 passed with stages
in 1 minute and 20 seconds
......@@ -436,6 +436,28 @@ def __compute_mm__(df: pd.DataFrame) -> pd.DataFrame:
return df
def get_continuous_melting_height(encoder_df: pd.DataFrame,
stacked_iceblocks_df: pd.DataFrame,
moveup_event_df: pd.DataFrame) -> pd.DataFrame:
stack_events_df = moveup_event_df[moveup_event_df["event_type"] == "stacking"]
if len(stack_events_df.index) != len(stacked_iceblocks_df):
raise ValueError("There should be the same number of stacking events as stakced heights!")
stack_events_df = stack_events_df.copy()
stack_events_df = pd.merge_asof(stack_events_df, stacked_iceblocks_df,
left_on="start_datetime", right_index=True,
direction="forward")
stack_events_df["melted_while_event"] = \
stack_events_df["stacked_height"] - (stack_events_df["end_position"] - stack_events_df["start_position"])
stack_events_df["avg_melting_speed"] = \
stack_events_df["melted_while_event"] / (stack_events_df["end_datetime"] - stack_events_df["start_datetime"]).dt.total_seconds()
for index, stack_event in stack_events_df.iterrows():
# Compute position change for each timestep of each event
pass
pass
def get_tubing_volume_dict(filepath: str,
max_datetime: datetime.datetime = datetime.datetime.now(datetime.timezone.utc)) -> dict:
"""Get the characteristic tubing volumes
......
......@@ -9,7 +9,8 @@ import pstats
from processor import flow
from processor import pump
from logreader.dataset import DatasetReader
from processor import encoder
from logreader.dataset import DatasetReader, InstrumentReader
class TestFlow(TestCase):
......@@ -138,3 +139,18 @@ class TestFlow(TestCase):
df = flow.add_flask_info(df, collector_df)
except:
self.fail("Exception raised!")
def test_get_continuous_melting_height(self):
data = [[pd.Timestamp("2021-05-07 12:34:22.133011+00:00"), 715],
[pd.Timestamp("2021-05-07 13:03:49.215460+00:00"), 677],
[pd.Timestamp("2021-05-07 13:29:03.557948+00:00"), 895],
[pd.Timestamp("2021-05-07 14:01:15.109480+00:00"), 680],
[pd.Timestamp("2021-05-07 14:30:03.054819+00:00"), 72]]
stacked_iceblock_df = pd.DataFrame(data, columns=['datetime', 'tot_stacked_height'])
stacked_iceblock_df = stacked_iceblock_df.set_index("datetime")
inst_reader = InstrumentReader(self.base_path)
encoder_df = inst_reader.get_timeseries("20210507_ASUMA2016_8_14", "ENCODER_periodic")
moveup_event_df = encoder.get_moveup_events(encoder_df, (-3.0, -0.01))
flow.get_continuous_melting_height(encoder_df, stacked_iceblock_df, moveup_event_df)
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