You can also use scipy.signal.welch to estimate the power spectral density using Welch’s method. Here is an comparison between np.fft.fft and scipy.signal.welch:

from scipy import signal
import numpy as np
import matplotlib.pyplot as plt fs = 10e3
N = 1e5
amp = 2*np.sqrt(2)
freq = 1234.0
noise_power = 0.001 * fs / 2
time = np.arange(N) / fs
x = amp*np.sin(2*np.pi*freq*time)
x += np.random.normal(scale=np.sqrt(noise_power), size=time.shape) # np.fft.fft
freqs = np.fft.fftfreq(time.size, 1/fs)
idx = np.argsort(freqs)
ps = np.abs(np.fft.fft(x))**2
plt.figure()
plt.plot(freqs[idx], ps[idx])
plt.title('Power spectrum (np.fft.fft)') # signal.welch
f, Pxx_spec = signal.welch(x, fs, 'flattop', 1024, scaling='spectrum')
plt.figure()
plt.semilogy(f, np.sqrt(Pxx_spec))
plt.xlabel('frequency [Hz]')
plt.ylabel('Linear spectrum [V RMS]')
plt.title('Power spectrum (scipy.signal.welch)')
plt.show()

 

来自为知笔记(Wiz)

Python power spectral 功率谱的更多相关文章

  1. Power Spectral Density

    对于一个特定的信号来说,有时域与频域两个表达形式,时域表现的是信号随时间的变化,频域表现的是信号在不同频率上的分量.在信号处理中,通常会对信号进行傅里叶变换得到该信号的频域表示,从而得到信号在频域上的 ...

  2. Python power函数

    power函数 from math import pow def power(x, y): if y == 0: return 1 tot = 1 for i in range(y): tot *= ...

  3. [Python] 学习资料汇总

    Python是一种面向对象的解释性的计算机程序设计语言,也是一种功能强大且完善的通用型语言,已经有十多年的发展历史,成熟且稳定.Python 具有脚本语言中最丰富和强大的类库,足以支持绝大多数日常应用 ...

  4. 倒谱(Cepstrum)和线性预测倒谱系数(LPCCs)

    倒谱是表示一帧语音数据特征的一个序列.从periodogram estimate of the power spectrum计算得到的倒谱系数,可以用于基音追踪(pitch tracking),然而, ...

  5. PSD的单位及计算方法[转]

      功率谱密度(PSD)的国际单位 功率谱密度(PSD),单位为:unit^2/Hz代表单位频率上信号的能量,所以是密度谱,幅值代表频段内的有效值平方. 如果是加速度功率谱密度,加速度的单位是m/s^ ...

  6. matplot模块中的pylab

    pylab的目的 Pylab combines the functionality of pyplot with the capabilities of NumPy in a single names ...

  7. 高斯白噪声(white Gaussian noise,WGN)

    本文科普一下高斯白噪声(white Gaussian noise,WGN). 百度百科上解释为“高斯白噪声,幅度分布服从高斯分布,功率谱密度服从均匀分布”,听起来有些晦涩难懂,下面结合例子通俗而详细地 ...

  8. 现代数字信号处理——AR模型

    1. AR模型概念观       AR模型是一种线性预测,即已知N个数据,可由模型推出第N点前面或后面的数据(设推出P点),所以其本质类似于插值,其目的都是为了增加有效数据,只是AR模型是由N点递推, ...

  9. 论文翻译:Speech Enhancement Based on the General Transfer Function GSC and Postfiltering

    论文地址:基于通用传递函数GSC和后置滤波的语音增强 博客作者:凌逆战 博客地址:https://www.cnblogs.com/LXP-Never/p/12232341.html 摘要 在语音增强应 ...

随机推荐

  1. 除法保留小数bit位 + 四舍五入

    /*num1/num2 保留bit 位小数 , 四舍五入*/ #include<bits/stdc++.h> using namespace std; ]; int main() { in ...

  2. Secondary NameNode究竟是做什么的

    Secondary NameNode:它究竟有什么作用? 在hadoop中,有一些命名不好的模块,Secondary NameNode是其中之一.从它的名字上看,它给人的感觉就像是NameNode的备 ...

  3. Python and Bluetooth

    环境 Windows7-64bit + Python2.7.15-64bit + Pybluez 安装pybluez时会报错,处理方法~ 1.安装VCForPython27.msi,这是为了提供vis ...

  4. win7 免安装MariaDB

    1.  官网下载MariaDB的windows版本 地址:https://downloads.mariadb.org/mariadb/10.0.17/ 目前最新版本是10.0.17 2.  下载完成后 ...

  5. mongodb启动失败:child process failed, exited with error number 100

    参考 http://www.dataguru.cn/thread-107361-1-1.html 里面的路径 根据自己的--dbpath的路径  和l--logpath路径去找

  6. 如何查看yum安装路径

    #yum install hdf5 #rpm -qa|grep hdf5 hdf5-1.8.7-1.el6.rf.x86_64 #rpm -ql hdf5-1.8.7-1.el6.rf.x86_64

  7. [问题解决]Fresco设置占位图不显示的问题

    [问题解决]Fresco设置占位图不显示的问题 /** * Created by diql on 2017/02/15. */ 问题说明 本来设置占位图是通过以下方法: public void set ...

  8. python跳出多重循环

    # -*- coding=utf-8 -*- """ 如何结束多重循环,在单层循环中,可以用break跳出循环,那两层,三层呢? """ # ...

  9. PHP之mb_substr使用

    mb_substr (PHP 4 >= 4.0.6, PHP 5, PHP 7) mb_substr - Get part of string mb_substr - 获取部分字符串 Descr ...

  10. 那些年,我们一起误解过的REST

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由sammyshen 发表于云+社区专栏 最近几年REST API越来越流行,特别是随着微服务的概念被广泛接受和应用,很多Web Ser ...