如何基于参考波形对齐时间序列?互相关实现失败求排查建议
时间序列互相关对齐问题求助
我有多组时间序列数据,希望通过互相关方法将其与第一组参考序列对齐。完成互相关计算后,我已根据延迟时间调整波形的起始时间,但仍无法与参考迹线对齐,不清楚问题所在。以下是我的代码示例,恳请各位提供意见或建议:
ref_tr=obspy.read(refernce[0]) #do cc and plots #---------------station info for cc--------------------- for event_file in eve_list: sta_files = glob.glob(os.path.join(event_file,"*ML0*BHZ*")) i=0 for sta_file in sta_files: org_tr = obspy.read(sta_file) #---------------do cross correlation --------------------- corr_result = xcorr(org_tr.data,ref_tr.data,10) corr_result = list(corr_result/(np.linalg.norm(org_tr[0].data)*np.linalg.norm(ref_tr[0].data))) max_corr = max(corr_result) max_index = corr_result.index(max_corr) cc_diff=(max_index-10)*delta # #---------------modify the start time accordingly--------------------- org_tr[0].stats.starttime=org_tr[0].stats.starttime+ timedelta(seconds=float(cc_diff)) #---------------plot the waveforms --------------------- data = sta_tr[0].data.copy() if max(data) != min(data): sta_tr[0].data=data/(max(data) - min(data)) # Normalize data sampling_rate = sta_tr[0].stats.sampling_rate plt.plot(np.arange(0,len(sta_tr[0].data))*1/sampling_rate, sta_tr[0].data+dist, color=color, linewidth=0.9)

内容的提问来源于stack exchange,提问作者user16941410
相关产品推荐
相关产品推荐

