本文整理汇总了Python中obspy.core.Stream.simulate方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.simulate方法的具体用法?Python Stream.simulate怎么用?Python Stream.simulate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.Stream
的用法示例。
在下文中一共展示了Stream.simulate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert
# 需要导入模块: from obspy.core import Stream [as 别名]
# 或者: from obspy.core.Stream import simulate [as 别名]
print "Trigger time:", t
mags = []
stations = client.getStations(t, t + 300, "CH")
for station in stations:
station = station['code']
try:
st = client.getWaveform("CH", station, "", "[EH]H[ZNE]", t - 300,
t + 300, metadata=True)
assert(len(st) == 3)
except:
print station, "---"
continue
st.simulate(paz_remove="self", paz_simulate=paz_wa, water_level=10)
st.trim(t, t + 50)
tr_n = st.select(component="N")[0]
ampl_n = max(abs(tr_n.data))
tr_e = st.select(component="E")[0]
ampl_e = max(abs(tr_e.data))
ampl = max(ampl_n, ampl_e)
sta_lat = st[0].stats.coordinates.latitude
sta_lon = st[0].stats.coordinates.longitude
event_lat = trig['latitude']
event_lon = trig['longitude']
epi_dist, az, baz = gps2DistAzimuth(event_lat, event_lon, sta_lat,
sta_lon)
示例2: open
# 需要导入模块: from obspy.core import Stream [as 别名]
# 或者: from obspy.core.Stream import simulate [as 别名]
# merging
try:
st.merge(0)
except Exception, e:
summary.append("Error while merging:")
summary.append(str(e))
summary = "\n".join(summary)
summary += "\n" + "\n".join(("%s=%s" % (k, v) for k, v in PAR.items()))
open(SUMMARY, "at").write(summary + "\n")
continue
# preprocessing, keep original data for plotting at end
for tr in st:
tr.data = detrend(tr.data)
st.simulate(paz_remove="self", paz_simulate=cornFreq2Paz(1.0), remove_sensitivity=False)
st.sort()
st_trigger = st.copy()
st_trigger.filter("bandpass", freqmin=PAR.LOW, freqmax=PAR.HIGH, corners=1, zerophase=True)
st.trim(T1, T2)
st_trigger.trim(T1, T2)
st_trigger.trigger("recstalta", sta=PAR.STA, lta=PAR.LTA)
summary.append(str(st))
# do the triggering
trigger_list = []
for tr in st_trigger:
tr.stats.channel = "recstalta"
max_len = PAR.MAXLEN * tr.stats.sampling_rate
trigger_sample_list = triggerOnset(tr.data, PAR.ON, PAR.OFF, max_len=max_len)
for on, off in trigger_sample_list:
示例3: preprocess
# 需要导入模块: from obspy.core import Stream [as 别名]
# 或者: from obspy.core.Stream import simulate [as 别名]
#.........这里部分代码省略.........
del st
stream.sort()
stream.merge(method=1, interpolation_samples=3, fill_value=None)
stream = stream.split()
logging.debug("Checking sample alignment")
for i, trace in enumerate(stream):
stream[i] = check_and_phase_shift(trace)
logging.debug("Checking Gaps")
if len(getGaps(stream)) > 0:
max_gap = 10
only_too_long = False
while getGaps(stream) and not only_too_long:
too_long = 0
gaps = getGaps(stream)
for gap in gaps:
if int(gap[-1]) <= max_gap:
stream[gap[0]] = stream[gap[0]].__add__(stream[gap[1]], method=1,
fill_value="interpolate")
stream.remove(stream[gap[1]])
break
else:
too_long += 1
if too_long == len(gaps):
only_too_long = True
stream = stream.split()
taper_length = 20.0 # seconds
for trace in stream:
if trace.stats.npts < 4 * taper_length * trace.stats.sampling_rate:
stream.remove(trace)
else:
trace.detrend(type="demean")
trace.detrend(type="linear")
trace.taper(max_percentage=None, max_length=1.0)
if not len(stream):
logging.debug(" has only too small traces, skipping...")
continue
for trace in stream:
logging.debug(
"%s.%s Highpass at %.2f Hz" % (station, comp, params.preprocess_highpass))
trace.filter("highpass", freq=params.preprocess_highpass, zerophase=True)
if trace.stats.sampling_rate != params.goal_sampling_rate:
logging.debug(
"%s.%s Lowpass at %.2f Hz" % (station, comp, params.preprocess_lowpass))
trace.filter("lowpass", freq=params.preprocess_lowpass, zerophase=True, corners=8)
if params.resampling_method == "Resample":
logging.debug("%s.%s Downsample to %.1f Hz" %
(station, comp, params.goal_sampling_rate))
trace.data = resample(
trace.data, params.goal_sampling_rate / trace.stats.sampling_rate, 'sinc_fastest')
elif params.resampling_method == "Decimate":
decimation_factor = trace.stats.sampling_rate / params.goal_sampling_rate
if not int(decimation_factor) == decimation_factor:
logging.warning("%s.%s CANNOT be decimated by an integer factor, consider using Resample or Lanczos methods"
" Trace sampling rate = %i ; Desired CC sampling rate = %i" %
(station, comp, trace.stats.sampling_rate, params.goal_sampling_rate))
sys.stdout.flush()
sys.exit()
logging.debug("%s.%s Decimate by a factor of %i" %
(station, comp, decimation_factor))
trace.data = trace.data[::int(decimation_factor)]
elif params.resampling_method == "Lanczos":
logging.debug("%s.%s Downsample to %.1f Hz" %
(station, comp, params.goal_sampling_rate))
trace.data = np.array(trace.data)
trace.interpolate(method="lanczos", sampling_rate=params.goal_sampling_rate, a=1.0)
trace.stats.sampling_rate = params.goal_sampling_rate
if get_config(db, 'remove_response', isbool=True):
logging.debug('%s Removing instrument response'%stream[0].id)
response_prefilt = eval(get_config(db, 'response_prefilt'))
response = responses[responses["channel_id"] == stream[0].id]
if len(response) > 1:
response = response[response["start_date"]<UTCDateTime(gd)]
response = response[response["end_date"]>UTCDateTime(gd)]
elif len(response) == 0:
logging.info("No instrument response information "
"for %s, exiting" % stream[0].id)
sys.exit()
datalesspz = response["paz"].values[0]
stream.simulate(paz_remove=datalesspz,
remove_sensitivity=True,
pre_filt=response_prefilt,
paz_simulate=None, )
for tr in stream:
tr.data = tr.data.astype(np.float32)
output += stream
del stream
del files
clean_scipy_cache()
return 0, output
示例4: preprocess
# 需要导入模块: from obspy.core import Stream [as 别名]
# 或者: from obspy.core.Stream import simulate [as 别名]
#.........这里部分代码省略.........
if int(gap[-1]) <= max_gap:
try:
stream[gap[0]] = stream[gap[0]].__add__(stream[gap[1]], method=1,
fill_value="interpolate")
stream.remove(stream[gap[1]])
except:
stream.remove(stream[gap[1]])
break
else:
too_long += 1
if too_long == len(gaps):
break
gaps = getGaps(stream)
del gaps
stream = stream.split()
for tr in stream:
if tr.stats.sampling_rate < (params.goal_sampling_rate-1):
stream.remove(tr)
taper_length = 20.0 # seconds
for trace in stream:
if trace.stats.npts < 4 * taper_length * trace.stats.sampling_rate:
stream.remove(trace)
else:
trace.detrend(type="demean")
trace.detrend(type="linear")
trace.taper(max_percentage=None, max_length=1.0)
if not len(stream):
logger.debug(" has only too small traces, skipping...")
continue
for trace in stream:
logger.debug(
"%s Highpass at %.2f Hz" % (trace.id, params.preprocess_highpass))
trace.filter("highpass", freq=params.preprocess_highpass, zerophase=True, corners=4)
if trace.stats.sampling_rate != params.goal_sampling_rate:
logger.debug(
"%s Lowpass at %.2f Hz" % (trace.id, params.preprocess_lowpass))
trace.filter("lowpass", freq=params.preprocess_lowpass, zerophase=True, corners=8)
if params.resampling_method == "Resample":
logger.debug("%s Downsample to %.1f Hz" %
(trace.id, params.goal_sampling_rate))
trace.data = resample(
trace.data, params.goal_sampling_rate / trace.stats.sampling_rate, 'sinc_fastest')
elif params.resampling_method == "Decimate":
decimation_factor = trace.stats.sampling_rate / params.goal_sampling_rate
if not int(decimation_factor) == decimation_factor:
logger.warning("%s CANNOT be decimated by an integer factor, consider using Resample or Lanczos methods"
" Trace sampling rate = %i ; Desired CC sampling rate = %i" %
(trace.id, trace.stats.sampling_rate, params.goal_sampling_rate))
sys.stdout.flush()
sys.exit()
logger.debug("%s Decimate by a factor of %i" %
(trace.id, decimation_factor))
trace.data = trace.data[::int(decimation_factor)]
elif params.resampling_method == "Lanczos":
logger.debug("%s Downsample to %.1f Hz" %
(trace.id, params.goal_sampling_rate))
trace.data = np.array(trace.data)
trace.interpolate(method="lanczos", sampling_rate=params.goal_sampling_rate, a=1.0)
trace.stats.sampling_rate = params.goal_sampling_rate
del trace
if params.remove_response:
logger.debug('%s Removing instrument response'%stream[0].id)
response = responses[responses["channel_id"] == stream[0].id]
if len(response) > 1:
response = response[response["start_date"] <= UTCDateTime(gd)]
if len(response) > 1:
response = response[response["end_date"] >= UTCDateTime(gd)]
elif len(response) == 0:
logger.info("No instrument response information "
"for %s, skipping" % stream[0].id)
continue
try:
datalesspz = response["paz"].values[0]
except:
logger.error("Bad instrument response information "
"for %s, skipping" % stream[0].id)
continue
stream.simulate(paz_remove=datalesspz,
remove_sensitivity=True,
pre_filt=params.response_prefilt,
paz_simulate=None, )
for tr in stream:
tr.data = tr.data.astype(np.float32)
output += stream
del stream
del files
clean_scipy_cache()
return output