我有以下时间序列:
基于最小点对齐,我想在时间= 800之后对齐信号.
我已尝试以下方法来对齐pandas中的两个信号:
from pandas import *
import pandas as pd
s1 = Series(vec1)
s2 = Series(vec2)
s3 = s1.align(s2,join='inner')
s1 = np.array(s1)
s2 = np.array(s2)
s3 = np.array(s3)
plt.plot(t,s1)
plt.plot(t,s2)
plt.plot(t,s3)
plt.show()
其中显示的对齐信号与原始形式完全相同.有关如何实现最小对齐的任何建议?
解决方法:
找到并对齐最小值:
import matplotlib.pyplot as plt #making toy data
x = np.arange(0, 2, .05)
s = []
s.append(np.sin(x*3))
s.append(np.cos(x*4+0.3))
s.append(np.sin(x)*np.exp(2-x)*-1)
plt.clf()
plt.plot(x, s[0], x, s[1], x, s[2])
plt.show()
plt.clf()
mindexes = map(lambda x: x.argmin(), s) #finding the minima
shifts = mindexes - min(mindexes)
def shifted(shift, x, s):
if shift == 0: #x[:-0] was not what I wanted.
return x, s
else:
return x[:-1*shift], s[shift:]
for i in (0,1,2):
px, py = shifted(shifts[i], x, s[i])
plt.plot(px, py)
plt.show()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。