def SigmaTemporal(THist):
    numSec, numOut, numIn, numFreq = THist.shape

    sHist = np.zeros((numSec, numOut, numFreq))

    for iSec in range(numSec):
        sHist[iSec, ...] = FreqTrans.Sigma(THist[iSec, ...])

    return sHist
Exemple #2
0
plt.figure()
plt.title(str(W_theshold_dB) + 'dB Bandwidth')
#overSamp = numSampList / numSampMin
plt.loglog(numSampList, np.asarray(binList), '-*')
plt.xlabel('Number of Samples')
plt.ylabel('Number of bins')
plt.grid('on')
plt.show

#%% Signal length - Window only
numSampList = np.arange(100, 1001, 100)
numSampMax = int(np.max(numSampList))
numSampMin = int(np.min(numSampList))
overSamp = numSampList / numSampMin

optSpec = FreqTrans.OptSpect(dftType = 'czt', freqRate = 1 * hz2rps, smooth = ('box', 1))
#optSpec.scaleType = 'density'
optSpec.winType = ('tukey', 0.0)
optSpec.freq = np.linspace(0, 0.05*np.pi, numSampMin-1)

sig = np.ones(numSampMax)
noiseSamples = np.random.randn(numSampMax)
noiseLev = 0.0
sig += noiseLev * noiseSamples

P_theshold_dB = -12
plt.figure()
binList = []
for numSamp in numSampList:
    numSamp = int(numSamp)
    
Exemple #3
0
    for iSig, sigOut in enumerate(sigOutList):
        outSig[iSig] = seg[sigOut]
#        outSig[iSig] = seg['Surf'][sigOut]

#        plt.plot(oDataSegs[iSeg]['time_s'], outSig[iSig])

    outList.append(outSig)

#%% Estimate the frequency response function
# Define the excitation frequencies
freqRate_hz = 50
freqRate_rps = freqRate_hz * hz2rps
optSpec = FreqTrans.OptSpect(dftType='czt',
                             freqRate=freqRate_rps,
                             smooth=('box', 3),
                             winType=('tukey', 0.2),
                             detrendType='Linear')

# Excited Frequencies per input channel
optSpec.freq = np.asarray(freqExc_rps)
optSpec.freqInterp = np.sort(optSpec.freq.flatten())

# Null Frequencies
freqGap_rps = optSpec.freq.flatten()[0:-1] + 0.5 * np.diff(
    optSpec.freq.flatten())
optSpec.freqNull = freqGap_rps
optSpec.freqNullInterp = True

# FRF Estimate
freq_rps = []
Exemple #4
0
pi = np.pi

hz2rps = 2 * pi
rps2hz = 1 / hz2rps

rad2deg = 180 / pi
deg2rad = 1 / rad2deg

mag2db = control.mag2db
db2mag = control.db2mag

#%%
W_dB = -20.0
W = db2mag(W_dB)

fBinSel = FreqTrans.LeakageGoal(W, winType='Dirichlet')[0]

#%%
freqRate_hz = 50
freqRate_rps = freqRate_hz * hz2rps
dt = 1 / freqRate_hz

freqMinDes_hz = 0.1
numCyclesDes = 3  # Plan for 3

freqStepDes_hz = 0.1

#%% Excitation
numCycles = 6  # Need 6!
numChan = 2
ampInit = 1
Exemple #5
0
    iSide1 = np.argwhere(bins > binPeak[0])[0][0] - 20
    iStart = np.argwhere(Mfit_dB[:iSide1] < M_dB[:iSide1])[-1][0]
    ax2.plot(bins[iStart:],
             Mfit_dB[iStart:],
             color=color,
             linestyle=':',
             label=str(winLabel) + ' Approx')

    print(
        str(winLabel) + 'binMin: ' + str(bins[iStart]) + ' a: ' +
        str(popt[0]) + ' s: ' + str(popt[1]))

# ax1.set_ylabel("Amplitude")
# ax1.set_xlabel("Sample")
# ax1.grid(True)
# ax1.set_ylim([0, 1.1])
# ax1.legend()

ax2.set_xlim([0, 10])
ax2.set_ylim([-80, 10])
ax2.grid(True)
ax2.set_ylabel("Normalized Power Magnitude [dB]")
ax2.set_xlabel("Normalized Bin")
ax2.legend(loc='upper right', framealpha=1)

fig2.set_size_inches([6.4, 3.6])
fig2.tight_layout()

if False:
    FreqTrans.PrintPrettyFig(fig2, 'WindowFunc.pgf')
        v = max(v, np.abs(objServo.v))
        a = max(a, np.abs(objServo.a))
        av = max(av, a*v)

    print(amp, p, v, a, av)

    pCmdList.append(pCmd)
    pOutList.append(pOut)

    if True:
        plt.figure(1)
        plt.plot(time_s, pCmd, time_s, pOut)


#%% Plot the Excitation Spectrum
optSpec = FreqTrans.OptSpect(dftType = 'czt', freqRate = freqRate_hz * hz2rps, freq = freqExc_rps, smooth = ('box', 3), winType = 'rect')

plt.figure(2)
TxyList = []
CxyList = []
PxxList = []
PyyList = []
PxyList = []
for i, pOut in enumerate(pOutList):
    pCmd = pCmdList[i]
    freq_rps, Txy, Cxy, Pxx, Pyy, Pxy = FreqTrans.FreqRespFuncEst(pCmd, pOut, optSpec)
    gain_dB, phase_deg = FreqTrans.GainPhase(Txy)
    freq_hz = freq_rps * rps2hz

    freq_hz = np.squeeze(freq_hz)
    gain_dB = np.squeeze(gain_dB)
inKeep = sysCtrl.InputName + sysPlantDist.InputName[2:]
outKeep = sysCtrl.OutputName + sysPlantDist.OutputName
sysLoopOut = ConnectName([sysCtrl, sysPlantDist], connectNames, inKeep, outKeep) # Lo = GK

# Closed-Loop
connectNames = sysLoopOut.OutputName[2:]
inKeep = sysLoopOut.InputName[:2] + sysLoopOut.InputName[4:]
outKeep = sysLoopOut.OutputName
sysCL = ConnectName([sysLoopOut], connectNames, inKeep, outKeep)

# Loop Lo - (e -> z)
sysLo = sysLoopOut[2:4, 0:2]
sysLo.InputName = sysLoopOut.InputName[0:2]
sysLo.OutputName = sysLoopOut.OutputName[2:4]

LoLinNom = FreqTrans.FreqResp(sysLo, freqLin_rps)

# Loop To - (r -> z)
sysTo = sysCL[2:4, 0:2]
sysTo.InputName = sysCL.InputName[0:2]
sysTo.OutputName = sysCL.OutputName[2:4]

ToLinNom = FreqTrans.FreqResp(sysTo, freqLin_rps)

# Loop So
sysSo = np.eye(2) - sysTo

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

pIn = 0.5 * control.ss([],[],[],np.diag(pSigma))
freqLin_hz = np.linspace(1e-1, 1e1, 400)
freqLin_rps = freqLin_hz * hz2rps

plantK11 = 1.0 ; plantWn11 = 3 * hz2rps; plantD11 = 0.2;
plantK12 = 0.5 ; plantWn12 = 5 * hz2rps; plantD12 = 0.3;
plantK21 = 0.25; plantWn21 = 4 * hz2rps; plantD21 = 0.1;
plantK22 = 1.0 ; plantWn22 = 6 * hz2rps; plantD22 = 0.4;

sysPlant = control.tf([[[0, 0, plantK11 * plantWn11**2], [0, 0, plantK21 * plantWn21**2]],
                       [[0, 0, plantK12 * plantWn12**2], [0, 0, plantK22 * plantWn22**2]]],
                      [[[1, 2.0*plantD11*plantWn11, plantWn11**2], [1, 2.0*plantD21*plantWn21, plantWn21**2]],
                       [[1, 2.0*plantD12*plantWn12, plantWn12**2], [1, 2.0*plantD22*plantWn22, plantWn22**2]]])

# Plant Response
TLinNom = FreqTrans.FreqResp(sysPlant, freqLin_rps)


#%% 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)
freqGap_rps = freqExc_rps[0:-1] + 0.5 * np.diff(freqExc_rps)
Exemple #9
0
    plt.plot(oDataSegs[iSeg]['time_s'], oDataSegs[iSeg]['vIas_mps'])

#    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][0])
#    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][1])
#    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][2])
#    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][0])
#    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][1])
#    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][2])


#%% Estimate the frequency response function
# Define the excitation frequencies
freqRate_hz = 50
freqRate_rps = freqRate_hz * hz2rps
optSpec = FreqTrans.OptSpect(dftType = 'czt', freqRate = freqRate_rps, smooth = ('box', 3), winType = ('tukey', 0.2), detrendType = 'Linear')

# Excited Frequencies per input channel
optSpec.freq = np.asarray(freqExc_rps)

# FRF Estimate
T = []
C = []
for iSeg, seg in enumerate(oDataSegs):

    freq_rps, Teb, Ceb, Pee, Pbb, Peb = FreqTrans.FreqRespFuncEst(vExcList[iSeg], vFbList[iSeg], optSpec)
    _       , Tev, Cev, _  , Pvv, Pev = FreqTrans.FreqRespFuncEst(vExcList[iSeg], vCmdList[iSeg], optSpec)

    freq_hz = freq_rps * rps2hz

    # Form the Frequency Response
Exemple #10
0
sysLoopIn = ConnectName([sysPlantDist, sysCtrl], connectNames, inKeep, outKeep)

# Closed-Loop (connect [uCntrl])
connectNames = sysLoopIn.OutputName[0:2]
inKeep = sysLoopIn.InputName[:2] + sysLoopIn.InputName[4:]
outKeep = sysLoopIn.OutputName
sysCL = ConnectName([sysLoopIn], connectNames, inKeep, outKeep)

# Loop Li - (uExc -> uCtrl)
sysLi = -sysLoopIn[
    0:2, 4:
    6]  # Li = KG, u_e to u # FIXIT - YES Negative : sysLi.dcgain() = array([[0.5, 0.25], [0.125, 0.5]])
sysLi.InputName = sysLoopIn.InputName[4:6]
sysLi.OutputName = sysLoopIn.OutputName[0:2]

LiLinNom = FreqTrans.FreqResp(sysLi, freqLin_rps)

# Loop Ti - (uExc -> uCtrl)
sysTi = -sysCL[
    0:2, 2:
    4]  # FIXIT - YES Negative : sysTi.dcgain() = array([[0.32394366, 0.11267606], [0.05633803, 0.32394366]])
sysTi.InputName = sysCL.InputName[2:4]
sysTi.OutputName = sysCL.OutputName[0:2]

TiLinNom = FreqTrans.FreqResp(sysTi, freqLin_rps)

sysSi = (np.eye(2) - sysTi)

pStd = [0.0, 0.0]
mStd = [1.0, 1.0]
    plt.plot(oDataSegs[iSeg]['time_s'], oDataSegs[iSeg]['vIas_mps'])

    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][0])
    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][1])
    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][2])
    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][0])
    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][1])
    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][2])

#%% Estimate the frequency response function
# Define the excitation frequencies
freqRate_hz = 50
freqRate_rps = freqRate_hz * hz2rps
optSpec = FreqTrans.OptSpect(dftType='czt',
                             freqRate=freqRate_rps,
                             smooth=('box', 3),
                             winType=('tukey', 0.0),
                             detrendType='Linear')

# Excited Frequencies per input channel
optSpec.freq = np.asarray(freqExc_rps)
optSpec.freqInterp = np.sort(optSpec.freq.flatten())

# Null Frequencies
freqNull_rps = optSpec.freqInterp[0:-1] + 0.5 * np.diff(optSpec.freqInterp)
optSpec.freqNull = freqNull_rps
optSpec.freqNullInterp = True

# FRF Estimate
TaEstNomList = []
TaEstUncList = []
Exemple #12
0
x, ampChirpX, freqChirp_rps = GenExcite.Chirp(freqInit_rps,
                                              freqFinal_rps,
                                              time_s,
                                              ampInit,
                                              ampFinal,
                                              freqType='linear',
                                              ampType='linear',
                                              initZero=1)

# Simulate the excitation through the system
time_s, y, _ = signal.lsim(sys, x, time_s)
y = np.atleast_2d(y)

# Estimate the transfer function
optSpec = FreqTrans.OptSpect(freqRate=freqRate_rps,
                             smooth=('box', 1),
                             winType=('tukey', 0.0))
freq_rps, Txy, Cxy, Pxx, Pyy, Pxy = FreqTrans.FreqRespFuncEst(x, y, optSpec)
gain_dB, phase_deg = FreqTrans.GainPhase(Txy)
freq_hz = freq_rps * rps2hz

freq_hz = np.squeeze(freq_hz)
gain_dB = np.squeeze(gain_dB)
phase_deg = np.unwrap(np.squeeze(phase_deg) * deg2rad) * rad2deg
Cxy = np.squeeze(Cxy)

#%% Multisine signal with CZT
numChan = 1
numCycles = 1

freqMinDes_rps = freqInit_rps * np.ones(numChan)
Exemple #13
0
        ax[iChan].grid(True)
    ax[iChan].set_xlabel('Time (s)')

if True:
    fig, ax = plt.subplots(ncols=1, nrows=numChan, sharex=True)
    for iChan in range(0, numChan):
        for iElem in sigIndx[iChan]:
            ax[iChan].plot(time_s, sigElem[iElem])
        ax[iChan].set_ylabel('Amplitude (nd)')
        ax[iChan].grid(True)
    ax[iChan].set_xlabel('Time (s)')

#%% Plot the Excitation Spectrum

## Compute Spectrum of each channel
optFFT = FreqTrans.OptSpect(freqRate=freqRate_hz * hz2rps)
optMAT = FreqTrans.OptSpect(dftType='dftmat', freqRate=freqRate_hz * hz2rps)
optCZT = FreqTrans.OptSpect(dftType='czt', freqRate=freqRate_hz * hz2rps)

freq_fft = []
P_dB_fft = []
freq_mat = []
P_dB_mat = []
freq_czt = []
P_dB_czt = []

for iChan, sig in enumerate(sigList):
    freq_rps_fft, _, P_fft = FreqTrans.Spectrum(sig, optFFT)
    freq_fft.append(freq_rps_fft * rps2hz)
    P_dB_fft.append(20 * np.log10(P_fft))
Exemple #14
0
rps2hz = 1/hz2rps

rad2deg = 180/pi
deg2rad = 1/rad2deg

mag2db = control.mag2db
db2mag = control.db2mag


#%% Define the frequency selection and distribution of the frequencies into the signals
# W_dB = -20.0
# W = db2mag(W_dB)
# binSel = FreqTrans.LeakageGoal(W, winType = 'rect')[0]

binSel = 1
W = FreqTrans.DirichletApprox(np.asarray([binSel]))

numChan = 1
freqRate_hz = 50
numCycles = 1

freqMaxDes_rps = 15 * hz2rps *  np.ones(numChan)
freqStepDes_rps = (20 / 50) * hz2rps
tBinWidth = FreqTrans.FreqStep2TimeBin(freqStepDes_rps)
timeDur_s = binSel * tBinWidth
freqMinDes_rps = (1/timeDur_s) * hz2rps * np.ones(numChan)

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)
inList = [sysOL.InputName.index(s) for s in ['cmdP', 'cmdQ', 'cmdR']]
outList = [sysOL.OutputName.index(s) for s in ['fbP', 'fbQ', 'fbR']]

sysSimOL = sysOL[outList, :]
sysSimOL = sysOL[:, inList]

# Linear System Response
gainLin_mag, phaseLin_rad, _ = control.freqresp(sysSimOL, omega=freqLin_rps)

TxyLin = gainLin_mag * np.exp(1j * phaseLin_rad)

gainLin_dB = 20 * np.log10(gainLin_mag)
phaseLin_deg = np.unwrap(phaseLin_rad) * rad2deg
rCritLin_mag = np.abs(TxyLin - (-1 + 0j))

sigmaLin_mag, _ = FreqTrans.Sigma(TxyLin)

#%% Excitation
numExc = 3
numCycles = 1
ampInit = 4.0 * deg2rad
ampFinal = ampInit
freqMinDes_rps = 0.1 * hz2rps * np.ones(numExc)
freqMaxDes_rps = 10 * 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)
Exemple #16
0
    ax[iChan].set_xlabel('Time (s)')

if True:
    fig, ax = plt.subplots(ncols=1, nrows=numChan, sharex=True)
    for iChan in range(0, numChan):
        for iElem in sigIndx[iChan]:
            ax[iChan].plot(time_s, sigElem[iElem])
        ax[iChan].set_ylabel('Amplitude (nd)')
        ax[iChan].grid(True)
    ax[iChan].set_xlabel('Time (s)')


#%% Plot the Excitation Spectrum

## Compute Spectrum of each channel
optFFT = FreqTrans.OptSpect(freqRate = freqRate_hz * hz2rps, winType = ('tukey', 0.0), smooth = ('box', 1))
optCZT = FreqTrans.OptSpect(dftType = 'czt', freqRate = freqRate_hz * hz2rps, winType = ('tukey', 0.0), smooth = ('box', 1))

freq_fft = []
P_dB_fft = []
freq_czt = []
P_dB_czt = []

for iChan, sig in enumerate(sigList):
    freq_rps_fft, _, P_fft  = FreqTrans.Spectrum(sig, optFFT)
    freq_fft.append(freq_rps_fft * rps2hz)
    P_dB_fft.append(20*np.log10(P_fft))

    optCZT.freq = freqElem_rps[sigIndx[iChan]]
    freq_rps_czt, _, P_czt  = FreqTrans.Spectrum(sig, optCZT)
    freq_czt.append(freq_rps_czt * rps2hz)
Exemple #17
0
    plt.plot(oDataSegs[iSeg]['time_s'], oDataSegs[iSeg]['vIas_mps'])

#    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][0])
#    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][1])
#    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][2])
#    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][0])
#    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][1])
#    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][2])

#%% Estimate the frequency response function
# Define the excitation frequencies
freqRate_hz = 50
freqRate_rps = freqRate_hz * hz2rps
optSpec = FreqTrans.OptSpect(dftType='czt',
                             freqRate=freqRate_rps,
                             smooth=('box', 3),
                             winType=('tukey', 0.2),
                             detrendType='Linear')

# Excited Frequencies per input channel
optSpec.freq = np.asarray(freqExc_rps)
optSpec.freqInterp = np.sort(optSpec.freq.flatten())

# Null Frequencies
freqGap_rps = optSpec.freq.flatten()[0:-1] + 0.5 * np.diff(
    optSpec.freq.flatten())
optSpec.freqNull = freqGap_rps
optSpec.freqNullInterp = True

# FRF Estimate
T = []
Exemple #18
0
plt.figure()
plt.subplot(3,1,1)
plt.plot(time_s, sig); plt.grid()
plt.ylabel('Signal (nd)');
plt.subplot(3,1,2)
plt.plot(time_s, ampChirp); plt.grid()
plt.ylabel('ampitude (nd)');
plt.subplot(3,1,3)
plt.plot(time_s, freqChirp_rps * rps2hz); plt.grid()
plt.xlabel('Time (s)'); plt.ylabel('Frequency (Hz)')
plt.show()


#%% Plot the Excitation Spectrum
## Compute Spectrum of each channel
optSpect = FreqTrans.OptSpect(freqRate = freqRate_hz)

freq_hz, sigDft, Psd_mag = FreqTrans.Spectrum(sig, optSpect)
Psd_dB = 20*np.log10(Psd_mag)

## Plot Spectrum
plt.figure()
plt.plot(freq_hz[0], Psd_dB[0])
plt.xlabel('frequency (Hz)');
plt.ylabel('Spectrum (dB)');
plt.grid()
plt.show()


#%% Create the output for JSON config
timeFinal_s = time_s[-1]
Exemple #19
0
phaseTiLinNom_deg = np.unwrap(phaseTiLinNom_rad) * rad2deg

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,
                                           X0=0.0,
                                           transpose=False)

vCmdName = sysCL.OutputName[:3]
vCmd = out[:3]

zName = sysCL.OutputName[-7:]
z = out[-7:]

#v = -(vCmd - vExc)
v = vCmd  # FIXIT

#%% Estimate the frequency response function
optSpec = FreqTrans.OptSpect(dftType='czt',
                             freqRate=freqRate_rps,
                             smooth=('box', 3),
                             winType=('tukey', 0.0),
                             detrendType='Linear',
                             interpType='linear')

# Excited Frequencies per input channel
optSpec.freq = freqChan_rps
optSpec.freqInterp = freqExc_rps

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

# FRF Estimate
freq_rps, Txy, Cxy, Pxx, Pyy, Pxy, TxyUnc, PxxNull, Pnn = FreqTrans.FreqRespFuncEstNoise(
    vExc, v, optSpec)
# _       , Txy, Cxy, _  , Pvv, Pev = FreqTrans.FreqRespFuncEst(vExc, v, optSpec)
Exemple #21
0
    plt.plot(oDataSegs[iSeg]['time_s'], oDataSegs[iSeg]['vIas_mps'])

    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][0])
    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][1])
    plt.plot(oDataSegs[iSeg]['time_s'], vExcList[iSeg][2])
    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][0])
    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][1])
    plt.plot(oDataSegs[iSeg]['time_s'], vFbList[iSeg][2])

#%% Estimate the frequency response function
# Define the excitation frequencies
freqRate_hz = 50
freqRate_rps = freqRate_hz * hz2rps
optSpec = FreqTrans.OptSpect(dftType='czt',
                             freqRate=freqRate_rps,
                             smooth=('box', 3),
                             winType=('tukey', 0.2),
                             detrendType='Linear')

# Excited Frequencies per input channel
optSpec.freq = np.asarray(freqExc_rps)

# FRF Estimate
LiEstNomList = []
LiEstCohList = []
svLiEstNomList = []
for iSeg, seg in enumerate(oDataSegs):

    freq_rps, Teb, Ceb, Pee, Pbb, Peb = FreqTrans.FreqRespFuncEst(
        vExcList[iSeg], vExcList[iSeg] + vFbList[iSeg], optSpec)
    # _       , Tev, Cev, _  , Pvv, Pev = FreqTrans.FreqRespFuncEst(vExcList[iSeg], vCmdList[iSeg], optSpec)