question: D3 Q4
This commit is contained in:
parent
563be46da6
commit
fa6eda5c16
|
|
@ -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.
|
# 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 = df_pivot.resample('s').mean()
|
||||||
df_resampled.interpolate(method='linear', inplace=True)
|
df_resampled.interpolate(method='linear', inplace=True)
|
||||||
df_resampled = pd.DataFrame(df_resampled)
|
df_resampled = pd.DataFrame(df_resampled)
|
||||||
df_gaia = df_resampled['gaia_p']
|
df_resampled['common_p'] = df_resampled[[c for c in df_resampled if '_p' in c
|
||||||
df_gaia_diffs = df_gaia.diff()
|
and c != 'pcc_p']].sum(axis=1) * -1
|
||||||
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.
|
# Plot the data. Note, that the data will mostly not be plotted with lines.
|
||||||
plt.ion() # Turn interactive mode on
|
plt.ion() # Turn interactive mode on
|
||||||
plt.figure()
|
plt.figure()
|
||||||
ax1, ax2 = plt.subplot(211), plt.subplot(212)
|
plt.plot(df_resampled['pcc_p'])
|
||||||
df_gaia.plot(marker='.', ax=ax1, linewidth=3)
|
plt.plot(df_resampled['common_p'])
|
||||||
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)
|
plt.show(block=True)
|
||||||
|
|
||||||
## gaia_min=0.62, gaia_max=7.085
|
## The controller seems to balance in and out from the grid. Differences are
|
||||||
## diff_min=-1.963, diff_max=1.3210000000000002
|
## probably from interpolation and resampling.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue