# Null Frequencies
optSpec.freqNull = freqGap_rps
optSpec.freqNullInterp = True

# FRF Estimate
freq_rps, Txy, Cxy, Sxx, Syy, Sxy, TxyUnc, SxxNull, Snn = FreqTrans.FreqRespFuncEstNoise(rExc, z, optSpec)
freq_hz = freq_rps * rps2hz

I2 = np.repeat([np.eye(2)], Txy.shape[-1], axis=0).T
ToEstNom = Txy # Txy = Sxy / Sxx
ToEstUnc = -TxyUnc # TxyUnc = np.abs(Sxn / Sxx)
ToEstCoh = Cxy # Cxy = np.abs(Sxy)**2 / (Sxx * Syy)


SoEstNom, SoEstUnc, SoEstCoh = FreqTrans.TtoS(ToEstNom, ToEstUnc, ToEstCoh)
LoEstNom, LoEstUnc, LoEstCoh = FreqTrans.StoL(SoEstNom, SoEstUnc, SoEstCoh)


print(np.sum(SxxNull, axis = -1) / np.sum(Sxx, axis = -1))
print(np.sum(Snn, axis = -1) / np.sum(Syy, axis = -1))
ToEstSNR = np.abs(ToEstNom / ToEstUnc)**2
SoEstSNR = np.abs(SoEstNom / SoEstUnc)**2
LoEstSNR = np.abs(LoEstNom / LoEstUnc)**2


#%% Nyquist Plot - Output Complimentary Sensitivity Function
ToLinUncMag = np.abs(ToLinUnc)
ToEstUncMag = np.abs(ToEstUnc)

numOut, numIn = ToLinNom.shape[0:-1]
ioArray = np.array(np.meshgrid(np.arange(numOut), np.arange(numIn))).T.reshape(-1, 2)
Esempio n. 2
0
# Null Frequencies
optSpec.freqNull = freqGap_rps
optSpec.freqNullInterp = True

# FRF Estimate
freq_rps, Txu, Cxu, Sxx, Syy, Sxy, TxuUnc, SxxNull, Snn = FreqTrans.FreqRespFuncEstNoise(
    uExc, uCtrl, optSpec)
freq_hz = freq_rps * rps2hz

I2 = np.repeat([np.eye(2)], Txu.shape[-1], axis=0).T
TiEstNom = -Txu  # Si = I - Ti
TiEstUnc = TxuUnc  # TxuUnc = np.abs(Sxu / Sxx)
TiEstCoh = Cxu  # Cxy = np.abs(Sxu)**2 / (Sxx * Syy)

SiEstNom, SiEstUnc, SiEstCoh = FreqTrans.TtoS(TiEstNom, TiEstUnc, TiEstCoh)
LiEstNom, LiEstUnc, LiEstCoh = FreqTrans.StoL(SiEstNom, SiEstUnc, SiEstCoh)

print(np.sum(SxxNull, axis=-1) / np.sum(Sxx, axis=-1))

TiEstSNR = np.abs(TiEstNom / TiEstUnc)**2
SiEstSNR = np.abs(SiEstNom / SiEstUnc)**2
LiEstSNR = np.abs(LiEstNom / LiEstUnc)**2

#%%
numFreq = len(freqExc_rps)
numTime = len(time_s)
scaleLinUnc = np.sqrt(numFreq / numTime)
TiLinUnc = scaleLinUnc * FreqTrans.FreqResp(
    sysTiUnc, freqLin_rps)  # Noise STD scaled to Uncertainty by sqrt(numFreq)

I2 = np.repeat([np.eye(2)], TiLinNom.shape[-1], axis=0).T
Esempio n. 3
0
sysSi = (np.eye(2) - sysTi)

pSigma = [0.0, 0.0]
mSigma = [1.0, 1.0]

pIn = 0.5 * control.ss([], [], [], np.diag(pSigma))
mIn = 0.5 * control.ss([], [], [], np.diag(mSigma))
sysTiUnc = sysSi * sysK * (sysR * pIn - sysN * mIn)
gainTiLinUnc_mag, phaseTiLinUnc_rad, _ = control.freqresp(sysTiUnc,
                                                          omega=freqLin_rps)
TiLinUnc = gainTiLinUnc_mag * np.exp(1j * phaseTiLinUnc_rad * deg2rad)

# Ti to Si, Si to Li
SiLinNom, SiLinUnc, _ = FreqTrans.TtoS(TiLinNom, TiLinUnc)
LiLinNom, LiLinUnc, _ = FreqTrans.StoL(SiLinNom, SiLinUnc)

#%% Excitation
numExc = 2
numCycles = 3
ampInit = 1
ampFinal = 1
freqMinDes_rps = 0.1 * hz2rps * np.ones(numExc)
freqMaxDes_rps = 10.1 * hz2rps * np.ones(numExc)
freqStepDes_rps = (10 / freqRate_hz) * hz2rps
methodSW = 'zip'  # "zippered" component distribution

# Generate MultiSine Frequencies
freqExc_rps, sigIndx, time_s = GenExcite.MultiSineComponents(
    freqMinDes_rps, freqMaxDes_rps, freqRate_hz, numCycles, freqStepDes_rps,
    methodSW)
LaEstNomList = []
LaEstUncList = []
LaEstCohList = []

for iSeg, seg in enumerate(oDataSegs):

    freq_rps, Txy, Cxy, Sxx, Syy, Sxy, TxyUnc, SxxNull, Snn = FreqTrans.FreqRespFuncEstNoise(
        vExcList[iSeg], vFbList[iSeg], optSpec)
    freq_hz = freq_rps * rps2hz

    TaEstNom = -Txy  # Sa = I - Ta
    TaEstUnc = TxyUnc  # TxuUnc = np.abs(Sxu / Sxx)
    TaEstCoh = Cxy  # Cxy = np.abs(Sxu)**2 / (Sxx * Suu)

    SaEstNom, SaEstUnc, SaEstCoh = FreqTrans.TtoS(TaEstNom, TaEstUnc, TaEstCoh)
    LaEstNom, LaEstUnc, LaEstCoh = FreqTrans.StoL(SaEstNom, SaEstUnc, SaEstCoh)

    TaEstNomList.append(TaEstNom)
    TaEstUncList.append(TaEstUnc)
    TaEstCohList.append(TaEstCoh)
    SaEstNomList.append(SaEstNom)
    SaEstUncList.append(SaEstUnc)
    SaEstCohList.append(SaEstCoh)
    LaEstNomList.append(LaEstNom)
    LaEstUncList.append(LaEstUnc)
    LaEstCohList.append(LaEstCoh)

    print(np.sum(SxxNull, axis=-1) / np.sum(Sxx, axis=-1))

T_InputNames = sigExcList
T_OutputNames = sigFbList