Write the automatic event processing for a geological survey's twelve-station seismic network: origin time, hypocentre and local magnitude from three-component waveforms, scored on further events with known truth.
harbor run -t reactive-labs/quake-locationharbor download reactive-labs/quake-locationYou are Tove Lindqvar, analyst in the Seismology Section of the Skarland Geological Survey (SGS). The section runs the Tindra Valley Seismic Network (network code TV): twelve three-component stations around the Tindra valley. Nobody has processed its triggers since the previous analyst left in May. Today is Thursday 2 July 2026, and Halvard Ostrem, Head of Seismic Monitoring, wrote to you this morning:
I want one program that takes a wfx event folder and gives origin time, hypocentre and ML according to SOP-SEIS-014, good enough that Sigrun only has to look at the odd ones. We will run it over the whole backlog from 1 January and then on every new trigger, so it has to cope with the network as it actually was on the day of each event. Please send me the results for the 29 events in the working set together with the program.
In /app/inputs:
request/: Halvard's emailevents/: the working set, 29 event folders exported from the archive with wfx, January to April 2026. Each
holds event.json (one entry per trace: id, start time, sampling rate, number of samples, datalogger) and
waveforms.npz (one int32 array of counts per trace id)sop/: SOP-SEIS-014 rev D (event processing) and technical note TN-2019-03 rev 2 (the ML scale)network/: the station database export, the inventory with the instrument responses, a velocity model file
and the ML station residualsmemos/, logs/: the section's memo on the velocity model, the operations e-log from October 2025 to June
2026 and the field tickets of 2026reference/: manufacturer documents for the sensors and dataloggers, the quarry's blast record for January to
April, and Sigrun Valle's manual solutions for six events of the working setprevious_analyst/: Jonas Kveld's script, his handover notes and his draft bulletin/app/output/analyze.py, run as
python3 /app/output/analyze.py <event_dir> <out.json>
<event_dir> is one event folder in the same format as those in /app/inputs/events (read-only; its name is
the event id). The program writes <out.json>, a JSON object with these keys:
| key | meaning |
|---|---|
event_id |
the event_id of the sidecar |
origin_time |
origin time in UTC, ISO 8601 with at least millisecond precision, e.g. 2026-03-04T11:22:33.456Z |
latitude, longitude |
epicentre in decimal degrees, WGS84, north and east positive |
depth_km |
depth in km below sea level, positive downward |
ml |
local magnitude ML as defined by the section |
Further keys are ignored. The program may load files that you put next to it in /app/output (find them
relative to __file__); /app/inputs is not available when it runs. It runs on one CPU core with 3 GB of
memory and no network, with Python 3.12, numpy, scipy and pandas, and must finish each event within 60 seconds
(a batch of 45 events within 15 minutes).
/app/output/results.csv with the header event_id,origin_time,latitude,longitude,depth_km,ml and one row
for each of the 29 events in /app/inputs/events, in the same units and conventions.
The program is run on further event folders from the same network and archive, 1 January to 30 June 2026, for which the true origin time, hypocentre and magnitude are known: local earthquakes, quarry blasts and events up to about 190 km from the network. Each event is scored on four quantities. With D the distance of the true epicentre from the network reference point (62.4000 N, 9.8000 E):
| quantity | tolerance, true ML 1.0 and above | tolerance, true ML below 1.0 | weight |
|---|---|---|---|
| epicentre (distance from the true epicentre on the WGS84 ellipsoid) | 1.0 km, plus 1.5 % of (D - 40 km) when D > 40 km | 2.0 km, plus 1.5 % of (D - 40 km) when D > 40 km | 0.40 (0.50 when D > 35 km) |
| depth; scored only when D is at most 35 km | 1.5 km | 4.5 km | 0.10 |
| origin time | 0.16 s | 0.44 s | 0.15 |
| ML | 0.09 | 0.12 | 0.35 |
A quantity earns full credit within its tolerance and loses credit linearly to zero at three times the tolerance.
An event whose epicentre earns no credit scores zero altogether, and so does an event for which the program
fails, runs out of time, or writes a result with a missing key or a value that is not a finite number. The rows
of results.csv are scored in the same way against the true values of the 29 events of the working set. The
final score is 0.8 times the mean over the further events plus 0.2 times the mean over results.csv.