本文整理汇总了Python中obspy.core.stream.Stream.filter方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.filter方法的具体用法?Python Stream.filter怎么用?Python Stream.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.stream.Stream
的用法示例。
在下文中一共展示了Stream.filter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getData
# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import filter [as 别名]
def getData(tstart, tend, opt):
"""
Download data from files in a folder, from IRIS, or a Earthworm waveserver
A note on SAC/miniSEED files: as this makes no assumptions about the naming scheme of
your data files, please ensure that your headers contain the correct SCNL information!
tstart: UTCDateTime of beginning of period of interest
tend: UTCDateTime of end of period of interest
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(',')
st = Stream()
if opt.server == 'SAC' or opt.server == 'miniSEED':
# Generate list of files
if opt.server == 'SAC':
flist = list(itertools.chain.from_iterable(glob.iglob(os.path.join(
root,'*.sac')) for root, dirs, files in os.walk(opt.sacdir)))+list(
itertools.chain.from_iterable(glob.iglob(os.path.join(
root,'*.SAC')) for root, dirs, files in os.walk(opt.sacdir)))
elif opt.server == 'miniSEED':
flist = list(itertools.chain.from_iterable(glob.iglob(os.path.join(
root,'*.mseed')) for root, dirs, files in os.walk(opt.mseeddir)))+list(
itertools.chain.from_iterable(glob.iglob(os.path.join(
root,'*.MSEED')) for root, dirs, files in os.walk(opt.mseeddir)))
# Determine which subset of files to load based on start and end times and
# station name; we'll fully deal with stations below
flist_sub = []
for f in flist:
# Load header only
stmp = obspy.read(f, headonly=True)
# Check if station is contained in the stas list
if stmp[0].stats.station in stas:
# Check if contains either start or end time
ststart = stmp[0].stats.starttime
stend = stmp[0].stats.endtime
if (ststart<=tstart and tstart<=stend) or (ststart<=tend and
tend<=stend) or (tstart<=stend and ststart<=tend):
flist_sub.append(f)
# Fully load data from file
stmp = Stream()
for f in flist_sub:
tmp = obspy.read(f, starttime=tstart, endtime=tend+opt.maxdt)
if len(tmp) > 0:
stmp = stmp.extend(tmp)
# Filter and merge
stmp = stmp.filter('bandpass', freqmin=opt.fmin, freqmax=opt.fmax, corners=2,
zerophase=True)
stmp = stmp.taper(0.05,type='hann',max_length=opt.mintrig)
for m in range(len(stmp)):
if stmp[m].stats.sampling_rate != opt.samprate:
stmp[m] = stmp[m].resample(opt.samprate)
stmp = stmp.merge(method=1, fill_value=0)
# Only grab stations/channels that we want and in order
netlist = []
stalist = []
chalist = []
loclist = []
for s in stmp:
stalist.append(s.stats.station)
chalist.append(s.stats.channel)
netlist.append(s.stats.network)
loclist.append(s.stats.location)
# Find match of SCNL in header or fill empty
for n in range(len(stas)):
for m in range(len(stalist)):
if (stas[n] in stalist[m] and chas[n] in chalist[m] and nets[n] in
netlist[m] and locs[n] in loclist[m]):
st = st.append(stmp[m])
if len(st) == n:
print("Couldn't find "+stas[n]+'.'+chas[n]+'.'+nets[n]+'.'+locs[n])
trtmp = Trace()
trtmp.stats.sampling_rate = opt.samprate
trtmp.stats.station = stas[n]
st = st.append(trtmp.copy())
else:
if '.' not in opt.server:
client = Client(opt.server)
else:
client = EWClient(opt.server, opt.port)
for n in range(len(stas)):
try:
#.........这里部分代码省略.........
示例2: location
# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import filter [as 别名]
AC.trim(startaim, endtaim, nearest_sample=True)
RLAS.trim(startaim, endtaim, nearest_sample=True)
# **Resample, Filter and Rotate**
# In[4]:
RLAS.decimate(factor=4)
AC.decimate(factor=4)
f_cutoff = 1.0
RLAS.filter('lowpass', freq=f_cutoff, corners=2, zerophase=True)
AC.filter('lowpass', freq=f_cutoff, corners=2, zerophase=True)
# event location from event info
source_latitude = event.origins[0].latitude
source_longitude = event.origins[0].longitude
# station location (Wettzell)
station_latitude = 49.144001
station_longitude = 12.8782
# theoretical backazimuth and distance
baz = gps2dist_azimuth(source_latitude, source_longitude, station_latitude, station_longitude)
print('Epicentral distance [m]: ',baz[0])
print('Theoretical azimuth [deg]: ', baz[1])
print('Theoretical backazimuth [deg]: ', baz[2])
示例3: Files
# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import filter [as 别名]
from obspy.core.util import gps2DistAzimuth
host = 'http://examples.obspy.org/'
# Files (fmt: SAC)
files = ['TOK.2011.328.21.10.54.OKR01.HHN.inv',
'TOK.2011.328.21.10.54.OKR02.HHN.inv', 'TOK.2011.328.21.10.54.OKR03.HHN.inv',
'TOK.2011.328.21.10.54.OKR04.HHN.inv', 'TOK.2011.328.21.10.54.OKR05.HHN.inv',
'TOK.2011.328.21.10.54.OKR06.HHN.inv', 'TOK.2011.328.21.10.54.OKR07.HHN.inv',
'TOK.2011.328.21.10.54.OKR08.HHN.inv', 'TOK.2011.328.21.10.54.OKR09.HHN.inv',
'TOK.2011.328.21.10.54.OKR10.HHN.inv']
# Earthquakes' epicenter
eq_lat = 35.565
eq_lon = -96.792
# Reading the waveforms
st = Stream()
for waveform in files:
st += read(host + waveform)
# Calculating distance from SAC headers lat/lon
# (trace.stats.sac.stla and trace.stats.sac.stlo)
for tr in st:
tr.stats.distance = gps2DistAzimuth(tr.stats.sac.stla,
tr.stats.sac.stlo, eq_lat, eq_lon)[0]
# Setting Network name for plot title
tr.stats.network = 'TOK'
st.filter('bandpass', freqmin=0.1, freqmax=10)
# Plot
st.plot(type='section', plot_dx=20e3, recordlength=100,
time_down=True, linewidth=.25, grid_linewidth=.25)