fig = 40 + iPlot fig = FreqTrans.PlotBode(freqLin_hz, gainLoLinNom_mag[iOut, iIn], phaseLoLinNom_deg[iOut, iIn], coher_nd = cohLoLin_mag[iOut, iIn], gainUnc_mag = gainLoLinUnc_mag[iOut, iIn], fig = fig, dB = True, color='k', label='Linear Model') fig = FreqTrans.PlotBode(freq_hz[iIn], gainLoEstNom_mag[iOut, iIn], phaseLoEstNom_deg[iOut, iIn], coher_nd = cohLoEst_mag[iOut, iIn], gainUnc_mag = gainLoEstUnc_mag[iOut, iIn], fig = fig, dB = True, color='b', label='Estimate [MIMO]') fig = FreqTrans.PlotBode(freq_hz[iIn, sigIndx[iIn]], gainLoEstNom_mag[iOut, iIn, sigIndx[iIn]], phaseLoEstNom_deg[iOut, iIn, sigIndx[iIn]], coher_nd = cohLoEst_mag[iOut, iIn, sigIndx[iIn]], gainUnc_mag = gainLoEstUnc_mag[iOut, iIn, sigIndx[iIn]], fig = fig, dB = True, color='g', label='Estimate [SIMO]') ax = fig.get_axes() handles, labels = ax[0].get_legend_handles_labels() handles = [handles[0], handles[3], handles[1], handles[4], handles[2], handles[5]] labels = [labels[0], labels[3], labels[1], labels[4], labels[2], labels[5]] ax[0].legend(handles, labels) fig.suptitle('$L_o$ : ' + '$r_{Exc}$[' + str(iIn) + '] to ' + '$z$[' + str(iOut) + ']') #%% Vector Margin Plots - Output Stability rCritLoLinNom_mag, rCritLoLinUnc_mag, rCritLoLinMin_mag = FreqTrans.DistCrit(LoLinNom, LoLinUnc, typeUnc = 'circle') rCritLoEstNom_mag, rCritLoEstUnc_mag, rCritLoEstMin_mag = FreqTrans.DistCrit(LoEstNom, LoEstUnc, typeUnc = 'circle') if True: numOut, numIn = LoLinNom.shape[0:-1] ioArray = np.array(np.meshgrid(np.arange(numOut), np.arange(numIn))).T.reshape(-1, 2) for iPlot, io in enumerate(ioArray): [iOut, iIn] = io fig = 30 + iPlot fig = FreqTrans.PlotVectorMargin(freqLin_hz, rCritLoLinNom_mag[iOut, iIn], cohLoLin_mag[iOut, iIn], rCritLoLinUnc_mag[iOut, iIn], fig = fig, linestyle='-', color='k', label='Linear Model') fig = FreqTrans.PlotVectorMargin(freq_hz[iIn], rCritLoEstNom_mag[iOut, iIn], cohLoEst_mag[iOut, iIn], rCritLoEstUnc_mag[iOut, iIn], fig = fig, linestyle='-', marker='.', color='b', label='Estimate [MIMO]') fig = FreqTrans.PlotVectorMargin(freq_hz[iIn, sigIndx[iIn]], rCritLoEstNom_mag[iOut, iIn, sigIndx[iIn]], cohLoEst_mag[iOut, iIn, sigIndx[iIn]], rCritLoEstUnc_mag[iOut, iIn, sigIndx[iIn]], fig = fig, linestyle='None', marker='.', color='g', label='Estimate [SIMO]') ax = fig.get_axes()
ax = fig.get_axes() ax[0].set_xlim(0, 10) # ax[0].set_yscale('log') ax[0].set_ylim(0, 2) #%% Vector Margin Plots inPlot = sysCL.InputName[:3] outPlot = [inName.replace('exc', 'fb') for inName in inPlot] numOut = len(outPlot) numIn = len(inPlot) ioArray = np.array(np.meshgrid(np.arange(numOut), np.arange(numIn))).T.reshape(-1, 2) # rCritLaLinNom_mag, rCritLaLinUnc_mag, rCritLaLinLower_mag = FreqTrans.DistCrit( LaLinNom, LaLinUnc, typeUnc='circle') rCritLaEstNom_mag, rCritLaEstUnc_mag, rCritLaEstLower_mag = FreqTrans.DistCrit( LaEstNom, LaEstUnc, typeUnc='circle') if False: for iPlot, io in enumerate(ioArray): iOut, iIn = io outName = outPlot[iOut] inName = inPlot[iIn] fig = 40 + iPlot # fig = FreqTrans.PlotVectorMargin(freqLin_hz, rCritLaLinNom_mag[iOut, iIn], coher_nd = np.ones_like(freqLin_hz), fig = fig, color = 'k', label = 'Linear') fig = FreqTrans.PlotVectorMargin(freqLin_hz, rCritLaLinNom_mag[iOut, iIn], vmUnc_mag=rCritLaLinUnc_mag[iOut,
for i in range(T.shape[-1]): T[..., i] = (Teb[..., i].T @ np.linalg.inv(Tev[..., i].T)).T sigmaNom_mag, _ = FreqTrans.Sigma(T) # Singular Value Decomp # Coherence C = Ceb T_InputName = exc_names T_OutputName = fbName gain_mag, phase_deg = FreqTrans.GainPhase(T, magUnit='mag', phaseUnit='deg', unwrap=True) rCritNom_mag, _, _ = FreqTrans.DistCrit(T, typeUnc='ellipse') #rCritNom_mag, rCritUnc_mag, rCrit_mag = FreqTrans.DistCrit(T, TUnc, typeUnc = 'ellipse') #rCritNom_mag, rCritUnc_mag, rCrit_mag, pCont_mag = FreqTrans.DistCritEllipse(T, TUnc) # Returns closest approach points #%% Sigma Plot Cmin = np.min(np.min(C, axis=0), axis=0) sigmaNom_magMin = np.min(sigmaNom_mag, axis=0) fig = 20 fig = FreqTrans.PlotSigma(freqLin_hz, sigmaLin_mag, coher_nd=np.ones_like(freqLin_hz), fig=fig, fmt='k', label='Linear') fig = FreqTrans.PlotSigma(freq_hz,