This is oftentimes not taught, but fairly important to understand, at least at a basic level. This also teaches you how to work with these in ObsPy.
This notebook aims to give a quick introductions to ObsPy's core functions and classes. Everything here will be repeated in more detail in later notebooks.
%matplotlib inline import matplotlib.pyplot as plt plt.style.use('ggplot') plt.rcParams['figure.figsize'] = 12, 8
According to the SEED standard, which is fairly well adopted, the following nomenclature is used to identify seismic receivers:
This results in full ids of the form NET.STA.LOC.CHAN, e.g. IV.PRMA..HHE.
In seismology we generally distinguish between three separate types of data:
Some formats have elements of two or more of these.
There are a myriad of waveform data formats but in Europe and the USA two formats dominate: MiniSEED and SAC
import obspy # ObsPy automatically detects the file format. st = obspy.read("data/example.mseed") print(st) # Fileformat specific information is stored here. print(st.stats.mseed)
# This is a quick interlude to teach you basics about how to work # with Stream/Trace objects. # Most operations work in-place, e.g. they modify the existing # objects. We'll create a copy here. st2 = st.copy() # To use only part of a Stream, use the select() function. print(st2.select(component="Z")) # Stream objects behave like a list of Trace objects. tr = st2 tr.plot() # Some basic processing. Please note that these modify the # existing object. tr.detrend("linear") tr.taper(type="hann", max_percentage=0.05) tr.filter("lowpass", freq=0.5) tr.plot()
# You can write it again by simply specifing the format. st.write("temp.mseed", format="mseed")
sacbeing very popular and the additional basic information that can be stored in the header.
st = obspy.read("data/example.sac") print(st) st.stats.sac.__dict__
# You can once again write it with the write() method. st.write("temp.sac", format="sac")
Station data contains information about the organziation that collections the data, geographical information, as well as the instrument response. It mainly comes in three formats:
(dataless) SEED: Very complete but pretty complex and binary. Still used a lot, e.g. for the Arclink protocol
RESP: A strict subset of SEED. ASCII based. Contains ONLY the response.
StationXML: Essentially like SEED but cleaner and based on XML. Most modern format and what the datacenters nowadays serve. Use this if you can.
ObsPy can work with all of them but today we will focus on StationXML.
They are XML files:
import obspy # Use the read_inventory function to open them. inv = obspy.read_inventory("data/all_stations.xml") print(inv)
You can see that they can contain an arbirary number of networks, stations, and channels.
# ObsPy is also able to plot a map of them. inv.plot(projection="local");
# As well as a plot the instrument response. inv.select(network="IV", station="SALO", channel="BH?").plot_response(0.001);
# Coordinates of single channels can also be extraced. This function # also takes a datetime arguments to extract information at different # points in time. inv.get_coordinates("IV.SALO..BHZ")
# And it can naturally be written again, also in modified state. inv.select(channel="BHZ").write("temp.xml", format="stationxml")
Event data is essentially served in either very simple formats like NDK or the CMTSOLUTION format used by many waveform solvers:
Datacenters on the hand offer QuakeML files, which are surprisingly complex in structure but can store complex relations.
# Read QuakeML files with the read_events() function. cat = obspy.read_events("data/GCMT_2014_04_01__Mw_8_1.xml") print(cat)
# Once again they can be written with the write() function. cat.write("temp_quake.xml", format="quakeml")
To show off some more things, I added a file containing all events from 2014 in the GCMT catalog.
import obspy cat = obspy.read_events("data/2014.ndk") print(cat)
cat.filter("depth > 100000", "magnitude > 7")