Commit 7af61021 authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

Flow Processor. Debubbler influence.

parent f3fd0bfc
Pipeline #104539 passed with stages
in 1 minute and 21 seconds
......@@ -12,18 +12,78 @@ import matplotlib.pyplot as plt
def get_flow_timeseries(dataset: DatasetReader):
colpump_df = pump.get_mlmin_df(dataset, "COLPUMP")
compump_df = pump.get_mlmin_df(dataset, "COMPUMP")
picpump_df = pump.get_mlmin_df(dataset, "PICPUMP")
pump_df = get_bubble_density_from_pump(dataset)
iceblock_df = dataset.get_timeseries("ICBKCTRL_instant")
melting_df = iceblock.get_melting_timeseries(iceblock_df)
melting_df["datetime_in"] = melting_df.index
com_water_df = pump_df[["com_water_pump"]]
com_water_df = com_water_df.rename(columns={"com_water_pump": "mlmin"})
melting_df["datetime_debubbler"] = get_datetime_out(melting_df["datetime_in"], com_water_df, 3.48, parallel=False)
colpic_df = pump_df[["pic", "col"]]
colpic_df["mlmin"] = colpic_df["pic"] + colpic_df["col"]
melting_df["datetime_T1"] = get_datetime_out(melting_df["datetime_debubbler"], colpic_df, 0.600, parallel=False)
pic_df = pump_df[["pic"]]
pic_df = pic_df.rename(columns={"pic": "mlmin"})
melting_df["datetime_T2"] = get_datetime_out(melting_df["datetime_T1"], pic_df, 0.095, parallel=False)
melting_df["datetime_picarro"] = melting_df["datetime_T2"] + datetime.timedelta(minutes=1, seconds=35)
picarro_df = dataset.get_timeseries("PICARRO_periodic")
picarro_df["Delta_18_16"].plot()
pass
def get_debubbler_effect(dataset: DatasetReader):
pump_df = get_bubble_density_from_pump(dataset)
conduct_df = dataset.get_timeseries("CONDUCTI_periodic")
conduct_df = conduct_df[["C1"]]
# conduct_df = conduct_df[conduct_df["C1"] > 1.35]
conduct_df["datetime_C1"] = conduct_df.index
com_water_df = pump_df[["com_water_pump"]]
com_water_df = com_water_df.rename(columns={"com_water_pump": "mlmin"})
conduct_df["datetime_debubbler"] = get_datetime_out(conduct_df["datetime_C1"], com_water_df, 0.087, parallel=False)
vol_debub_C5 = 0.630
vol_debub_T1 = 0.432
vol_debub_C4 = 1.187
vol_T1_C4 = vol_debub_C4 - vol_debub_T1
vol_T1_C5 = vol_debub_C5 - vol_debub_T1
colpic_df = pump_df[["pic", "col"]]
colpic_df = colpic_df.ewm(alpha=0.05).mean()
colpic_df["mlmin"] = colpic_df["pic"] + colpic_df["col"]
conduct_df["datetime_T1"] = get_datetime_out(conduct_df["datetime_debubbler"], colpic_df, vol_debub_T1, parallel=False)
col_df = pump_df[["col"]]
col_df = col_df.rename(columns={"col": "mlmin"})
conduct_df["datetime_C4"] = get_datetime_out(conduct_df["datetime_T1"], col_df, vol_T1_C4, parallel=False)
pic_df = pump_df[["pic"]]
pic_df = pic_df.rename(columns={"pic": "mlmin"})
conduct_df["datetime_C5"] = get_datetime_out(conduct_df["datetime_T1"], pic_df, vol_T1_C5, parallel=False)
pass
def compare_gasflow(dataset: DatasetReader):
"USELESS - For later reuse/refactor"
colpump_df = pump.get_mlmin_df(dataset, "COLPUMP")
compump_df = pump.get_mlmin_df(dataset, "COMPUMP")
picpump_df = pump.get_mlmin_df(dataset, "PICPUMP")
gasflow_df = dataset.get_timeseries("GASFLOW_periodic")
pump_df = pd.merge(colpump_df, compump_df, right_index=True, left_index=True, how="outer", suffixes=["_col", "_com"])
pump_df = pd.merge(colpump_df, compump_df, right_index=True, left_index=True, how="outer",
suffixes=["_col", "_com"])
pump_df = pd.merge(pump_df, picpump_df, right_index=True, left_index=True, how="outer")
pump_df = pump_df.rename(columns={"mlmin": "mlmin_pic"})
pump_df = pd.merge(pump_df, gasflow_df, right_index=True, left_index=True, how="outer")
......@@ -36,7 +96,6 @@ def get_flow_timeseries(dataset: DatasetReader):
pump_df["mlmin_air_diff"] = pump_df["mlmin_com_air"] - pump_df["mlmin_gas"]
pump_df[["mlmin_air_diff"]].plot()
plt.show()
pass
def get_bubble_density(dataset: DatasetReader):
......@@ -70,13 +129,10 @@ def get_bubble_density_from_pump(dataset: DatasetReader):
def get_bubble_density_from_conduct(dataset: DatasetReader):
first_datetime = "2020-12-23 14:35:08"
last_datetime = "2020-12-23 15:02:49"
conduct_df = dataset.get_timeseries("CONDUCTI_periodic")[["C1", "C2"]]
c1 = conduct_df[first_datetime:last_datetime]["C1"]
c1 = conduct_df["C1"]
c2 = conduct_df["C2"]
c2.index = c2.index + datetime.timedelta(seconds=-11)
c2 = c2[first_datetime:last_datetime]
c2.index = c2.index + datetime.timedelta(seconds=-9)
c2 = c2 - 0.05
conduct_df = pd.merge(c1, c2, left_index=True, right_index=True, how="outer").fillna(method="ffill")
......@@ -124,6 +180,9 @@ def get_datetime_out(datetime_in: pd.Series, mlmin_df: pd.DataFrame, tube_volume
mlmin_df = mlmin_df[["mlmin"]].ffill()
mlmin_df["ml_cumul"] = pump.add_cumulated_volume(mlmin_df["mlmin"])
# Make sure the earliest datetime_in is after the first available ml_cumul
datetime_in = datetime_in[datetime_in.index >= mlmin_df["ml_cumul"].dropna().index[0]]
if parallel:
pandarallel.initialize()
datetime_out = datetime_in.parallel_apply(__get_single_datetime_out__, args=(mlmin_df, tube_volume_ml))
......@@ -160,6 +219,8 @@ def __get_single_datetime_out__(datetime_in: pd.Timestamp, mlmin_df: pd.DataFram
# Create a DataFrame of flow rate's evolution, starting from insertion (`datetime_in`)
object_mlmin_df = mlmin_df[mlmin_df.index >= datetime_in]
if len(object_mlmin_df.index) == 0:
return
# Get already-cumulated volume at datetime_in
initial_volume = object_mlmin_df["ml_cumul"].iloc[0]
......
......@@ -20,7 +20,7 @@ class TestFlow(TestCase):
self.base_path = config_parser["base_data_path"]
def test_get_flow_timeseries(self):
dataset_name = "20210122_mock_ice_bronkgas_debub"
dataset_name = "20210202_mock_core_flasks"
dataset = DatasetReader(self.base_path, dataset_name)
try:
......@@ -28,6 +28,15 @@ class TestFlow(TestCase):
except:
self.fail("Exception raised!")
def test_get_debubbler_effect(self):
dataset_name = "20210212_conducti_transitions_various_speeds"
dataset = DatasetReader(self.base_path, dataset_name)
try:
flow.get_debubbler_effect(dataset)
except:
self.fail("Exception raised!")
def test_get_datetime_out_artificialdataset(self):
tube_volume_ml = 30
......@@ -93,6 +102,6 @@ class TestFlow(TestCase):
flow.get_bubble_density_from_conduct(dataset)
def test_get_bubble_density(self):
dataset_name = "20201223_mock_core"
dataset_name = "20201223_mock_core_bronkhorst"
dataset = DatasetReader(self.base_path, dataset_name)
flow.get_bubble_density(dataset)
\ No newline at end of file
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