There are various methods you can use to read historic OpenEEW data, in order to test new algorithms. Here we provide an example with our Python library.
We also have a dashboard in Node-RED that allows you to view historic data.
OpenEEW data with Python
Presently you can use the OpenEEW package for Python to download and analyze OpenEEW accelerometer data.
This tutorial allows you to get started working with OpenEEW accelerometer data in Python (version 3.5 or later) by analyzing a magnitude 7.2 earthquake that occurred in Mexico on 16 February 2018.
The code is available as a Jupyer notebook from our github repo.
To install openeew, you can use pip(for Python 3.5 or later):
To reproduce the results of this tutorial, you will also need to install some other packages:
Finding earthquake details
Mexico's national seismological service (SSN) has a catalog of past earthquakes. Here, you can find details of the magnitude 7.2 earthquake that struck near the coast of Oaxaca on 16 February 2018, which we will store in a dict variable for later use:
Using the folium package, we can visualize the epicenter on a map:
This produces a beautiful interactive map with the epicenter shown as a crimson circle:
Earthquake epicenter (map produced using folium)
Getting device locations
The next step is to see where OpenEEW's seismic devices were located at the time of the earthquake. This is straightforward using OpenEEW:
Now we can add the device locations to the map from above:
Epicenter and device locations (map produced using folium)
We see that the majority of devices are deployed along the Pacific coast of Mexico, which is its most seismically active region.
Clicking on the blue markers, we can see the corresponding device IDs:
Devices closest to epicenter (map produced using folium)
Getting accelerometer records
Now we know where the different devices were located at the time of the earthquake, we would like to see their accelerometer records. This can be achieved using the method
get_filtered_records together with the function
get_df_from_records, which returns the accelerometer records as a pandas.DataFrame:
For plotting purposes, we extract a
datetime.datetime object from the Unix time
sample_t and then select the required columns:
Looking at the first few rows with
To visualize these records, we use the package plotnine and a simple function that outputs a plot of the x-, y- and z-axes for a given
From the map above, we see that the closest station to the epicenter was 004, but unfortunately this device was not sending data at the time. Indeed, maintaining device connectivity is one of the challenges of managing a seismic network. The next closest station was 006, which we pass to our function:
This gives the following output for the x-axis:
Accelerometer records for device 006 (plot created using plotnine)
We see that this device recorded some large accelerometer values (in Gal, where 1 Gal = 1cm/s²), as we would expect by its proximity to the epicenter. The crimson vertical line, which shows when the earthquake started, is about 10 seconds before the shaking started to affect this sensor.
Now we have an idea how the earthquake affected nearby devices, let's have a look at one further away. Going back to the map, we see that there was a device, 000, located in Mexico City, more than 350km away:
Device located in the south of Mexico City (map produced using folium)
For this device,
plot_seismogram outputs the following for the x-axis:
Accelerometer records for device 000 (plot created using plotnine)
We immediately note some differences from the first plot:
the acceleration values are much lower
more time passed after the earthquake began before it was detected: approximately 1 minute compared to 10 seconds for the closest device
The first point highlights that shaking caused by an earthquake changes with distance from the epicenter, while the second point highlights the window of opportunity after an earthquake is first detected to send alerts to faraway locations before shaking there begins.
The challenge is therefore to accurately estimate how shaking will be felt in faraway locations and to do so quickly before shaking in those locations begins.
Comparing maximum accelerations
To see how distance affects the level of shaking, it is interesting to compare the maximum acceleration of each device with distance from the epicenter.
Here we calculate the maximum horizontal acceleration of each device:
We can then combine these values with the device metadata:
Finally, we create a plot using this code:
How shaking changes with distance (plot created using plotnine)
We see that the maximum acceleration decreases exponentially as distance from epicenter increases.