From 563be46da69460f14e727306c8b8c89f97cd2168 Mon Sep 17 00:00:00 2001 From: DBras Date: Mon, 10 Jun 2024 14:00:46 +0200 Subject: [PATCH] question: D3 Q3 --- demo_plotter.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/demo_plotter.py b/demo_plotter.py index de1e8dc..da3f37c 100755 --- a/demo_plotter.py +++ b/demo_plotter.py @@ -36,7 +36,7 @@ else: ################################################################################ -################## Question 2 ################################################## +################## Question 3 ################################################## ################################################################################ # Construct a dataframe and pivot it to obtain a dataframe with a column per unit, and a row per timestamp. @@ -46,12 +46,22 @@ 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=}') # Plot the data. Note, that the data will mostly not be plotted with lines. plt.ion() # Turn interactive mode on plt.figure() -ax1 = plt.subplot(211) # Make two separate figures -ax2 = plt.subplot(212) -df_resampled[[c for c in df_resampled.columns if c.endswith('_p')]].plot(marker='.', ax=ax1, linewidth=3) -df_resampled[[c for c in df_resampled.columns if c.endswith('_q')]].plot(marker='.', ax=ax2, linewidth=3) +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.show(block=True) + +## gaia_min=0.62, gaia_max=7.085 +## diff_min=-1.963, diff_max=1.3210000000000002