Skip to content
Snippets Groups Projects
Commit 3d64fd68 authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

Instant_config_df: fill NAs with previous values, to match new CFA conductcalib setup.

parent 31a85d67
No related branches found
No related tags found
No related merge requests found
...@@ -61,18 +61,34 @@ class CalibRun: ...@@ -61,18 +61,34 @@ class CalibRun:
def update_steps_df(self): def update_steps_df(self):
config_df = self.instant_config_df.copy() config_df = self.instant_config_df.copy()
# From long to wide format
config_df = config_df.pivot(index='datetime', columns='name', values='value') config_df = config_df.pivot(index='datetime', columns='name', values='value')
# Forward fill NAs. Values not changing are not recorded in instant_config_df, so fill with previous value.
config_df = config_df.fillna(method='ffill')
# Compute step number for each line
config_df["step"] = np.arange(len(config_df)) + 1 config_df["step"] = np.arange(len(config_df)) + 1
# Set start/end datetime for each step
config_df["start_datetime"] = config_df.index config_df["start_datetime"] = config_df.index
config_df["end_datetime"] = config_df["start_datetime"].shift(-1) config_df["end_datetime"] = config_df["start_datetime"].shift(-1)
# For the last step, compute the end_datetime from expected length written in User-defined config file.
config_df.loc[config_df.index[-1], 'end_datetime'] = \ config_df.loc[config_df.index[-1], 'end_datetime'] = \
config_df.loc[config_df.index[-1], 'start_datetime'] \ config_df.loc[config_df.index[-1], 'start_datetime'] \
+ datetime.timedelta(seconds=int(self.user_config_df.loc[self.user_config_df.index[-1], 'length_sec'])) + datetime.timedelta(seconds=int(self.user_config_df.loc[self.user_config_df.index[-1], 'length_sec']))
config_df.reset_index(drop=True, inplace=True) config_df.reset_index(drop=True, inplace=True)
# Reshape: separate column for excite and headgain
config_df = pd.wide_to_long(config_df, ["excite", "headgain"], i="step", j="channel", sep="_").reset_index() config_df = pd.wide_to_long(config_df, ["excite", "headgain"], i="step", j="channel", sep="_").reset_index()
# Add "stable" timeframe limit for each step, i.e. remove transition phases at the beginning/end of each step.
config_df["stable_start_datetime"] = config_df["start_datetime"] + datetime.timedelta(seconds=2) config_df["stable_start_datetime"] = config_df["start_datetime"] + datetime.timedelta(seconds=2)
config_df["stable_end_datetime"] = config_df["end_datetime"] - datetime.timedelta(seconds=2) config_df["stable_end_datetime"] = config_df["end_datetime"] - datetime.timedelta(seconds=2)
# Compute mean, standard deviation and validity for each step/channelComment
for channel in range(1, 6): for channel in range(1, 6):
channel_config_df = config_df[config_df["channel"] == channel].copy() channel_config_df = config_df[config_df["channel"] == channel].copy()
for index, row in channel_config_df.iterrows(): for index, row in channel_config_df.iterrows():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment