예제 #1
0
def test_arma():
    """arma, check that rho is correct (appendix 10.A )and reproduce figure 10.2"""
    a, b, rho = arma_estimate(marple_data, 20, 20, 40)
    psd = arma2psd(A=a, B=b, rho=rho, NFFT=None)
    psd = arma2psd(A=a, B=b, rho=rho)
    try:
        psd = arma2psd(A=None, B=None, rho=rho)
        assert False
    except:
        assert True
    return psd
예제 #2
0
def test_arma():
    """arma, check that rho is correct (appendix 10.A )and reproduce figure 10.2"""
    a,b, rho = arma_estimate(marple_data, 20, 20, 40)
    psd = arma2psd(A=a,B=b, rho=rho, NFFT=None)
    psd = arma2psd(A=a,B=b, rho=rho)
    try:
        psd = arma2psd(A=None, B=None, rho=rho)
        assert False
    except:
        assert True
    return psd
예제 #3
0
def test_arma_values():
    a, b, rho = arma_estimate(marple_data, 15, 15, 30)
    assert_almost_equal(rho, 0.20050144053393698, 1e-6)

    assert_array_almost_equal(a, numpy.array([
        1.47857824-0.16358208j,  4.32139091-0.86231938j,
        6.04115773-1.77030183j,  6.09285854-3.96367752j,
        4.70699008-3.27199141j,  3.45467782-1.59183506j,
        3.11230094-1.06510595j,  1.55237009+1.09800024j,
        1.05148353+2.2720917j ,  1.68042547+4.9737292j ,
        3.22899406+6.39981425j,  3.16557650+5.92783737j,
        3.47120865+5.48246963j,  2.79508215+3.3238971j ,
        2.13174602+1.51034329j]), decimal=4)
예제 #4
0
def test_arma_values():
    a, b, rho = arma_estimate(marple_data, 15, 15, 30)
    assert_almost_equal(rho, 0.20050144053393698, decimal=6)

    assert_array_almost_equal(a, numpy.array([ 
        1.47857824-0.16358208j,  4.32139091-0.86231938j,
        6.04115773-1.77030183j,  6.09285854-3.96367752j,
        4.70699008-3.27199141j,  3.45467782-1.59183506j,
        3.11230094-1.06510595j,  1.55237009+1.09800024j,
        1.05148353+2.2720917j ,  1.68042547+4.9737292j ,
        3.22899406+6.39981425j,  3.16557650+5.92783737j,
        3.47120865+5.48246963j,  2.79508215+3.3238971j ,
        2.13174602+1.51034329j  
        ]), decimal=4)
예제 #5
0
def test_arma():
    """arma, check that rho is correct (appendix 10.A )and reproduce figure 10.2"""
    a,b, rho = arma_estimate(marple_data, 20,20,40)
    psd = arma2psd(A=a,B=b, rho=rho)
    return psd
plt.xlabel('Frequencies')
plt.ylabel('Power Spectral Density')

#Part 2.3(B)
btWin = signal.hamming(len(y_coordinates_3))
db20 = lambda x: np.log10(np.abs(x)) * 20
phi, f = blackmanTukey(y_coordinates_3, btWin, len(y_coordinates_3))
plt.figure()
plt.plot(x_coordinates_3, db20(phi))
plt.title('Blackman-Tukey')
plt.xlabel('Frequencies')
plt.ylabel('Spectral Estimate')

#Part 2.3(C)
plt.figure()
ar, ma, rho = arma_estimate(y_coordinates_3, 15, 15, 30)
psd = arma2psd(ar, ma, rho=rho, NFFT=4096)
plt.plot(10 * np.log10(psd / max(psd)))
plt.axis([0, 4096, -80, 0])
plt.title('AutoRegressive')
plt.xlabel('Frequencies')
plt.ylabel('Spectral Estimate')

plt.figure()
plt.subplot(2, 1, 1)
# Part 2.5
frequencies = 1000.0  # Sampling frequency
time_stamps_2 = np.arange(1000) / frequencies
signal_1 = np.sin(2 * np.pi * 100 * time_stamps_2)  # with frequency of 100
plt.plot(time_stamps_2, signal_1, color='r', label='Signal_1')
예제 #7
0
def test_arma():
    """arma, check that rho is correct (appendix 10.A )and reproduce figure 10.2"""
    a,b, rho = arma_estimate(marple_data, 20,20,40)
    psd = arma2psd(A=a,B=b, rho=rho)
    return psd