question: D3 Part 2 Q2
This commit is contained in:
parent
e6c47bac4e
commit
f5dfda57b7
|
|
@ -1,5 +1,6 @@
|
|||
#!./venv/bin/python3
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import json
|
||||
import matplotlib.pyplot as plt
|
||||
import os
|
||||
|
|
@ -38,6 +39,15 @@ else:
|
|||
################## Part 2 ######################################################
|
||||
################################################################################
|
||||
|
||||
def overshoot(df, T1, T2):
|
||||
yT1, yT2 = df[T1], df[T2]
|
||||
over = 1 / (yT1 - yT2) * np.max(yT2 - df)
|
||||
return over
|
||||
|
||||
SETPOINT_UNIX = 1718013959.6977577
|
||||
SETPOINT_TS = pd.to_datetime(SETPOINT_UNIX, unit='s')
|
||||
WINDOW = pd.to_datetime(SETPOINT_UNIX+25, unit='s')
|
||||
|
||||
## The controller is reasonably fast at reacting to changes; the sum of in and
|
||||
## out is at zero roughly 5-10 seconds after a change.
|
||||
|
||||
|
|
@ -45,7 +55,7 @@ else:
|
|||
df = pd.DataFrame.from_records(data)
|
||||
df['time'] = pd.to_datetime(df['time'], unit='s')
|
||||
df_pivot = df.pivot_table(values='value', columns='unit', index='time')
|
||||
df_resampled = df_pivot.resample('s').mean()
|
||||
df_resampled = df_pivot.resample('0.1s').mean()
|
||||
df_resampled.interpolate(method='linear', inplace=True)
|
||||
df_resampled = pd.DataFrame(df_resampled)
|
||||
|
||||
|
|
@ -54,5 +64,10 @@ plt.ion() # Turn interactive mode on
|
|||
plt.figure()
|
||||
ax1, ax2 = plt.subplot(211), plt.subplot(212)
|
||||
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)
|
||||
ax2.plot(df_resampled['pcc_p'][SETPOINT_TS:WINDOW], marker='.', linewidth=3, label='pcc_p')
|
||||
ax2.plot(df_resampled['dumpload_p'][SETPOINT_TS:WINDOW], marker='.', linewidth=3, label='dumpload')
|
||||
plt.legend()
|
||||
|
||||
# print(overshoot(df_resampled['pcc_p'][SETPOINT_TS:WINDOW], SETPOINT_TS, WINDOW))
|
||||
|
||||
plt.show(block=True)
|
||||
|
|
|
|||
Loading…
Reference in New Issue