def test_pcovar(): p = pcovar(data_cosine(), 15, NFFT=4096, scale_by_freq=True) p() p = pcovar(marple_data, 15, NFFT=4096) p() print(p.get_converted_psd('centerdc')) return p.psd
def test_pmtm(): data = data_cosine(N=64, A=0.1, sampling=1024, freq=200) res = pmtm(data, 2.5, 4, show=False) res = pmtm(data, 2.5, show=False) res = pmtm(data, 2.5, show=False, method="eigen") res = pmtm(data, 2.5, show=False, method="unity") res = pmtm(data, 2.5, method="eigen", show=True) res = pmtm(data, 2.5, method="adapt", show=True) #res = pmtm(data, 2.5, show=False, method="eigen", show=True) # e and v must be provided together try: res = pmtm(data, 2.5, show=False, e=1, v=None) assert False except: assert True # provide v and e v, e = dpss(64, 4, 2) pmtm(marple_data, NW=4, k=2, v=v, e=e) try: pmtm(marple_data, NW=None, k=2) assert False except: assert True
def test_pmtm(): data = data_cosine(N=64, A=0.1, sampling=1024, freq=200) res = pmtm(data, 2.5, 4, show=False) res = pmtm(data, 2.5, show=False) res = pmtm(data, 2.5, show=False, method="eigen") res = pmtm(data, 2.5, show=False, method="unity") res = pmtm(data, 2.5, method="eigen", show=True) res = pmtm(data, 2.5, method="adapt", show=True) #res = pmtm(data, 2.5, show=False, method="eigen", show=True) # e and v must be provided together try: res = pmtm(data, 2.5, show=False, e=1, v=None) assert False except: assert True # provide v and e v,e = dpss(64,4,2) pmtm(marple_data, NW=4, k=2, v=v, e=e); try: pmtm(marple_data, NW=None, k=2); assert False except: assert True
def test_pcovar(): p = pcovar(data_cosine(), 15, NFFT=4096, scale_by_freq=True) p() print(p) p = pcovar(marple_data, 15, NFFT=4096) p() print(p) print(p.get_converted_psd('centerdc')) return p.psd
def test_pmusic(): p = pmusic(marple_data, 15, NSIG=11) p() p = pmusic(data_cosine(), 15, NSIG=11, verbose=True) p() print(p) # test verbosity of the _get_signal_space function spectrum_set_level("DEBUG") pmusic(data_two_freqs(), 15, threshold=1)() pmusic(data_two_freqs(), 15, NSIG=11, verbose=True)() pmusic(data_two_freqs(), 15, criteria="mdl")() # pmusic(data_two_freqs(), 15, NSIG=0)()
def test_pmusic(): p = pmusic(marple_data, 15, NSIG=11) p() p = pmusic(data_cosine(), 15, NSIG=11) p() print(p)
def test_eigen_parameters(): psd, s = ev(data_cosine(), 15) psd, s = ev(data_cosine(), 15, NSIG=11) psd, s = ev(data_cosine(), 15, threshold=2)
def test_pmtm(): data = data_cosine(N=64, A=0.1, sampling=1024, freq=200) res = pmtm(data, 2.5, 4, show=False) res = pmtm(data, 2.5, show=False)
def test_pev(): p = pev(marple_data, 15, NSIG=11) p() p = pev(data_cosine(), 15, NSIG=11, verbose=True) p() print(p)
hamming = Window(len(x), name='hamming') f, pxx = sci.periodogram(x, window=hamming.data, fs=Fs, nfft=len(x), scaling='spectrum') pwrest = pxx.max() idx = pxx.argmax() plt.subplot(312) plt.plot(f, pxx) plt.title('Periodograma') plt.xlabel('Frequência') plt.ylabel('Potência (W)') plt.grid() plt.axis([0, 2 * fc, 0, A**2]) print('A potência máxima ocorre em ', f[idx], ' Hz') print('A potência estimada é', pwrest) plt.subplot(313) #construindo todo o procedimento com as funções da spectrum import spectrum as spec data = spec.data_cosine(N=len(x), A=10, sampling=Fs, freq=fc) p = spec.Periodogram(x, sampling=Fs, window='hamming') p.run() #Recomputa a psd caso 'x' tenha sido alterado p.plot() plt.title("Periodograma (dB) da Spectrum") plt.tight_layout() plt.show()