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,
                                                                     iIn],
                                         coher_nd=np.ones_like(freqLin_hz),
                                         fig=fig,
                                         color='k',
                                         label='Linear')
        fig = FreqTrans.PlotVectorMargin(freq_hz[0],
                                         rCritLaEstNom_mag[iOut, iIn],
                                         vmUnc_mag=rCritLaEstUnc_mag[iOut,
                                                                     iIn],
                                         coher_nd=LaEstCoh[iOut, iIn],
                                         color='b',
                                         fig=fig,
                                         label='Excitation (MIMO)')
        fig = FreqTrans.PlotVectorMargin(
            freq_hz[0, sigIndx[iIn]],
            rCritLaEstNom_mag[iOut, iIn, sigIndx[iIn]],
            vmUnc_mag=rCritLaEstUnc_mag[iOut, iIn, sigIndx[iIn]],
    ax[0].legend(handles, labels)
    
    fig.suptitle('$L_o$ : ' + '$r_{Exc}$' + ' to ' + '$z$')


#%% Vector Margin Plots - Output Stability
vmLoLinNom_mag, vmLoLinUnc_mag, vmLoLinMin_mag = FreqTrans.VectorMargin(LoLinNom, LoLinUnc, typeUnc = 'circle')
vmLoEstNom_mag, vmLoEstUnc_mag, vmLoEstMin_mag = FreqTrans.VectorMargin(LoEstNom, LoEstUnc, typeUnc = 'circle')

numOut, numIn = LoLinNom.shape[0:-1]
ioArray = np.array(np.meshgrid(np.arange(numOut), np.arange(numIn))).T.reshape(-1, 2)

if True:
    for iPlot, [iOut, iIn] in enumerate(ioArray):
        fig = 30 + iPlot
        fig = FreqTrans.PlotVectorMargin(freqLin_hz, vmLoLinNom_mag[iOut, iIn], cohLoLin_mag[iOut, iIn], vmLoLinUnc_mag[iOut, iIn], fig = fig, linestyle='-', color='k', label='Linear Model')
        fig = FreqTrans.PlotVectorMargin(freq_hz[iIn], vmLoEstNom_mag[iOut, iIn], cohLoEst_mag[iOut, iIn], vmLoEstUnc_mag[iOut, iIn], fig = fig, linestyle='-', marker='.', color='b', label='Estimate [MIMO]')
        fig = FreqTrans.PlotVectorMargin(freq_hz[iIn, sigIndx[iIn]], vmLoEstNom_mag[iOut, iIn, sigIndx[iIn]], cohLoEst_mag[iOut, iIn, sigIndx[iIn]], vmLoEstUnc_mag[iOut, iIn, sigIndx[iIn]], fig = fig, linestyle='None', marker='.', 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) + ']')


#%% Nyquist Plot - Output Stability
LoLinUncMag = np.abs(LoLinUnc)
LoEstUncMag = np.abs(LoEstUnc)
Exemplo n.º 3
0
rCritLiEstCrit_mag, _, _ = FreqTrans.VectorMargin(LiEstCrit, typeUnc='circle')

if True:
    numOut, numIn = LiLinNom.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,
                                         rCritLiLinNom_mag[iOut, iIn],
                                         cohLiLin_mag[iOut, iIn],
                                         rCritLiLinUnc_mag[iOut, iIn],
                                         fig=fig,
                                         linestyle='-',
                                         color='k',
                                         label='Linear Model')
        fig = FreqTrans.PlotVectorMargin(freq_hz[iIn],
                                         rCritLiEstNom_mag[iOut, iIn],
                                         cohLiEst_mag[iOut, iIn],
                                         rCritLiEstUnc_mag[iOut, iIn],
                                         fig=fig,
                                         linestyle='-',
                                         marker='.',
                                         color='b',
                                         label='Estimate [MIMO]')
        fig = FreqTrans.PlotVectorMargin(freq_hz[iIn, sigIndx[iIn]],
                                         rCritLiEstNom_mag[iOut, iIn,
                                                           sigIndx[iIn]],
vmTLinNom_mag, vmTLinUnc_mag, vmTLinMin_mag = FreqTrans.VectorMargin(TLinNom, TLinUnc, typeUnc = 'circle')
vmTEstNom_mag, vmTEstUnc_mag, vmTEstMin_mag = FreqTrans.VectorMargin(TEstNom, TEstUnc, typeUnc = 'circle')

# Sampled Systems
vmTEstSamp_mag = np.zeros((numOut, numIn, nFreq, nSamp), dtype='float')
for iSamp in range(nSamp):
  vmTEstSamp_mag[..., iSamp], _, _ = FreqTrans.VectorMargin(TEstSamp[..., iSamp], typeUnc = 'circle')


numOut, numIn = TLinNom.shape[0:-1]
ioArray = np.array(np.meshgrid(np.arange(numOut), np.arange(numIn))).T.reshape(-1, 2)

if True:
    for iPlot, [iOut, iIn] in enumerate(ioArray):
        fig = None
        fig = FreqTrans.PlotVectorMargin(freqLin_hz, vmTLinNom_mag[iOut, iIn], cohTLin_mag[iOut, iIn], vmTLinUnc_mag[iOut, iIn], fig = fig, linestyle='-', color='k', label='Linear Model')
        fig = FreqTrans.PlotVectorMargin(freq_hz[iIn], vmTEstNom_mag[iOut, iIn], cohTEst_mag[iOut, iIn], vmTEstUnc_mag[iOut, iIn], fig = fig, linestyle='-', marker='.', color='r', label='Estimate [MIMO]')
        fig = FreqTrans.PlotVectorMargin(freq_hz[iIn, sigIndx[iIn]], vmTEstNom_mag[iOut, iIn, sigIndx[iIn]], cohTEst_mag[iOut, iIn, sigIndx[iIn]], vmTEstUnc_mag[iOut, iIn, sigIndx[iIn]], fig = fig, linestyle='-', marker='.', color='b', label='Estimate [SIMO]')

        for iSamp in range(nSamp):
          fig = FreqTrans.PlotVectorMargin(freq_hz[iIn], vmTEstSamp_mag[iOut, iIn, :, iSamp], marker='.', color = 'gray', linestyle='None', fig = fig, label = 'Sampled (MIMO)')

        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('$u_' + str(iIn) + '$ to ' + '$z_' + str(iOut) + '$')
        fig.set_tight_layout(True)
numIn = len(inPlot)
ioArray = np.array(np.meshgrid(np.arange(numOut),
                               np.arange(numIn))).T.reshape(-1, 2)

if False:
    for iPlot, [iOut, iIn] in enumerate(ioArray):
        fig = 10 + iPlot
        for iSeg in range(0, len(oDataSegs)):

            vm_mag = vmLaEstNomList_mag[iSeg][iOut, iIn]
            vmUnc_mag = vmLaEstUncList_mag[iSeg][iOut, iIn]

            fig = FreqTrans.PlotVectorMargin(freq_hz[iIn],
                                             vm_mag,
                                             vmUnc_mag=vmUnc_mag,
                                             coher_nd=LaEstCohList[iSeg][iOut,
                                                                         iIn],
                                             fig=fig,
                                             color=rtsmSegList[iSeg]['color'],
                                             label=oDataSegs[iSeg]['Desc'])

        fig = FreqTrans.PlotVectorMargin(freq_hz[iIn],
                                         0.4 * np.ones_like(freq_hz[iIn]),
                                         fig=fig,
                                         color='r',
                                         linestyle='--',
                                         label='Critical')
        fig.suptitle(inPlot[iIn] + ' to ' + outPlot[iOut])

        ax = fig.get_axes()
        ax[0].set_ylim(0, 2)