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

Flow. Get conductivity by melting time.

parent 77422a0c
Pipeline #152027 passed with stages
in 1 minute and 38 seconds
......@@ -433,6 +433,54 @@ def add_flask_info(arrival_df: pd.DataFrame, collector_df: pd.DataFrame) -> pd.D
return arrival_df
def get_conduct_by_melt_time(arrival_df: pd.DataFrame, conduct_df: pd.DataFrame,
probes: list = ["C1", "C2", "C3", "C4", "C5"],
reference_datetime: str = None,
export_in_dataset: DatasetReader = None) -> pd.DataFrame:
"""Get the conductivity values as a function of the sample melting time.
Parameters
----------
arrival_df: pd.DataFrame
Output of :func:`get_arrival_df` function.
conduct_df: pd.DataFrame
Conductivity's timestamped data, as obtained with :func:`get_datasets_data` function.
probes: list, optional
List of probes (e.g. `["C1", "C2", "C3"]`) which should be computed.
reference_datetime: str, optional
If set, all the values of a probe will be subtracted by the value at the reference point. This is used in order
to "gather" all probes in the same area of the plot, thus minimizing the gap induced by the values of the
non-calibrated probes. It eases the conductivity peak's comparison over several probes.
export_in_dataset: DatasetReader, optional
If set, the resulting dataset will be exported as .log file in the regular "Dataset" place and format, making it
readable by cfa-analysis software.
Returns
-------
pd.DataFrame
Index is the datetime when the ice section was melted. Each column give the conductivity value of this ice
section.
"""
conduct_arrival_df = arrival_df[probes]
conduct_rescaled_df = pd.DataFrame(columns=probes)
for probe in probes:
df = pd.merge_asof(conduct_arrival_df[probe], conduct_df[probe], left_on=probe, right_index=True)
df = df[probe + "_y"].rename(probe)
if reference_datetime is not None:
idx_ref = df.index.searchsorted(reference_datetime)
df = df - df.iloc[idx_ref]
conduct_rescaled_df[probe] = df
if export_in_dataset is not None:
conduct_rescaled_path = os.path.join(export_in_dataset.dataset_path,
export_in_dataset.dataset_name + "_CONDUCTI-R_periodic.log")
conduct_rescaled_df.index.name = 'datetime'
conduct_rescaled_df.to_csv(conduct_rescaled_path, date_format="%Y-%m-%dT%H:%M:%SZ", sep="\t")
return conduct_rescaled_df
def __compute_mm__(df: pd.DataFrame) -> pd.DataFrame:
df["datetime"] = df.index
df["mm_step"] = df["speed"].abs() * df["datetime"].diff().dt.total_seconds().fillna(0)
......
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