def x_corr(a,b,center_time_s=1000.0,window_len_s=50.0,plot=True):
center_index = int(center_time_s/a.dt)
window_index = int(window_len_s/(a.dt))
print "center_index is", center_index
print "window_index is", window_index
t1 = a.trace_x[(center_index - window_index) : (center_index + window_index)]
t2 = b.trace_x[(center_index - window_index) : (center_index + window_index)]
print t1
time_window = np.linspace((-window_len_s/2.0), (window_len_s/2), len(t1))
#print time_window
#plt.plot(time_window, t1)
#plt.plot(time_window, t2)
#plt.show()
x_corr_time = correlate(t1, t2)
delay = (np.argmax(x_corr_time) - (len(x_corr_time)/2) ) * a.dt
#print "the delay is ", delay
return delay
评论列表
文章目录