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

Collector. Re-number flask to have unique numbers, segregated by rack.

parent 95b51930
Pipeline #157222 passed with stages
in 1 minute and 6 seconds
"""
The collector processor module provides functions to manipulate collector's raw data.
"""
import pandas as pd
def renumber_flasks(collector_df: pd.DataFrame) -> pd.DataFrame:
if "flask" not in collector_df.columns:
raise ValueError("The collector_df expected should have a 'flask' column")
# In the old numbering system, flasks were grouped by 50. Re-number them by 100
if collector_df.index[0] < pd.Timestamp(year=2021, month=12, day=16, tz="UTC"):
collector_df.loc[(collector_df["flask"] >= 101) & (collector_df["flask"] <= 148)] = collector_df.loc[(collector_df["flask"] >= 101) & (collector_df["flask"] <= 148)] + 300 - 100
collector_df.loc[(collector_df["flask"] >= 51) & (collector_df["flask"] <= 98)] = collector_df.loc[(collector_df["flask"] >= 51) & (collector_df["flask"] <= 98)] + 200 - 50
collector_df.loc[(collector_df["flask"] >= 1) & (collector_df["flask"] <= 48)] = collector_df.loc[(collector_df["flask"] >= 1) & (collector_df["flask"] <= 48)] + 100
# Re-number the flasks of the 4th rack and followings.
collector_df["cumcount"] = collector_df.groupby("flask").cumcount()
collector_df["flask"] = collector_df["flask"] + collector_df["cumcount"] * 300
return collector_df
if __name__ == '__main__':
from cfatools.logreader.dataset import DatasetReader
dataset = DatasetReader("/homel/ojossoud/_temp/data_cfa", "20210826_ASUMA2016_6-1_sq")
# collector_df = dataset.get_timeseries("COLLECTR_instant")
# renumber_flasks(collector_df)
collector_df = dataset.get_timeseries("COLLECTR_instant", "flask")
collector_df = collector_df.rename(columns={"value": "flask"})
renumber_flasks(collector_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