analyticsClass.py 文件源码

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

项目:pslab-python 作者: fossasia 项目源码 文件源码
def amp_spectrum(self, v, si, nhar=8):  
        # voltages, samplimg interval is seconds, number of harmonics to retain
        from numpy import fft
        NP = len(v)
        frq = fft.fftfreq(NP, si)[:NP/2]    # take only the +ive half of the frequncy array
        amp = abs(fft.fft(v)[:NP/2])/NP     # and the fft result
        index =  amp.argmax()               # search for the tallest peak, the fundamental
        if index == 0:                      # DC component is dominating
            index =  amp[4:].argmax()       # skip frequencies close to zero
        return frq[:index*nhar], amp[:index*nhar]   # restrict to 'nhar' harmonics
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号