本文整理汇总了Python中obspy.core.stream.Stream.resample方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.resample方法的具体用法?Python Stream.resample怎么用?Python Stream.resample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.stream.Stream
的用法示例。
在下文中一共展示了Stream.resample方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getCatData
# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import resample [as 别名]
def getCatData(date, opt):
"""
Download data from IRIS or Earthworm waveserver with padding and filter it. This is
a specialized version getData() for catalog events, pulling a smaller amount of time
around a known event.
date: UTCDateTime of known catalog event
opt: Options object describing station/run parameters
Returns ObsPy stream objects, one for cutting and the other for triggering
"""
nets = opt.network.split(',')
stas = opt.station.split(',')
locs = opt.location.split(',')
chas = opt.channel.split(',')
if opt.server == "IRIS":
client = Client("IRIS")
else:
client = EWClient(opt.server, opt.port)
st = Stream()
for n in range(len(stas)):
try:
stmp = client.get_waveforms(nets[n], stas[n], locs[n], chas[n],
date - opt.atrig, date + 3*opt.atrig)
stmp = stmp.filter("bandpass", freqmin=opt.fmin, freqmax=opt.fmax,
corners=2, zerophase=True)
stmp = stmp.merge(method=1, fill_value='interpolate')
except (obspy.fdsn.header.FDSNException):
try: # try again
stmp = client.get_waveforms(nets[n], stas[n], locs[n], chas[n],
date - opt.atrig, date + 3*opt.atrig)
stmp = stmp.filter("bandpass", freqmin=opt.fmin, freqmax=opt.fmax,
corners=2, zerophase=True)
stmp = stmp.merge(method=1, fill_value='interpolate')
except (obspy.fdsn.header.FDSNException):
print('No data found for {0}.{1}'.format(stas[n],nets[n]))
trtmp = Trace()
trtmp.stats.sampling_rate = opt.samprate
trtmp.stats.station = stas[n]
stmp = Stream().extend([trtmp.copy()])
# Resample to ensure all traces are same length
if stmp[0].stats.sampling_rate != opt.samprate:
stmp = stmp.resample(opt.samprate)
st.extend(stmp.copy())
st = st.trim(starttime=date-opt.atrig, endtime=date+3*opt.atrig, pad=True,
fill_value=0)
stC = st.copy()
return st, stC