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. [转] Scala 的集合类型与数组操作

    [From] https://blog.csdn.net/gongxifacai_believe/article/details/81916659 版权声明:本文为博主原创文章,转载请注明出处. ht ...

  2. Android的启动模式(下)

    Android中的启动模式(下) 在这篇文章中,我会继续跟大家分享有关于Android中启动模式的相关知识.当然,如果对这个启动模式还不完全了解或者没有听过的话,可以先看看我之前写的有关于这个知识点的 ...

  3. 对 云寻觅贴吧(http://tieba.yunxunmi.com/)的简要分析

    1. 云寻觅的用户需求:一方面是很多用户有很多问题,需要高质量的答案,但是搜索引擎无法满足这种需求,百度知道做得不够好,所以用户需要一个平台可以解决他们的问题:另外一方面,又有很多经济良好,时间较为充 ...

  4. Spring Boot Starter列表

    转自:http://blog.sina.com.cn/s/blog_798f713f0102wiy5.html Spring Boot Starter 基本的一共有43种,具体如下: 1)spring ...

  5. shiro学习笔记_0200_认证

    认证,身份验证,验证用户是否合法 在shiro中,用户需要提供principals (身份)和credentials(证明)给shiro,从而应用能验证用户身份: principals:用户的身份信息 ...

  6. apktook 反编译错误

    Exception in thread "main" brut.androlib.err.UndefinedResObject: resource spec: 0x01010490 ...

  7. JavaScript设计模式-9.工厂模式

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. transition过渡效果

    语法:transition: property duration timing-function delay; transition-property 规定设置过渡效果的 CSS 属性的名称.tran ...

  9. R语言数组array函数

    数组是一个可以在两个以上的维度存储数据的R数据对象.例如 - 如果创建尺寸(2,3,4)的数组,那么创建4个矩形矩阵每2行3列.数组只能存储数据类型. 使用 array()函数创建数组.它需要向量作为 ...

  10. 《TCP/IP详解》

    TCP/IP概述 Transmission Control Protocol/Internet Protocol的简写,中译名为传输控制协议/因特网互联协议,又名网络通讯协议,是Internet最基本 ...