예제 #1
0
def test_pcovar_plot():
    p = pcovar([1, 2, 3, 4, 5, 6, 7, 8], 2)
    p.plot()
    assert len(p.psd) == 5
    p = pcovar([1, 2, 3, 4, 5, 6, 7, 8, 9], 2)
    p.plot()
    assert len(p.psd) == 5
예제 #2
0
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
예제 #3
0
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 pcovar(var):
    """
    Input: SSTA time series
    """

    nw = 48  # order of an autoregressive prediction model for the signal, used in estimating the PSD.
    nfft = 256  # NFFT (int) – total length of the final data sets (padded with zero if needed

    fs = 1  # default value
    p = pcovar(var, nw, nfft, fs)
    return p
예제 #5
0
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])
예제 #6
0
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])