具有numpy的周期性信号的单个周期的平均值

问题描述 投票:1回答:1

我在大学做了一个测量。信号有很多噪音,但是是周期性的。

My raw signal

我知道信号开始的点(x = 36400)和频率(1Hz)和采样率(48000)。所以我可以每48000点“减少”单个时段。我可以生成看起来像这个[[period1],[period2],...,[period100]]的数组,其中每个句点包含测量值。

我现在想要平均每个周期以获得较少噪声的信号。我知道如何使用for循环执行此操作,但有没有快速的方法来使用numpy?

python numpy scipy scientific-computing
1个回答
1
投票

首先,您需要切割数组以获得有意义的部分

n_periods = 10  # or however man
beginning_idx = 1000  # or whever the good data begins

raw_signal = ...  # this is the data you read in
good_signal = raw_signal[beginning_idx:beginning_idx + n_periods * 48000]
periodic = good_signal.reshape(n_periods, 48000)
avg_signal = periodic.mean(axis=0)
© www.soinside.com 2019 - 2024. All rights reserved.