def test_pcorrelogram_class(): p = pcorrelogram(marple_data, lag=16) p() print(p) p = pcorrelogram(data_two_freqs(), lag=16) p.plot() print(p)
def create_all_psd(): f = pylab.linspace(0, 1, 4096) pylab.figure(figsize=(12,8)) # MA model p = spectrum.pma(xx, 64,128); p(); p.plot() """ #ARMA 15 order a, b, rho = spectrum.arma_estimate(data, 15,15, 30) psd = spectrum.arma2psd(A=a,B=b, rho=rho) newpsd = tools.cshift(psd, len(psd)//2) # switch positive and negative freq pylab.plot(f, 10 * pylab.log10(newpsd/max(newpsd)), label='ARMA 15,15') """ # YULE WALKER p = spectrum.pyule(xx, 7 , NFFT=4096, scale_by_freq=False); p.plot() # equivalent to # plot([x for x in p.frequencies()] , 10*log10(p.psd)); grid(True) #burg method p = spectrum.pburg(xx, 7, scale_by_freq=False); p.plot() #pcovar p = spectrum.pcovar(xx, 7, scale_by_freq=False); p.plot() #pmodcovar p = spectrum.pmodcovar(xx, 7, scale_by_freq=False); p.plot() # correlogram p = spectrum.pcorrelogram(xx, lag=60, NFFT=512, scale_by_freq=False); p.plot() # minvar p = spectrum.pminvar(xx, 7, NFFT=256, scale_by_freq=False); p.plot() # pmusic p = spectrum.pmusic(xx, 10,4, scale_by_freq=False); p.plot() # pmusic p = spectrum.pev(xx, 10, 4, scale_by_freq=False); p.plot() # periodogram p = spectrum.Periodogram(xx, scale_by_freq=False); p.plot() # legend( ["MA 32", "pyule 7", "pburg 7", "pcovar", "pmodcovar", "correlogram", "minvar", "pmusic", "pev", "periodgram"]) pylab.ylim([-80,80])
def create_all_psd(): f = pylab.linspace(0, 1, 4096) pylab.figure(figsize=(12, 8)) # MA model p = spectrum.pma(xx, 64, 128) p() p.plot() """ #ARMA 15 order a, b, rho = spectrum.arma_estimate(data, 15,15, 30) psd = spectrum.arma2psd(A=a,B=b, rho=rho) newpsd = tools.cshift(psd, len(psd)//2) # switch positive and negative freq pylab.plot(f, 10 * pylab.log10(newpsd/max(newpsd)), label='ARMA 15,15') """ # YULE WALKER p = spectrum.pyule(xx, 7, NFFT=4096, scale_by_freq=False) p.plot() # equivalent to # plot([x for x in p.frequencies()] , 10*log10(p.psd)); grid(True) #burg method p = spectrum.pburg(xx, 7, scale_by_freq=False) p.plot() #pcovar p = spectrum.pcovar(xx, 7, scale_by_freq=False) p.plot() #pmodcovar p = spectrum.pmodcovar(xx, 7, scale_by_freq=False) p.plot() # correlogram p = spectrum.pcorrelogram(xx, lag=60, NFFT=512, scale_by_freq=False) p.plot() # minvar p = spectrum.pminvar(xx, 7, NFFT=256, scale_by_freq=False) p.plot() # pmusic p = spectrum.pmusic(xx, 10, 4, scale_by_freq=False) p.plot() # pmusic p = spectrum.pev(xx, 10, 4, scale_by_freq=False) p.plot() # periodogram p = spectrum.Periodogram(xx, scale_by_freq=False) p.plot() # legend([ "MA 32", "pyule 7", "pburg 7", "pcovar", "pmodcovar", "correlogram", "minvar", "pmusic", "pev", "periodgram" ]) pylab.ylim([-80, 80])
eps = np.finfo(float).tiny # grilla de sampleo temporal tt = np.linspace(0, (N-1)/fs, N).flatten() dd = 0.5 # prestar atención que las tuplas dentro de los diccionarios también pueden direccionarse mediante "ii" #data = np.sin( 2*np.pi*(N/4+dd)*df*tt) + np.sqrt(0.1)*np.random.randn(N) data = np.sin( 2*np.pi*(N/4+dd)*df*tt) + np.sin( 2*np.pi*(N/4+10+dd)*df*tt) + np.sqrt(0.1)*np.random.randn(N) # No paramétricos pP = sp.Periodogram(data, sampling=fs, NFFT = N ) _, pW = sg.welch(data, fs=fs, nfft=N, window='hanning', nperseg=int(np.round(N/3)) ) pBT = sp.pcorrelogram(data, sampling=fs, NFFT = N, lag=int(np.round(N/5)), window='hamming') pMT = sp.MultiTapering(data, sampling=fs, NFFT = N, NW=2 ) # Paramétricos pEig = sp.pev(data, 30, NFFT=N ) pCov = sp.pmodcovar(data, 30, NFFT = N ) pARMA = sp.parma(data, 8, 8, 30, NFFT=N) sp.pma description = ['Per', 'Welch', 'BT', 'MT', 'Eig', 'MCov', 'ARMA' ]
def test_pcorrelogram_class(): p = pcorrelogram(marple_data, lag=16) p() print(p)