North Korea made another nuclear test this morning just after 0330 UTC. Inspired by Steven Gibbons's tweets this morning, I wanted to download the data for myself, in as few lines of Python as possible.
Here we go! First some preliminaries:
In [1]:
import matplotlib.pyplot as plt
%matplotlib inline
We'll use the awesome ObsPy library. Following the instructions in the ObsPy documentation, and using IRIS as the data source (per Steve's tweets)...
In [2]:
from obspy.clients.fdsn import Client
client = Client("IRIS")
In [3]:
from obspy import UTCDateTime
t = UTCDateTime("2017-09-03_03:30:00")
st = client.get_waveforms("IC", "MDJ", "00", "BHZ", t, t + 5*60)
st.plot()
This st thing is the ObsPy stream.
In [4]:
st
Out[4]:
We requested the broadband channel, but some stations have lots of others:
LHZ: long period ~1 Hz, with Z for vertical, or N or E for horizontal.BHZ: broadband 10–80 Hz, with Z for vertical, or N or E for horizontal.HHZ: broadband 80–250 Hz, with Z for vertical, or N or E for horizontal.
In [5]:
inventory = client.get_stations(network="IC", station="MDJ")
inventory.plot()
plt.show()
In [6]:
inventory
Out[6]:
Let's compare to the test in September 2016:
In [7]:
t1 = UTCDateTime("2016-09-09_00:30:00")
st1 = client.get_waveforms("IC", "MDJ", "00", "BHZ", t1, t1 + 5*60)
st1.plot()
We can plot the tests together:
In [8]:
label = "{network}.{station}.{location}.{channel}".format(**st.traces[0].meta)
plt.figure(figsize=(15,5))
plt.plot(st.traces[0], label="3 Sept 2017")
plt.plot(st1.traces[0], label="9 Sept 2016")
plt.text(-200, 2.5e6, label, size=20)
plt.legend()
plt.grid()
plt.show()
Clearly a substantially more powerful explosion.
In [9]:
st = client.get_waveforms("IC", "MDJ", "*", "HHZ", t, t + 15*60)
st.plot()
In [10]:
z = st.traces[0]
NFFT = 2048
Fs = st.traces[0].meta.sampling_rate # Sample rate in Hz
plt.figure(figsize=(15, 5))
Pxx, freqs, bins, im = plt.specgram(z, NFFT=NFFT, Fs=Fs, noverlap=int(0.9*NFFT), cmap='viridis', vmin=-50, vmax=50)
plt.show()
Steve said he thought the signal at about 600 s might be a rockfall.
© 2017 agilescientific.com and licensed CC-BY 4.0