Commit 81b5e83b authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

Flow Processor. Start on plexi

parent b4360e2e
Pipeline #119387 passed with stages
in 1 minute and 17 seconds
......@@ -257,11 +257,7 @@ def get_datasets_data(dataset: DatasetReader)\
# Iceblock
iceblock_df = dataset.get_timeseries("ICBKCTRL_instant")
iceblock_df = iceblock.get_melting_timeseries(iceblock_df)
iceblock_df = iceblock_df.sort_index()
iceblock_df["icbk_datetime"] = iceblock_df.index
iceblock_df = iceblock_df.rename(columns={"value_int": "icbk_code",
"value": "icbk_name"})
iceblock_df = iceblock.get_clean_iceblock_df(iceblock_df)
# Conductivity
conduct_df = dataset.get_timeseries("CONDUCTI_periodic")
......@@ -438,7 +434,8 @@ def __compute_mm__(df: pd.DataFrame) -> pd.DataFrame:
def get_absolute_melted_height(encoder_df: pd.DataFrame,
stacked_iceblocks_df: pd.DataFrame,
moveup_event_df: pd.DataFrame) -> pd.DataFrame:
moveup_event_df: pd.DataFrame,
starting_on_plexi: bool) -> pd.DataFrame:
"""Get the total absolute melting height, for each encoder's timestep.
Parameters
......@@ -450,6 +447,9 @@ def get_absolute_melted_height(encoder_df: pd.DataFrame,
the ice blocks stacked at the same time should be summed.
moveup_event_df: pd.DataFrame
Output of :func:`cfatools.processor.encoder.get_moveup_events` function.
starting_on_plexi: bool
If ``True``, the plexi-plate is in ``PLACED`` position at the beginning of the ``encoder_df`` dataset. In this
case, 7.5mm (plexi-plate height) are removed from the ``melted_height``.
Returns
-------
......@@ -457,13 +457,11 @@ def get_absolute_melted_height(encoder_df: pd.DataFrame,
Same as ``encoder_df``, with an additional ``melted_height`` column.
"""
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 stacked heights!")
# Associate the stack events to the total height of ice blocks stacked at this event
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,
left_on="start_datetime", right_on="datetime_stacked",
direction="forward")
# Compute the height of already-stacked ice which has been melted during the stacking event, while the encoder was
......@@ -485,6 +483,14 @@ def get_absolute_melted_height(encoder_df: pd.DataFrame,
encoder_df["melted_height"] = (-encoder_df["ice_speed"] * encoder_df["time_diff"]).cumsum()
if starting_on_plexi:
encoder_df["melted_height"] = encoder_df["melted_height"] - 7.5
encoder_df.loc[encoder_df["melted_height"] < 0, "melted_height"] = 0
# Set all-but-last 0-value melted height to NaN
if len(encoder_df[encoder_df["melted_height"] == 0].index) > 2:
encoder_df.loc[:encoder_df[encoder_df["melted_height"] == 0].tail(2).index[0], "melted_height"] = np.nan
return encoder_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