For the this exercise we will download some data from the Tohoku-Oki earthquake, cut out a certain time window around the first arrival and remove the instrument response from the data.
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')
plt.rcParams['figure.figsize'] = 12, 8
The first step is to download all the necessary information using the ObsPy FDSN client. Learn to read the documentation!
We need the following things:
get_events()
method of the client. A good provider of event data is the USGS.II.BFO
which is available for example from IRIS. Use the get_waveforms()
method.get_stations()
method.
import obspy
from obspy.clients.fdsn import Client
c_event = Client("USGS")
# Event time.
event_time = obspy.UTCDateTime("2011-03-11T05:46:23.2")
# Get the event information. The temporal and magnitude constraints make it unique
cat = c_event.get_events(starttime=event_time - 10, endtime=event_time + 10,
minmagnitude=9)
print(cat)
c = Client("IRIS")
# Download station information at the response level!
inv = c.get_stations(network="II", station="BFO", location="*", channel="BH?",
starttime=event_time - 60, endtime=event_time + 3600,
level="response")
print(inv)
# Download 3 component waveforms.
st = c.get_waveforms(network="II", station="BFO", location="*",
channel="BH?", starttime=event_time - 60,
endtime=event_time + 3600)
print(st)
Have a look at the just downloaded data.
inv.plot()
inv.plot_response(0.001)
cat.plot()
st.plot()
coords = inv.get_coordinates("II.BFO.00.BHE")
coords
origin = cat[0].preferred_origin()
print(origin)
Use obspy.geodetics.locations2degree
.
from obspy.geodetics import locations2degrees
distance = locations2degrees(origin.latitude, origin.longitude,
coords["latitude"], coords["longitude"])
print(distance)
from obspy.taup import TauPyModel
m = TauPyModel(model="ak135")
arrivals = m.get_ray_paths(...)
arrivals.plot()
from obspy.taup import TauPyModel
m = TauPyModel(model="ak135")
arrivals = m.get_ray_paths(
distance_in_degree=distance,
source_depth_in_km=origin.depth / 1000.0)
arrivals.plot();
first_arrival = origin.time + arrivals[0].time
print(first_arrival)
st.trim(first_arrival - 60, first_arrival + 300)
st.plot();
st.remove_response(inventory=inv, pre_filt=...)
st.remove_response(inventory=inv,
pre_filt=(1.0 / 100.0, 1.0 / 50.0, 10.0, 20.0),
output="VEL")
st.plot()
from IPython.html.widgets import interact
from obspy.taup import TauPyModel
m = TauPyModel("ak135")
def plot_raypaths(distance, depth, wavetype):
try:
plt.close()
except:
pass
if wavetype == "ttall":
phases = ["ttall"]
elif wavetype == "diff":
phases = ["Pdiff", "pPdiff"]
m.get_ray_paths(distance_in_degree=distance,
source_depth_in_km=depth,
phase_list=phases).plot();
interact(plot_raypaths, distance=[0, 180],
depth=[0, 700], wavetype=["ttall", "diff"]);