首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用scipy.signal.spectral.lombscargle进行周期发现

使用scipy.signal.spectral.lombscargle进行周期发现
EN

Stack Overflow用户
提问于 2012-11-13 02:16:04
回答 1查看 2K关注 0票数 5

新的Scipy v0.11提供了一个用于频谱分析的包。不幸的是,文档很稀疏,并且没有太多可用的示例。

作为一个小例子,我正在尝试做一个正弦波的周期发现。不幸的是,它预测的是1的周期,而不是预期的2pi。有什么想法吗?

代码语言:javascript
复制
# imports the numerical array and scientific computing packages
import numpy as np
import scipy as sp
from scipy.signal import spectral

# generates 100 evenly spaced points between 1 and 1000
time = np.linspace(1, 1000, 100)

# computes the sine value of each of those points
mags = np.sin(time)

# scales the sine values so that the mean is 0 and the variance is 1 (the documentation specifies that this must be done)
scaled_mags = (mags-mags.mean())/mags.std()

# generates 1000 frequencies between 0.01 and 1
freqs = np.linspace(0.01, 1, 1000)

# computes the Lomb Scargle Periodogram of the time and scaled magnitudes using each frequency as a guess
periodogram = spectral.lombscargle(time, scaled_mags, freqs)

# returns the inverse of the frequence (i.e. the period) of the largest periodogram value
1/freqs[np.argmax(periodogram)]

这将返回1,而不是预期的2pi ~= 1/0.6366周期。有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-13 02:45:20

请注意,根据docstringspectral.lombscargle的最后一个参数是角频率

代码语言:javascript
复制
Parameters
----------
x : array_like
Sample times.
y : array_like
Measurement values.
freqs : array_like
Angular frequencies for output periodogram.
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13349181

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档