from gekko import GEKKO import pandas as pd import matplotlib.pyplot as plt # load data and parse into columns url = 'http://apmonitor.com/do/uploads/Main/tclab_dyn_data2.txt' data = pd.read_csv(url) t = data['Time'] u = data[['H1','H2']] y = data[['T1','T2']] # generate time-series model m = GEKKO(remote=False) # system identification na = 2 # output coefficients nb = 2 # input coefficients yp,p,K = m.sysid(t,u,y,na,nb,diaglevel=1) plt.figure() plt.subplot(2,1,1) plt.plot(t,u) plt.legend([r'$u_0$',r'$u_1$']) plt.ylabel('MVs') plt.subplot(2,1,2) plt.plot(t,y) plt.plot(t,yp) plt.legend([r'$y_0$',r'$y_1$',r'$z_0$',r'$z_1$']) plt.ylabel('CVs') plt.xlabel('Time') plt.savefig('sysid.png') plt.show()