DEV Community

Arthur031221
Arthur031221

Posted on

Replaying earthquakes in the browser, and checking the waves against 3,933 real picks

When an earthquake is in the news, you get a magnitude and a map. I wanted to see what the waves did and how many seconds I would've had. I built Rumbleback to replay a real earthquake.

The 2024 Hualien earthquake replayed on a map of Taiwan

What you see

The blue ring is the first P wave at the surface. The orange ring is the first S wave. Small dots light up at real stations when analysts picked a P arrival. Strong motion instruments appear when the S wave reaches them, colored by the intensity USGS computed from their recording. Below the timeline is a nearby station's real seismogram, with the model's P and S arrivals drawn over it.

Drop a pin on your home to see the P and S arrival there. A slider asks "if an alert went out at this second" and shows how long before the S wave you'd have heard it, or whether you were inside the blind zone.

How the waves are computed

Travel times come from the iasp91 Earth model. A small Python script asks ObsPy TauP for the first P and S arrival on a grid of 34 source depths and about 900 distances, then stores a 166 KB table. The browser interpolates it for the quake's depth. A test compares that with 600 random TauP results off the grid. The median error is 0.01 s.

How I checked it

Each featured quake includes the picks USGS used to locate it. I compare the model with 3,933 first P arrivals from 14 quakes, up to 95 degrees away. The median error is 0.66 s, and 90 percent are within 1.75 s. I recomputed that with ObsPy directly to check that my interpolation wasn't hiding anything.

The model reproduces what instruments recorded for quakes 8 to 48 km deep. It doesn't forecast a quake it hasn't seen, because picks and origin times come from the same data. S waves have almost no picks in USGS data, so the S ring is the model alone. Surface waves and local ground aren't modeled, and the docs say so.

Under the hood

It's a static page with MapLibre and a canvas overlay for the waves. The pin lives in the browser. Shared links keep it after the #, so no server sees it. The end-to-end tests record every request the page makes and look for the pin's coordinates.

The code is MIT licensed: https://github.com/Arthur031221/Rumbleback. I'd like to hear about any quake where the timing looks wrong.

Top comments (0)