在python中对齐跟踪数组

2024-06-06 06:42:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一系列的痕迹是这样的:

真的很小的低部分,然后一个大的高部分和结束与低部分再次

Example of a trace

我想把所有的痕迹对齐。。。尽可能接近(因此从低到高的变化和相反的变化将在相同的索引上)

我试着使用互相关,但那给了我0偏移量。。。我不知道为什么

def give_offset(y,y2):
# limit your signal length to speed things up
lim = 2000              

# do the actual correlation
corr = scipy.signal.correlate(y[:lim], y2[:lim], mode='full')

# The offset is the maximum of your correlation array,
# itself being offset by (lim - 1):
offset = np.argmax(corr) - (lim - 1)
return offset

我没有在网上找到任何东西,我很困惑,因为这似乎是一个常见的问题,许多人以前面临的


Tags: thetoyoursignaldeflengthoffset偏移量