def plot_moments(KF,fig=None,scaleByMean=False): import matplotlib import matplotlib.pyplot as plt z_test = list(fastlib.ED_TwrGag(KF.WT.ED) - KF.WT.ED['TowerBsHt']) print('z test:',z_test) n=len(z_test) # z_test.reverse() # --- Compare measurements cmap = matplotlib.cm.get_cmap('viridis') COLRS = [(cmap(v)[0],cmap(v)[1],cmap(v)[2]) for v in np.linspace(0,1,n+1)] if fig is None: fig=plt.figure() fig.set_size_inches(6.4,15.0,forward=True) # default is (6.4,4.8) for i,z in enumerate(z_test): ax = fig.add_subplot(n,1,i+1) M_sim =KF.M_sim[i] if scaleByMean: M_sim+=-np.mean(KF.M_sim[i])+np.mean(KF.M_ref[i]) ax.plot (KF.time, KF.M_ref[i], 'k-', color='k', label='Reference' , lw=1) ax.plot (KF.time, M_sim , '--', color=COLRS[i],label='Estimation', lw=0.8) ax.set_ylabel('My z={:.1f}'.format(z)) ax.tick_params(direction='in') # if ii<2: if i<n-1: ax.set_xticklabels([]) else: ax.set_xlabel('Time [s]') ax.legend() # # plt.ylim(0.05*10**8,0.8*10**8) ax.set_title('KalmanLoads')
def moments(KF): WT = KF.WT z_test = fastlib.ED_TwrGag(WT.ED) - WT.ED['TowerBsHt'] EI = np.interp(z_test, WT.Twr.s_span, WT.Twr.EI[0, :]) kappa = np.interp(z_test, WT.Twr.s_span, WT.Twr.PhiK[0][0, :]) qx = KF.X_hat[KF.iX['ut1']] KF.M_sim = [qx * EI[i] * kappa[i] / 1000 for i in range(len(z_test))] # in [kNm] KF.M_ref = [ KF.df['TwHt{:d}MLyt'.format(i + 1)].values for i in range(len(z_test)) ] # in [kNm] return KF.M_sim, KF.M_ref