本文整理汇总了Python中obspy.core.Trace.stats['endtime1']方法的典型用法代码示例。如果您正苦于以下问题:Python Trace.stats['endtime1']方法的具体用法?Python Trace.stats['endtime1']怎么用?Python Trace.stats['endtime1']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.Trace
的用法示例。
在下文中一共展示了Trace.stats['endtime1']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stream_collapse_tr
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import stats['endtime1'] [as 别名]
def stream_collapse_tr(st):
if not isinstance(st, Stream):
raise InputError("'st' must be a 'obspy.core.stream.Stream' object")
stream_new = Stream()
# Generate sorted list of traces (no copy)
# Sort order, id, starttime, endtime
ids = []
for tr in st:
if not tr.id in ids:
ids.append(tr.id)
for id in ids:
print "new_trace id: %s" % id
tr_new = Trace()
tr_new.data = np.zeros(st[0].data.shape)
# tr_new.stats = {}
tr_new.stats_tr1 = {}
tr_new.stats_tr2 = {}
starttime1_list = []
starttime2_list = []
endtime1_list = []
endtime2_list = []
n_tr = 0
for tr in st:
if tr.id == id:
print tr.id
if len(tr_new.data) != len(tr.data):
lp = len(tr_new.data) - len(tr.data)
print "lp: %d" % lp
if lp > 0:
left = np.ceil(lp / 2)
right = lp - left
cdata = np.append(np.zeros(left, dtype=tr.data.dtype),
tr.data)
tr.data = np.append(cdata,
np.zeros(right,
dtype=tr.data.dtype))
else:
lp = -lp
left = np.ceil(lp / 2)
right = lp - left
tr.data = tr.data[left:-right]
print "len tr: %d" % len(tr)
print "len tr_new: % d" % len(tr_new)
tr_new.data += tr.data
n_tr += 1
starttime1_list.append(tr.stats_tr1.starttime)
starttime2_list.append(tr.stats_tr2.starttime)
endtime1_list.append(tr.stats_tr1.endtime)
endtime2_list.append(tr.stats_tr2.endtime)
tr_new.stats.update(tr.stats)
tr_new.stats_tr1.update(tr.stats_tr1)
tr_new.stats_tr2.update(tr.stats_tr2)
tr_new.data /= n_tr
tr_new.stats['starttime1'] = starttime1_list
tr_new.stats['starttime2'] = starttime2_list
tr_new.stats['endtime1'] = endtime1_list
tr_new.stats['endtime2'] = endtime2_list
stream_new.append(tr_new)
return stream_new