- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试查找在不均匀时间测量的信号的功率谱密度。数据看起来像这样:
0 1.55
755 1.58
2412256 2.42
2413137 0.32
2497761 1.19
...
其中第一列是自第一次测量以来的时间(以秒为单位),第二列是测量值。
目前,使用 Matlab 中的周期图函数,我已经能够通过以下方式估计功率谱密度:
nfft = length(data(:,2));
pxx = periodogram(data(:,2),[],nfft);
现在,为了绘制这个我一直在使用
len = length(pxx);
num = 1:1:len;
plot(num,pxx)
这显然没有将正确的 x 轴放置在功率谱密度上(并产生如下图所示的结果),而功率谱密度需要位于频率空间中。鉴于数据采样不均匀,我对如何解决这个问题感到困惑。
在估计不均匀采样数据的功率谱密度时,转换到(然后在频率空间中绘制)的正确方法是什么?我也有兴趣从 python/numpy/scipy 的角度解决这个问题,但到目前为止只研究了 Matlab 函数。
最佳答案
我不知道有任何函数可以根据不规则采样数据计算 PSD,因此您需要首先将数据转换为统一采样率。所以第一步是使用 interp1 定期重新采样。
avg_fs = 1/mean(diff(data(:, 1)));
min_time = min(data(:, 1));
max_time = max(data(:, 1));
num_pts = floor((max_time - min_time) * avg_fs);
new_time = (1:num_pts)' / avg_fs;
new_time = new_time - new_time(1) + min_time;
new_x = interp1(data(:, 1), data(:, 2), new_time);
我总是使用 pwelch 来计算 PSD,这是我的方法
nfft = 512; % play with this to change your frequency resolution
noverlap = round(nfft * 0.75); % 75% overlap
window = hanning(nfft);
[Pxx,F] = pwelch(new_x, window, noverlap, nfft, avg_fs);
plot(F, Pxx)
xlabel('Frequency (Hz)')
grid on
您肯定想尝试 nfft,较大的数字将为您提供更高的频率分辨率(频率之间的间距更小),但 PSD 的噪声会更大。获得高分辨率和低噪声的一个技巧是使窗口小于 nfft。
关于python - Matlab/Python : Power spectral density of non-uniform time series,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21750075/
我尝试从网站 https://plot.ly/scikit-learn/plot-kmeans-silhouette-analysis/ 运行代码.当我运行时发现 matplotlib 模块已经没有光
关于 http://en.cppreference.com/w/cpp/numeric/random : The Mersenne twister is slower and has greater
我有一个二维点数据集,我想使用 K 均值技术对其进行分类。 数据: import numpy as np x1 = np.array([3,1,1,2,1,6,6,6,5,6,7,8,9,8,9,9,
我正在尝试列出我的 .hdr 文件中存在的所有波段。我有超过 100 个波段,这是一个高光谱数据。 img = envi.open('Dun_Hyperion_Atm_Corr.hdr','Dun_H
我正在尝试打开一个 envi .img 文件,但有一个同名的 .hdr 文件。在 .img 文件中有两个图像,我可以使用以下代码读取它们。 from spectral import * img = o
让我们从一个简单的时间序列输入开始,并尝试构建一个自动编码器,该自动编码器简单地进行傅立叶变换,然后在 keras 中对我们的数据进行反变换。 如果我们尝试这样做: inputs = Input(sh
新的 Scipy v0.11 提供了一个用于光谱分析的包。不幸的是,文档很少,而且没有很多可用的示例。 作为一个小例子,我正在尝试发现正弦波的周期。不幸的是,它预测的周期为 1 而不是预期的 2pi。
我指的是以下帖子:Using scipy.signal.spectral.lombscargle for period discovery 我意识到在某些情况下给出的答案是正确的。 sin(x) 的频
我正在使用 scikit learn 的“谱聚类”功能。我能够对 8100 x 8100 矩阵执行聚类,但此函数会对 10000 x 10000 矩阵抛出错误。 有人用过这个函数来处理大矩阵吗? 编辑
我一直在使用 pylab 的代码,它运行良好: import pylab as pl colors = pl.cm.Spectral(np.linspace(0, 1, 10)) 但是,我想摆脱 py
我正在尝试查找在不均匀时间测量的信号的功率谱密度。数据看起来像这样: 0 1.55 755 1.58 2412256 2.42 2413137 0.32 2497761 1.19 ... 其中第一列是
我有两个长度相等的时间序列(地震道的不同分量),我计算了它们的单独频谱图 PxV 和 PxH,它们对应于地震信号的垂直和水平分量。然后,我提取了每个频谱图的数据数组(对应于时间 - 频率空间中的点的幅
我将我的 MacBook 更新为 Mavericks,重新安装了 Macports 和我常用的所有 Python 2.7 模块。在运行 Python 时,我收到以下消息: 导入 mlab 时: 来自
我是一名优秀的程序员,十分优秀!