fuzzyworld

shadow-zone / files / src / earthquakeData.ts

earthquakeData.ts

2.0 KB · history · blame

1/**
2 * Types for pre-fetched real-world seismic datasets.
3 * JSON files in src/data/ are populated by scripts/fetch-earthquake-data.mjs.
4 */
5
6export interface PhaseArrival {
7 /** FDSN station code, e.g. "ANMO" */
8 station: string;
9 /** FDSN network code, e.g. "IU" */
10 network: string;
11 /** Epicentral distance in degrees */
12 distanceDeg: number;
13 /** Observed P travel time in seconds (arrival_time - origin_time). null if phase not picked. */
14 pTravelTimeSec: number | null;
15 /** Observed S travel time in seconds. null if not picked or in shadow. */
16 sTravelTimeSec: number | null;
17}
18
19export interface EarthquakeDataset {
20 /** Short unique identifier, e.g. "tohoku-2011" */
21 id: string;
22 /** Human-readable name */
23 name: string;
24 /** ISO8601 origin time */
25 originTime: string;
26 /** Epicenter latitude */
27 latitude: number;
28 /** Epicenter longitude */
29 longitude: number;
30 /** Hypocenter depth in km */
31 depthKm: number;
32 /** Moment magnitude */
33 magnitudeMw: number;
34 /** USGS ComCat event ID, e.g. "official20110311054624120_30" */
35 usgsId: string;
36 /** Short description of what makes this event interesting for shadow zone study */
37 note: string;
38 /** Phase arrival observations from global network */
39 arrivals: PhaseArrival[];
40}
41
42// ── Dataset registry ──────────────────────────────────────────────────────────
43// Each dataset JSON is imported statically so Vite bundles it.
44// Run `npm run fetch-data` to (re-)populate the JSON files.
45
46import tohoku from './data/tohoku-2011.json';
47import chile from './data/chile-2010.json';
48import okhotsk from './data/okhotsk-2013.json';
49
50export const EARTHQUAKE_DATASETS: EarthquakeDataset[] = [
51 tohoku as EarthquakeDataset,
52 chile as EarthquakeDataset,
53 okhotsk as EarthquakeDataset,
54];
55
56export function getDataset(id: string): EarthquakeDataset | undefined {
57 return EARTHQUAKE_DATASETS.find(d => d.id === id);
58}