Waveform plot

This will download continuous seismic waveforms & plot them and requires ObsPy

Import ObsPy module

In [23]:
from obspy import read
from obspy import UTCDateTime
from obspy.clients.fdsn import Client

import obspy as ob
print("# obspy version = ",ob.__version__)
# obspy version =  1.2.1

Set client (Data Center)

This example uses NCEDC. We can use other dataceneter (e.g., SCEDC, IRIS, GEOFON...)

In [24]:
client = Client("NCEDC") # data from NCEDC
#client = Client("SCEDC") # data from SCEDC
#client = Client("IRIS") # data from IRIS

Set SNCL

Which SNCL (Station, Network, Component, Location)? This example uses BKS.BK.HHZ.00 data

In [25]:
# BKS BHZ data
sta = "BKS" # station
com = "HHZ" # componnet 
net = "BK" # network
loc = "00" # location "--" for blank location code

Set time window

This example uses 10-min data for the 2019 M7.1 Ridgecrest earthquake

In [26]:
# 2019-07-06 03:19:53 (UTC)35.770°N 117.599°W8.0 km depth
start_day = "2019-07-06T03:19:53"
end_day = "2019-07-06T03:29:53"
starttime = UTCDateTime(start_day)
endtime = UTCDateTime(end_day)

Download seismic data

use get_waveforms to download data and do st.plot() for plotting

In [27]:
st = client.get_waveforms(network=net, station=sta, location=loc, channel=com,
                     starttime=starttime, endtime=endtime, 
                     attach_response=True)
st.plot()
Out[27]:

Correct instrument response

use remove_response to correct the instrument response. We can select output unit (displacement, velocity or accerelation)

In [28]:
st.detrend() # remove liner trend
st.taper(max_percentage=0.001) # apply taper
Out[28]:
1 Trace(s) in Stream:
BK.BKS.00.HHZ | 2019-07-06T03:19:53.008393Z - 2019-07-06T03:29:52.998393Z | 100.0 Hz, 60000 samples
In [29]:
st = st.remove_response( output="VEL" ) # get velocity data (m/s)
#st = st.remove_response( output="DISP" ) # get displacement data (m)
#st = st.remove_response( output="ACC" ) # get acceleration data (m/s^2)
In [30]:
st.plot()
Out[30]:

Filtering seismic data

first remove liner trend, apply a cosin taper, and then do filtering

In [31]:
fl = 0.02 # in Hz 
fh = 0.05 # in Hz
st.filter(type='bandpass', freqmin=fl, freqmax=fh, corners=6, zerophase=False)
Out[31]:
1 Trace(s) in Stream:
BK.BKS.00.HHZ | 2019-07-06T03:19:53.008393Z - 2019-07-06T03:29:52.998393Z | 100.0 Hz, 60000 samples
In [32]:
st.plot()
Out[32]:
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: