frequency_estimator.py 文件源码

python
阅读 50 收藏 0 点赞 0 评论 0

项目:NetPower_TestBed 作者: Vignesh2208 项目源码 文件源码
def freq_from_HPS(sig, fs):
    """
    Estimate frequency using harmonic product spectrum (HPS)

    """
    windowed = sig * blackmanharris(len(sig))

    from pylab import subplot, plot, log, copy, show

    # harmonic product spectrum:
    c = abs(rfft(windowed))
    maxharms = 3
    #subplot(maxharms, 1, 1)
    #plot(log(c))
    for x in range(2, maxharms):
        a = copy(c[::x])  # Should average or maximum instead of decimating
        # max(c[::x],c[1::x],c[2::x],...)
        c = c[:len(a)]
        i = argmax(abs(c))
        true_i = parabolic(abs(c), i)[0]
        print 'Pass %d: %f Hz' % (x, fs * true_i / len(windowed))
        c *= a
        #subplot(maxharms, 1, x)
        #plot(log(c))
    #show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号