import numpy as np
import matplotlib.pyplot as plt
import obspy
%matplotlib inline
plt.style.use('ggplot')#'seaborn-whitegrid')
plt.rcParams['figure.figsize'] = 10, 5
from obspy import UTCDateTime
from obspy.clients.fdsn import Client
#M 2.1 - 3km W of Concord, CA
#2020-03-17 04:16:49 (UTC)37.968°N 122.045°W12.9 km depth
fdsn_client = Client("NCEDC")
net_code = "BK"
sta_code = "BRK"
# get data
starttime = UTCDateTime(2020, 3, 17, 2, 0, 0)
endtime = UTCDateTime(2020, 3, 17, 7, 0, 0)
# plot
starttime2 = UTCDateTime(2020, 3, 17, 3, 30, 0)
endtime2 = UTCDateTime(2020, 3, 17, 5, 30, 0)
st = fdsn_client.get_waveforms(network=net_code, station=sta_code, location="00", channel="HHZ",
starttime=starttime, endtime=endtime,
attach_response=True)
st = st.remove_response( output="VEL" )
st.detrend()
st.taper(max_percentage=0.001)
st2 = st.copy()
fl = 1
fh = 10
title = st2[0].id+" (BP filter: "+str(fl)+"-"+str(fh)+"Hz)"
st2.slice(starttime=starttime2,
endtime=endtime2).filter(
"bandpass", freqmin=fl, freqmax=fh).plot(type='dayplot', interval=10, title=title)
st2 = st.copy()
fl = 5
fh = 10
title = st2[0].id+" (BP filter: "+str(fl)+"-"+str(fh)+"Hz)"
st2.slice(starttime=starttime2,
endtime=endtime2).filter(
"bandpass", freqmin=fl, freqmax=fh).plot(type='dayplot', interval=10, title=title)
st2 = st.copy()
fl = 10
fh = 20
title = st2[0].id+" (BP filter: "+str(fl)+"-"+str(fh)+"Hz)"
st2.slice(starttime=starttime2,
endtime=endtime2).filter(
"bandpass", freqmin=fl, freqmax=fh).plot(type='dayplot', interval=10, title=title)