# pabloelara/e3ws architecture

> Architecture diagram of the GitHub repository pabloelara/e3ws, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pabloelara/e3ws
- Repository: https://github.com/pabloelara/e3ws

## Overview

E3WS is a single-station, machine-learning earthquake early-warning workflow: it processes continuous three-component waveforms, detects candidate events, picks the P phase, then repeatedly estimates magnitude and source parameters and records results. Station-specific detector preparation is a separate capability: catalog/remove earthquake intervals, extract noise features, and train a detector. The README documents these domain stages; the runtime excerpt shows model loading and the picker call, but omits parts of the inference loop, so unsupported runtime links are not inferred.

Main entry points: [`real_time/E3WS_rt.py`](https://github.com/pabloelara/e3ws/blob/main/real_time/E3WS_rt.py) (Monitoring runner), [`real_time/functions/pb_utils_v16.py`](https://github.com/pabloelara/e3ws/blob/main/real_time/functions/pb_utils_v16.py) (Waveform features), [`models/DET/build_DET/pb_save_DET_model.py`](https://github.com/pabloelara/e3ws/blob/main/models/DET/build_DET/pb_save_DET_model.py) (Detector training), [`real_time/functions/pick_func_v16.py`](https://github.com/pabloelara/e3ws/blob/main/real_time/functions/pick_func_v16.py) (P-phase picking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Real-time monitoring"]
  node_runner["Monitoring runner<br/>[E3WS_rt.py]"]
  node_detection["Event detection"]
  node_picking["P-phase picking<br/>[pick_func_v16.py]"]
  node_characterization["Source estimates<br/>[E3WS_rt.py]"]
  node_results["Estimate results"]
end

subgraph group_assets["Inference models"]
  node_detmodel["Station detector"]
  node_pickmodel["P-picker model"]
  node_magmodels["Magnitude models"]
  node_dismodels["Distance models"]
  node_depmodels["Depth models"]
  node_bazmodels["Back-azimuth models"]
end

subgraph group_detprep["Detector preparation"]
  node_catalog["Noise interval catalog<br/>[gen_catag.py]"]
  node_noisefeatures["Noise feature extraction<br/>[pb_FV_noise.py]"]
  node_earthquakefeatures["Earthquake feature data"]
  node_training["Detector training"]
end

subgraph group_features["Feature engineering"]
  node_featurepipeline["Waveform features<br/>[pb_utils_v16.py]"]
  node_featuremath["Feature calculations<br/>[pb_functions.py]"]
end

node_operator(("Station operator"))
node_waveforms["Three-component waveforms"]
node_instrument["Station response<br/>[SLRZ_HN.pz]"]

node_operator -->|"starts monitoring"| node_runner
node_waveforms -->|"provides records"| node_runner
node_runner -->|"loads detector"| node_detmodel
node_runner -->|"loads picker"| node_pickmodel
node_runner -->|"loads models"| node_magmodels
node_runner -->|"loads models"| node_dismodels
node_runner -->|"loads models"| node_depmodels
node_runner -->|"loads models"| node_bazmodels
node_runner -->|"calls picker"| node_picking
node_picking -->|"extracts features"| node_featurepipeline
node_featurepipeline -->|"uses calculations"| node_featuremath
node_runner -->|"updates estimates"| node_characterization
node_characterization -->|"writes estimates"| node_results
node_operator -->|"prepares station data"| node_catalog
node_catalog -->|"marks noise intervals"| node_noisefeatures
node_noisefeatures -->|"produces noise features"| node_training
node_earthquakefeatures -->|"supplies event features"| node_training
node_training -->|"trains detector"| node_detmodel
node_featurepipeline -.->|"corrects response"| node_instrument

click node_runner "https://github.com/pabloelara/e3ws/blob/main/real_time/E3WS_rt.py"
click node_detection "https://github.com/pabloelara/e3ws/tree/main/models/DET"
click node_picking "https://github.com/pabloelara/e3ws/blob/main/real_time/functions/pick_func_v16.py"
click node_characterization "https://github.com/pabloelara/e3ws/blob/main/real_time/E3WS_rt.py"
click node_results "https://github.com/pabloelara/e3ws/tree/main/real_time/results"
click node_detmodel "https://github.com/pabloelara/e3ws/tree/main/models/DET"
click node_pickmodel "https://github.com/pabloelara/e3ws/tree/main/models/PICK"
click node_magmodels "https://github.com/pabloelara/e3ws/tree/main/models/MAG"
click node_dismodels "https://github.com/pabloelara/e3ws/tree/main/models/DIS"
click node_depmodels "https://github.com/pabloelara/e3ws/tree/main/models/DEP"
click node_bazmodels "https://github.com/pabloelara/e3ws/tree/main/models/BAZ"
click node_catalog "https://github.com/pabloelara/e3ws/blob/main/models/DET/build_DET/gen_catag.py"
click node_noisefeatures "https://github.com/pabloelara/e3ws/blob/main/models/DET/build_DET/pb_FV_noise.py"
click node_earthquakefeatures "https://github.com/pabloelara/e3ws/tree/main/models/DET/build_DET/atr_eq"
click node_training "https://github.com/pabloelara/e3ws/blob/main/models/DET/build_DET/pb_save_DET_model.py"
click node_featurepipeline "https://github.com/pabloelara/e3ws/blob/main/real_time/functions/pb_utils_v16.py"
click node_featuremath "https://github.com/pabloelara/e3ws/blob/main/real_time/functions/pb_functions.py"
click node_instrument "https://github.com/pabloelara/e3ws/blob/main/real_time/pz/SLRZ_HN.pz"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runner,node_detection,node_picking,node_characterization,node_results toneBlue
class node_detmodel,node_pickmodel,node_magmodels,node_dismodels,node_depmodels,node_bazmodels toneAmber
class node_catalog,node_noisefeatures,node_earthquakefeatures,node_training toneMint
class node_featurepipeline,node_featuremath toneRose
class node_operator,node_waveforms toneIndigo
class node_instrument toneTeal
```

## Components

### Real-time monitoring

- [Monitoring runner](https://github.com/pabloelara/e3ws/blob/main/real_time/E3WS_rt.py): `real_time/E3WS_rt.py`
- [Event detection](https://github.com/pabloelara/e3ws/tree/main/models/DET): `models/DET`
- [P-phase picking](https://github.com/pabloelara/e3ws/blob/main/real_time/functions/pick_func_v16.py): `real_time/functions/pick_func_v16.py`
- [Source estimates](https://github.com/pabloelara/e3ws/blob/main/real_time/E3WS_rt.py): `real_time/E3WS_rt.py`
- [Estimate results](https://github.com/pabloelara/e3ws/tree/main/real_time/results): `real_time/results`

### Inference models

- [Station detector](https://github.com/pabloelara/e3ws/tree/main/models/DET): `models/DET`
- [P-picker model](https://github.com/pabloelara/e3ws/tree/main/models/PICK): `models/PICK`
- [Magnitude models](https://github.com/pabloelara/e3ws/tree/main/models/MAG): `models/MAG`
- [Distance models](https://github.com/pabloelara/e3ws/tree/main/models/DIS): `models/DIS`
- [Depth models](https://github.com/pabloelara/e3ws/tree/main/models/DEP): `models/DEP`
- [Back-azimuth models](https://github.com/pabloelara/e3ws/tree/main/models/BAZ): `models/BAZ`

### Detector preparation

- [Noise interval catalog](https://github.com/pabloelara/e3ws/blob/main/models/DET/build_DET/gen_catag.py): `models/DET/build_DET/gen_catag.py`
- [Noise feature extraction](https://github.com/pabloelara/e3ws/blob/main/models/DET/build_DET/pb_FV_noise.py): `models/DET/build_DET/pb_FV_noise.py`
- [Earthquake feature data](https://github.com/pabloelara/e3ws/tree/main/models/DET/build_DET/atr_eq): `models/DET/build_DET/atr_eq`
- [Detector training](https://github.com/pabloelara/e3ws/blob/main/models/DET/build_DET/pb_save_DET_model.py): `models/DET/build_DET/pb_save_DET_model.py`

### Feature engineering

- [Waveform features](https://github.com/pabloelara/e3ws/blob/main/real_time/functions/pb_utils_v16.py): `real_time/functions/pb_utils_v16.py`
- [Feature calculations](https://github.com/pabloelara/e3ws/blob/main/real_time/functions/pb_functions.py): `real_time/functions/pb_functions.py`

### Other components

- **Station operator**
- **Three-component waveforms**
- [Station response](https://github.com/pabloelara/e3ws/blob/main/real_time/pz/SLRZ_HN.pz): `real_time/pz/SLRZ_HN.pz`

## Connections

- Station operator → Monitoring runner: starts monitoring (evidence: `README.md`)
- Three-component waveforms → Monitoring runner: provides records (evidence: `README.md`)
- Monitoring runner → Station detector: loads detector (evidence: `real_time/E3WS_rt.py`)
- Monitoring runner → P-picker model: loads picker (evidence: `real_time/E3WS_rt.py`)
- Monitoring runner → Magnitude models: loads models (evidence: `real_time/E3WS_rt.py`)
- Monitoring runner → Distance models: loads models (evidence: `real_time/E3WS_rt.py`)
- Monitoring runner → Depth models: loads models (evidence: `real_time/E3WS_rt.py`)
- Monitoring runner → Back-azimuth models: loads models (evidence: `real_time/E3WS_rt.py`)
- Monitoring runner → P-phase picking: calls picker (evidence: `real_time/E3WS_rt.py`)
- P-phase picking → Waveform features: extracts features (evidence: `real_time/functions/pick_func_v16.py`)
- Waveform features → Feature calculations: uses calculations (evidence: `real_time/functions/pb_utils_v16.py`)
- Monitoring runner → Source estimates: updates estimates (evidence: `README.md`)
- Source estimates → Estimate results: writes estimates (evidence: `real_time/E3WS_rt.py`)
- Station operator → Noise interval catalog: prepares station data (evidence: `README.md`)
- Noise interval catalog → Noise feature extraction: marks noise intervals (evidence: `models/DET/build_DET/gen_catag.py`)
- Noise feature extraction → Detector training: produces noise features (evidence: `README.md`)
- Earthquake feature data → Detector training: supplies event features (evidence: `README.md`)
- Detector training → Station detector: trains detector (evidence: `README.md`)
- Waveform features → Station response: corrects response
