From fa6eda5c162068eb549d9eaf9cb347c110b25558 Mon Sep 17 00:00:00 2001 From: DBras Date: Mon, 10 Jun 2024 14:15:17 +0200 Subject: [PATCH] question: D3 Q4 --- demo_plotter.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/demo_plotter.py b/demo_plotter.py index da3f37c..6f77e84 100755 --- a/demo_plotter.py +++ b/demo_plotter.py @@ -36,7 +36,7 @@ else: ################################################################################ -################## Question 3 ################################################## +################## Question 4 ################################################## ################################################################################ # Construct a dataframe and pivot it to obtain a dataframe with a column per unit, and a row per timestamp. @@ -46,22 +46,15 @@ df_pivot = df.pivot_table(values='value', columns='unit', index='time') df_resampled = df_pivot.resample('s').mean() df_resampled.interpolate(method='linear', inplace=True) df_resampled = pd.DataFrame(df_resampled) -df_gaia = df_resampled['gaia_p'] -df_gaia_diffs = df_gaia.diff() -gaia_min, gaia_max = df_gaia.min(), df_gaia.max() -diff_min, diff_max = df_gaia_diffs.min(), df_gaia_diffs.max() - -print(f'{gaia_min=}, {gaia_max=}') -print(f'{diff_min=}, {diff_max=}') +df_resampled['common_p'] = df_resampled[[c for c in df_resampled if '_p' in c + and c != 'pcc_p']].sum(axis=1) * -1 # Plot the data. Note, that the data will mostly not be plotted with lines. plt.ion() # Turn interactive mode on plt.figure() -ax1, ax2 = plt.subplot(211), plt.subplot(212) -df_gaia.plot(marker='.', ax=ax1, linewidth=3) -ax1.hlines([gaia_min, gaia_max], df_gaia.index.min(), df_gaia.index.max(), color='r') -df_gaia_diffs.plot(marker='.', ax=ax2, linewidth=3) +plt.plot(df_resampled['pcc_p']) +plt.plot(df_resampled['common_p']) plt.show(block=True) -## gaia_min=0.62, gaia_max=7.085 -## diff_min=-1.963, diff_max=1.3210000000000002 +## The controller seems to balance in and out from the grid. Differences are +## probably from interpolation and resampling.