H = FreqTrans.Hann(fBin, N) Hmag = np.abs(H) Hmax = np.nanmax(Hmag) Hnorm_mag = Hmag / Hmax Hnorm_dH = mag2db(Hnorm_mag) Happrox_mag = FreqTrans.HannApprox(fBin) Happrox_dH = mag2db(Happrox_mag) fig = 1 fig = FreqTrans.PlotGainType(fBin, Dnorm_mag, None, None, None, fig=fig, dB=True, linestyle='-', color='b', label='Dirichlet Function') fig = FreqTrans.PlotGainType(fBin, Dapprox_mag, None, None, None, fig=fig, dB=True, linestyle=':', color='b', label='Dirichlet Approximation') fig = FreqTrans.PlotGainType(fBin,
fig.suptitle(inName + ' to ' + outName, size=20) # ax[0].set_ylim(-2, 2) #%% Bode Mag - Noise Estimation Validation if False: for iPlot, io in enumerate(ioArray): iOut, iIn = io outName = outPlot[iOut] inName = inPlot[iIn] fig = 100 + iPlot fig = FreqTrans.PlotGainType(freqLin_hz, gainLaLinNom_mag[iOut, iIn], coher_nd=np.ones_like(freqLin_hz), fig=fig, color='k', label='Linear') fig = FreqTrans.PlotGainType(freq_hz[0], gainLaEstNom_mag[iOut, iIn], LaEstCoh[iOut, iIn], fig=fig, color='b', label='Estimation (MIMO)') fig = FreqTrans.PlotGainType(freq_hz[0, sigIndx[iIn]], gainLaEstNom_mag[iOut, iIn, sigIndx[iIn]], SaEstCoh[iOut, iIn, sigIndx[iIn]], fig=fig, color='g', label='Estimation (SIMO)')
nBack_temp = np.copy(nBack) # nBack_temp[np.isnan(nBack_temp)] = 0.0 nRL_temp = np.copy(nRL) nRL_temp[np.isnan(nRL_temp)] = 1.0 nDF = nSat_temp * nDelay * nBack_temp * nRL_temp # Linear System sysLin = control.tf([objServo.freqNat_rps**2], [1, 2*objServo.damp*objServo.freqNat_rps, objServo.freqNat_rps**2]) nLin = FreqTrans.FreqResp(sysLin, freqExc_rps) #% Plot fig = None fig = FreqTrans.PlotGainType(cmd, np.abs(nSat), np.angle(nSat, deg=True), fig=fig, dB = False, label = 'Saturation Limit') fig = FreqTrans.PlotGainType(cmd, np.abs(nDelay), np.angle(nDelay, deg=True), fig=fig, dB = False, label = 'Time Delay') # fig = FreqTrans.PlotGainType(cmd, np.abs(nLim), np.angle(nLim, deg=True), fig=fig, dB = False, label = 'Hard Limit with Freeplay') # fig = FreqTrans.PlotGainType(cmd, np.abs(nCmdLim), np.angle(nCmdLim, deg=True), fig=fig, dB = False, label = 'Command Limit') fig = FreqTrans.PlotGainType(cmd, np.abs(nBack), np.angle(nBack, deg=True), fig=fig, dB = False, label = 'Backlash Limit') fig = FreqTrans.PlotGainType(cmd, np.abs(nRL), np.angle(nRL, deg=True), fig=fig, dB = False, label = 'Rate Limit') fig = FreqTrans.PlotGainType(cmd, np.abs(nDF), np.angle(nDF, deg=True), fig=fig, dB = False, label = 'Describing Function') ax = fig.get_axes() ax[0].set_xscale("linear") # ax[0].set_ylabel("|NL/L|") ax[1].set_xscale("linear") ax[1].set_xlim(left = 0, right = 20) ax[1].set_ylim(bottom = -90, top = 0) ax[0].set_ylabel('Normalized Gain [-]') ax[1].set_xlabel('Normalized Input Amplitude')