question: D3 Part 2
This commit is contained in:
parent
fa6eda5c16
commit
bb6ebbc9db
File diff suppressed because it is too large
Load Diff
|
|
@ -34,10 +34,12 @@ if use_setpoint_log:
|
||||||
else:
|
else:
|
||||||
data = meas_data
|
data = meas_data
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
################## Part 2 ######################################################
|
||||||
|
################################################################################
|
||||||
|
|
||||||
################################################################################
|
## The controller is reasonably fast at reacting to changes; the sum of in and
|
||||||
################## Question 4 ##################################################
|
## out is at zero roughly 5-10 seconds after a change.
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# 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.
|
||||||
df = pd.DataFrame.from_records(data)
|
df = pd.DataFrame.from_records(data)
|
||||||
|
|
@ -46,15 +48,11 @@ 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_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.
|
# 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()
|
||||||
plt.plot(df_resampled['pcc_p'])
|
ax1, ax2 = plt.subplot(211), plt.subplot(212)
|
||||||
plt.plot(df_resampled['common_p'])
|
df_resampled[[c for c in df_resampled.columns if '_p' in c]].plot(marker='.', ax=ax1, linewidth=3)
|
||||||
|
df_resampled['pcc_p'].plot(marker='.', ax=ax2, linewidth=3)
|
||||||
plt.show(block=True)
|
plt.show(block=True)
|
||||||
|
|
||||||
## The controller seems to balance in and out from the grid. Differences are
|
|
||||||
## probably from interpolation and resampling.
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue