gamma-wadati 0.1.0.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gamma_wadati-0.1.0.dev1/PKG-INFO +148 -0
- gamma_wadati-0.1.0.dev1/README.md +138 -0
- gamma_wadati-0.1.0.dev1/pyproject.toml +14 -0
- gamma_wadati-0.1.0.dev1/setup.cfg +4 -0
- gamma_wadati-0.1.0.dev1/src/gamma_wadati.egg-info/PKG-INFO +148 -0
- gamma_wadati-0.1.0.dev1/src/gamma_wadati.egg-info/SOURCES.txt +14 -0
- gamma_wadati-0.1.0.dev1/src/gamma_wadati.egg-info/dependency_links.txt +1 -0
- gamma_wadati-0.1.0.dev1/src/gamma_wadati.egg-info/requires.txt +3 -0
- gamma_wadati-0.1.0.dev1/src/gamma_wadati.egg-info/top_level.txt +1 -0
- gamma_wadati-0.1.0.dev1/src/wadati/__init__.py +11 -0
- gamma_wadati-0.1.0.dev1/src/wadati/_base.py +616 -0
- gamma_wadati-0.1.0.dev1/src/wadati/_bayesian_mixture.py +918 -0
- gamma_wadati-0.1.0.dev1/src/wadati/_gaussian_mixture.py +1175 -0
- gamma_wadati-0.1.0.dev1/src/wadati/forward.py +197 -0
- gamma_wadati-0.1.0.dev1/src/wadati/pairing.py +128 -0
- gamma_wadati-0.1.0.dev1/src/wadati/windowing.py +245 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gamma-wadati
|
|
3
|
+
Version: 0.1.0.dev1
|
|
4
|
+
Summary: Earthquake phase association and location as a Bayesian Gaussian mixture on the Wadati transform
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: numpy
|
|
8
|
+
Requires-Dist: scipy
|
|
9
|
+
Requires-Dist: scikit-learn>=1.9
|
|
10
|
+
|
|
11
|
+
# Wadati BGMM: joint phase association and 3D location
|
|
12
|
+
|
|
13
|
+
Earthquake phase **association** and **location** solved together as a
|
|
14
|
+
(Bayesian) Gaussian Mixture Model, in the spirit of GaMMA but using the
|
|
15
|
+
**Wadati transform**. For every station that picks both P and S of an event we
|
|
16
|
+
form
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
M = (t_P + t_S)/2 = t0 + p·r D = (t_S − t_P)/2 = q·r
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
which are linear in source distance `r`. The transform decouples origin time
|
|
23
|
+
from location: because `α = p/q`, the quantity `u = M − α·D = t0` for any true
|
|
24
|
+
pick, *independent of location*. Origin time is therefore estimated location-free
|
|
25
|
+
(a weighted mean), and the hypocenter follows from distance trilateration
|
|
26
|
+
`r ≈ β·D`. This breaks the usual depth/origin-time tradeoff and makes full 3-D
|
|
27
|
+
`(x, y, z)` location tractable.
|
|
28
|
+
|
|
29
|
+
The one structural change to a textbook GMM: each component's mean is **not** a
|
|
30
|
+
free parameter but the Wadati forward prediction `μ_nk = (t0_k + p·r_nk,
|
|
31
|
+
q·r_nk)` of event `k`'s `(t0, x, y, z)` at station `n`. Everything else
|
|
32
|
+
(responsibilities, covariance, DP weights, Wishart prior) is standard.
|
|
33
|
+
See [`formulation.md`](formulation.md) for the full derivation.
|
|
34
|
+
|
|
35
|
+
## Layout
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
src/wadati/_gaussian_mixture.py vendored sklearn GaussianMixture, edited
|
|
39
|
+
src/wadati/_bayesian_mixture.py vendored sklearn BayesianGaussianMixture, edited
|
|
40
|
+
src/wadati/_base.py vendored sklearn EM/VB loop (unchanged)
|
|
41
|
+
src/wadati/forward.py velocity model, predict_mean, estimate_t0, locate
|
|
42
|
+
src/wadati/windowing.py t0 pre-clustering into time windows
|
|
43
|
+
synthetic.py 3-case 3D catalog generator (+ ~20% false picks)
|
|
44
|
+
pipeline.py window -> BGMM -> post-hoc filter -> metrics
|
|
45
|
+
plots.py Wadati M-D, map, depth section, timeline
|
|
46
|
+
formulation.md derivation
|
|
47
|
+
mixture/ pristine sklearn 1.9.0 sources (diff reference)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The mixture models are vendored from scikit-learn 1.9.0 and committed unmodified
|
|
51
|
+
first, so `git log -p src/wadati/_gaussian_mixture.py` shows exactly the
|
|
52
|
+
algorithm change against upstream.
|
|
53
|
+
|
|
54
|
+
## Run
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
PYTHONPATH=src python3 synthetic.py # print the synthetic catalog
|
|
58
|
+
PYTHONPATH=src python3 plots.py # figures/catalog_overview.png (truth)
|
|
59
|
+
PYTHONPATH=src python3 -m wadati.windowing # show the t0 windows
|
|
60
|
+
PYTHONPATH=src python3 pipeline.py # end-to-end metrics + figures/results_overview.png
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Requires `numpy`, `scipy`, `scikit-learn` (1.9.x), `matplotlib`.
|
|
64
|
+
|
|
65
|
+
## Three test cases
|
|
66
|
+
|
|
67
|
+
The synthetic catalog merges, with absolute time offsets, three configurations
|
|
68
|
+
that stress different parts of the problem:
|
|
69
|
+
|
|
70
|
+
| Case | Setup | What it tests |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| 1 | same `t0`, different locations | spatial separation (M, D carry only distance, so association is pure trilateration) |
|
|
73
|
+
| 2 | same location, different `t0` | temporal separation via `u = M − αD` |
|
|
74
|
+
| 3 | both close (~3 s, ~5 km) | the hardest case (still identifiable) |
|
|
75
|
+
|
|
76
|
+
## Initialization
|
|
77
|
+
|
|
78
|
+
Two strategies, selected by the sklearn-style `init_params` (they differ only in
|
|
79
|
+
whether the init also fixes the source parameters; both feed the same EM/VB loop):
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
BayesianGaussianMixture(init_params="smallest_d", n_init=1, ...) # deterministic (default)
|
|
83
|
+
BayesianGaussianMixture(init_params="kmeans", n_init=20, ...) # random, restart-selected
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The default, `"smallest_d"`, seeds components deterministically from **candidate
|
|
87
|
+
event locations**, not from picks. Within each t0 group, picks are scanned in
|
|
88
|
+
order of increasing `D`
|
|
89
|
+
(= q·distance): a small `D` means the station is near the source, so its
|
|
90
|
+
location is the best epicenter proxy. The smallest-`D` picks (spatially
|
|
91
|
+
de-duplicated so several same-t0 events each get a seed) become the initial
|
|
92
|
+
events `(t0 = group mean of u, location = that station)`, and these are used
|
|
93
|
+
**directly** as the starting hypocenters; the first trilateration runs in the
|
|
94
|
+
first M-step. No randomness is involved, so `n_init = 1` suffices.
|
|
95
|
+
|
|
96
|
+
A controlled comparison (6 random catalogs, 20% false picks) shows why this is
|
|
97
|
+
the right default:
|
|
98
|
+
|
|
99
|
+
| initialization | `n_init=1` | `n_init=20` |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| k-means on (t0, station x, y) | ~0.8 (seed-dependent) | 0.95 |
|
|
102
|
+
| smallest-D candidate locations (deterministic) | **0.91** (reproducible) | 0.91 (restarts are no-ops) |
|
|
103
|
+
|
|
104
|
+
No single initialization exceeds ~0.91: the likelihood is multimodal and the
|
|
105
|
+
jump to ~0.95 comes from restart *selection by ELBO*, not from init quality.
|
|
106
|
+
The deterministic init matches the best single shot while being reproducible and
|
|
107
|
+
restart-free.
|
|
108
|
+
|
|
109
|
+
## Results
|
|
110
|
+
|
|
111
|
+
Across 6 random catalogs (8 events, ~20% false picks), deterministic
|
|
112
|
+
`n_init = 1`: mean association ARI ≈ **0.91**, median origin-time error ≈ 0.16 s,
|
|
113
|
+
epicenter ≈ 0.6 km, depth ≈ 1.8 km, no spurious events. Case 1 (same t0,
|
|
114
|
+
different location) and Case 2 (different t0, same location) recover cleanly with
|
|
115
|
+
the Dirichlet process pruning the event count automatically.
|
|
116
|
+
|
|
117
|
+
Case 3 (close in both, ~3 s and ~5 km) is the hardest but **identifiable**:
|
|
118
|
+
exhaustive enumeration of all partitions confirms the true labeling is the
|
|
119
|
+
maximum-likelihood one (gap = 0, under both free and fixed covariance). The
|
|
120
|
+
remaining pipeline misses on Case 3 are EM local optima, not fundamental
|
|
121
|
+
ambiguity, and randomized restarts (`n_init = 20`) raise the mean ARI to ≈ 0.95.
|
|
122
|
+
(Pushing the separation down to ~2 s crosses an identifiability threshold: two
|
|
123
|
+
events that close produce too few, too noisy picks to distinguish, and the ML
|
|
124
|
+
partition then overfits the source parameters to noise — the true labeling is no
|
|
125
|
+
longer the maximum-likelihood one.)
|
|
126
|
+
|
|
127
|
+
## Phase weights
|
|
128
|
+
|
|
129
|
+
Each pick carries a quality weight `w_n ∈ [0,1]` (e.g. a picker's confidence).
|
|
130
|
+
Following GaMMA, the weight enters the **likelihood** (`log P += log w_n` in the
|
|
131
|
+
E-step), not the M-step. Added to every component, it cancels in the
|
|
132
|
+
responsibility normalization, so it **never changes the geometric fit** — it
|
|
133
|
+
only lowers a poor pick's marginal score. This is the right choice for an
|
|
134
|
+
*uncalibrated* ML confidence: putting `w` on `P` (a constant offset) is immune to
|
|
135
|
+
its absolute scale, whereas putting `w` on `log P` (observation-weighting) would
|
|
136
|
+
shrink effective counts and make the Dirichlet process prune real events. The
|
|
137
|
+
pipeline consumes the quality signal post-hoc: a pick is kept only if
|
|
138
|
+
`max_k γ_nk · w_n ≥ min_resp` (fit confidence × quality) and its Mahalanobis
|
|
139
|
+
residual is small, and each event is relocated from its kept picks weighted by
|
|
140
|
+
`w_n`.
|
|
141
|
+
|
|
142
|
+
False picks are otherwise handled post-hoc: drop picks that fail the gate above,
|
|
143
|
+
then refit each event's hypocenter from its own kept picks. Because depth is well
|
|
144
|
+
constrained by the Wadati distance `r = β·D` (each pick fixes the source-station
|
|
145
|
+
distance), depth errors trace to association mistakes, not to depth being
|
|
146
|
+
unresolvable. A dedicated uniform noise component in the mixture (GaMMA's dummy
|
|
147
|
+
component, the principled home for `w` as `P(real)` once calibrated) is left for
|
|
148
|
+
future work.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Wadati BGMM: joint phase association and 3D location
|
|
2
|
+
|
|
3
|
+
Earthquake phase **association** and **location** solved together as a
|
|
4
|
+
(Bayesian) Gaussian Mixture Model, in the spirit of GaMMA but using the
|
|
5
|
+
**Wadati transform**. For every station that picks both P and S of an event we
|
|
6
|
+
form
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
M = (t_P + t_S)/2 = t0 + p·r D = (t_S − t_P)/2 = q·r
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
which are linear in source distance `r`. The transform decouples origin time
|
|
13
|
+
from location: because `α = p/q`, the quantity `u = M − α·D = t0` for any true
|
|
14
|
+
pick, *independent of location*. Origin time is therefore estimated location-free
|
|
15
|
+
(a weighted mean), and the hypocenter follows from distance trilateration
|
|
16
|
+
`r ≈ β·D`. This breaks the usual depth/origin-time tradeoff and makes full 3-D
|
|
17
|
+
`(x, y, z)` location tractable.
|
|
18
|
+
|
|
19
|
+
The one structural change to a textbook GMM: each component's mean is **not** a
|
|
20
|
+
free parameter but the Wadati forward prediction `μ_nk = (t0_k + p·r_nk,
|
|
21
|
+
q·r_nk)` of event `k`'s `(t0, x, y, z)` at station `n`. Everything else
|
|
22
|
+
(responsibilities, covariance, DP weights, Wishart prior) is standard.
|
|
23
|
+
See [`formulation.md`](formulation.md) for the full derivation.
|
|
24
|
+
|
|
25
|
+
## Layout
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
src/wadati/_gaussian_mixture.py vendored sklearn GaussianMixture, edited
|
|
29
|
+
src/wadati/_bayesian_mixture.py vendored sklearn BayesianGaussianMixture, edited
|
|
30
|
+
src/wadati/_base.py vendored sklearn EM/VB loop (unchanged)
|
|
31
|
+
src/wadati/forward.py velocity model, predict_mean, estimate_t0, locate
|
|
32
|
+
src/wadati/windowing.py t0 pre-clustering into time windows
|
|
33
|
+
synthetic.py 3-case 3D catalog generator (+ ~20% false picks)
|
|
34
|
+
pipeline.py window -> BGMM -> post-hoc filter -> metrics
|
|
35
|
+
plots.py Wadati M-D, map, depth section, timeline
|
|
36
|
+
formulation.md derivation
|
|
37
|
+
mixture/ pristine sklearn 1.9.0 sources (diff reference)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The mixture models are vendored from scikit-learn 1.9.0 and committed unmodified
|
|
41
|
+
first, so `git log -p src/wadati/_gaussian_mixture.py` shows exactly the
|
|
42
|
+
algorithm change against upstream.
|
|
43
|
+
|
|
44
|
+
## Run
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
PYTHONPATH=src python3 synthetic.py # print the synthetic catalog
|
|
48
|
+
PYTHONPATH=src python3 plots.py # figures/catalog_overview.png (truth)
|
|
49
|
+
PYTHONPATH=src python3 -m wadati.windowing # show the t0 windows
|
|
50
|
+
PYTHONPATH=src python3 pipeline.py # end-to-end metrics + figures/results_overview.png
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Requires `numpy`, `scipy`, `scikit-learn` (1.9.x), `matplotlib`.
|
|
54
|
+
|
|
55
|
+
## Three test cases
|
|
56
|
+
|
|
57
|
+
The synthetic catalog merges, with absolute time offsets, three configurations
|
|
58
|
+
that stress different parts of the problem:
|
|
59
|
+
|
|
60
|
+
| Case | Setup | What it tests |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| 1 | same `t0`, different locations | spatial separation (M, D carry only distance, so association is pure trilateration) |
|
|
63
|
+
| 2 | same location, different `t0` | temporal separation via `u = M − αD` |
|
|
64
|
+
| 3 | both close (~3 s, ~5 km) | the hardest case (still identifiable) |
|
|
65
|
+
|
|
66
|
+
## Initialization
|
|
67
|
+
|
|
68
|
+
Two strategies, selected by the sklearn-style `init_params` (they differ only in
|
|
69
|
+
whether the init also fixes the source parameters; both feed the same EM/VB loop):
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
BayesianGaussianMixture(init_params="smallest_d", n_init=1, ...) # deterministic (default)
|
|
73
|
+
BayesianGaussianMixture(init_params="kmeans", n_init=20, ...) # random, restart-selected
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The default, `"smallest_d"`, seeds components deterministically from **candidate
|
|
77
|
+
event locations**, not from picks. Within each t0 group, picks are scanned in
|
|
78
|
+
order of increasing `D`
|
|
79
|
+
(= q·distance): a small `D` means the station is near the source, so its
|
|
80
|
+
location is the best epicenter proxy. The smallest-`D` picks (spatially
|
|
81
|
+
de-duplicated so several same-t0 events each get a seed) become the initial
|
|
82
|
+
events `(t0 = group mean of u, location = that station)`, and these are used
|
|
83
|
+
**directly** as the starting hypocenters; the first trilateration runs in the
|
|
84
|
+
first M-step. No randomness is involved, so `n_init = 1` suffices.
|
|
85
|
+
|
|
86
|
+
A controlled comparison (6 random catalogs, 20% false picks) shows why this is
|
|
87
|
+
the right default:
|
|
88
|
+
|
|
89
|
+
| initialization | `n_init=1` | `n_init=20` |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| k-means on (t0, station x, y) | ~0.8 (seed-dependent) | 0.95 |
|
|
92
|
+
| smallest-D candidate locations (deterministic) | **0.91** (reproducible) | 0.91 (restarts are no-ops) |
|
|
93
|
+
|
|
94
|
+
No single initialization exceeds ~0.91: the likelihood is multimodal and the
|
|
95
|
+
jump to ~0.95 comes from restart *selection by ELBO*, not from init quality.
|
|
96
|
+
The deterministic init matches the best single shot while being reproducible and
|
|
97
|
+
restart-free.
|
|
98
|
+
|
|
99
|
+
## Results
|
|
100
|
+
|
|
101
|
+
Across 6 random catalogs (8 events, ~20% false picks), deterministic
|
|
102
|
+
`n_init = 1`: mean association ARI ≈ **0.91**, median origin-time error ≈ 0.16 s,
|
|
103
|
+
epicenter ≈ 0.6 km, depth ≈ 1.8 km, no spurious events. Case 1 (same t0,
|
|
104
|
+
different location) and Case 2 (different t0, same location) recover cleanly with
|
|
105
|
+
the Dirichlet process pruning the event count automatically.
|
|
106
|
+
|
|
107
|
+
Case 3 (close in both, ~3 s and ~5 km) is the hardest but **identifiable**:
|
|
108
|
+
exhaustive enumeration of all partitions confirms the true labeling is the
|
|
109
|
+
maximum-likelihood one (gap = 0, under both free and fixed covariance). The
|
|
110
|
+
remaining pipeline misses on Case 3 are EM local optima, not fundamental
|
|
111
|
+
ambiguity, and randomized restarts (`n_init = 20`) raise the mean ARI to ≈ 0.95.
|
|
112
|
+
(Pushing the separation down to ~2 s crosses an identifiability threshold: two
|
|
113
|
+
events that close produce too few, too noisy picks to distinguish, and the ML
|
|
114
|
+
partition then overfits the source parameters to noise — the true labeling is no
|
|
115
|
+
longer the maximum-likelihood one.)
|
|
116
|
+
|
|
117
|
+
## Phase weights
|
|
118
|
+
|
|
119
|
+
Each pick carries a quality weight `w_n ∈ [0,1]` (e.g. a picker's confidence).
|
|
120
|
+
Following GaMMA, the weight enters the **likelihood** (`log P += log w_n` in the
|
|
121
|
+
E-step), not the M-step. Added to every component, it cancels in the
|
|
122
|
+
responsibility normalization, so it **never changes the geometric fit** — it
|
|
123
|
+
only lowers a poor pick's marginal score. This is the right choice for an
|
|
124
|
+
*uncalibrated* ML confidence: putting `w` on `P` (a constant offset) is immune to
|
|
125
|
+
its absolute scale, whereas putting `w` on `log P` (observation-weighting) would
|
|
126
|
+
shrink effective counts and make the Dirichlet process prune real events. The
|
|
127
|
+
pipeline consumes the quality signal post-hoc: a pick is kept only if
|
|
128
|
+
`max_k γ_nk · w_n ≥ min_resp` (fit confidence × quality) and its Mahalanobis
|
|
129
|
+
residual is small, and each event is relocated from its kept picks weighted by
|
|
130
|
+
`w_n`.
|
|
131
|
+
|
|
132
|
+
False picks are otherwise handled post-hoc: drop picks that fail the gate above,
|
|
133
|
+
then refit each event's hypocenter from its own kept picks. Because depth is well
|
|
134
|
+
constrained by the Wadati distance `r = β·D` (each pick fixes the source-station
|
|
135
|
+
distance), depth errors trace to association mistakes, not to depth being
|
|
136
|
+
unresolvable. A dedicated uniform noise component in the mixture (GaMMA's dummy
|
|
137
|
+
component, the principled home for `w` as `P(real)` once calibrated) is left for
|
|
138
|
+
future work.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "gamma-wadati"
|
|
7
|
+
version = "0.1.0.dev1"
|
|
8
|
+
description = "Earthquake phase association and location as a Bayesian Gaussian mixture on the Wadati transform"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = ["numpy", "scipy", "scikit-learn>=1.9"] # 1.9.1 is the version QuakeFlow's benchmarks run
|
|
12
|
+
|
|
13
|
+
[tool.setuptools.packages.find]
|
|
14
|
+
where = ["src"]
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gamma-wadati
|
|
3
|
+
Version: 0.1.0.dev1
|
|
4
|
+
Summary: Earthquake phase association and location as a Bayesian Gaussian mixture on the Wadati transform
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: numpy
|
|
8
|
+
Requires-Dist: scipy
|
|
9
|
+
Requires-Dist: scikit-learn>=1.9
|
|
10
|
+
|
|
11
|
+
# Wadati BGMM: joint phase association and 3D location
|
|
12
|
+
|
|
13
|
+
Earthquake phase **association** and **location** solved together as a
|
|
14
|
+
(Bayesian) Gaussian Mixture Model, in the spirit of GaMMA but using the
|
|
15
|
+
**Wadati transform**. For every station that picks both P and S of an event we
|
|
16
|
+
form
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
M = (t_P + t_S)/2 = t0 + p·r D = (t_S − t_P)/2 = q·r
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
which are linear in source distance `r`. The transform decouples origin time
|
|
23
|
+
from location: because `α = p/q`, the quantity `u = M − α·D = t0` for any true
|
|
24
|
+
pick, *independent of location*. Origin time is therefore estimated location-free
|
|
25
|
+
(a weighted mean), and the hypocenter follows from distance trilateration
|
|
26
|
+
`r ≈ β·D`. This breaks the usual depth/origin-time tradeoff and makes full 3-D
|
|
27
|
+
`(x, y, z)` location tractable.
|
|
28
|
+
|
|
29
|
+
The one structural change to a textbook GMM: each component's mean is **not** a
|
|
30
|
+
free parameter but the Wadati forward prediction `μ_nk = (t0_k + p·r_nk,
|
|
31
|
+
q·r_nk)` of event `k`'s `(t0, x, y, z)` at station `n`. Everything else
|
|
32
|
+
(responsibilities, covariance, DP weights, Wishart prior) is standard.
|
|
33
|
+
See [`formulation.md`](formulation.md) for the full derivation.
|
|
34
|
+
|
|
35
|
+
## Layout
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
src/wadati/_gaussian_mixture.py vendored sklearn GaussianMixture, edited
|
|
39
|
+
src/wadati/_bayesian_mixture.py vendored sklearn BayesianGaussianMixture, edited
|
|
40
|
+
src/wadati/_base.py vendored sklearn EM/VB loop (unchanged)
|
|
41
|
+
src/wadati/forward.py velocity model, predict_mean, estimate_t0, locate
|
|
42
|
+
src/wadati/windowing.py t0 pre-clustering into time windows
|
|
43
|
+
synthetic.py 3-case 3D catalog generator (+ ~20% false picks)
|
|
44
|
+
pipeline.py window -> BGMM -> post-hoc filter -> metrics
|
|
45
|
+
plots.py Wadati M-D, map, depth section, timeline
|
|
46
|
+
formulation.md derivation
|
|
47
|
+
mixture/ pristine sklearn 1.9.0 sources (diff reference)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The mixture models are vendored from scikit-learn 1.9.0 and committed unmodified
|
|
51
|
+
first, so `git log -p src/wadati/_gaussian_mixture.py` shows exactly the
|
|
52
|
+
algorithm change against upstream.
|
|
53
|
+
|
|
54
|
+
## Run
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
PYTHONPATH=src python3 synthetic.py # print the synthetic catalog
|
|
58
|
+
PYTHONPATH=src python3 plots.py # figures/catalog_overview.png (truth)
|
|
59
|
+
PYTHONPATH=src python3 -m wadati.windowing # show the t0 windows
|
|
60
|
+
PYTHONPATH=src python3 pipeline.py # end-to-end metrics + figures/results_overview.png
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Requires `numpy`, `scipy`, `scikit-learn` (1.9.x), `matplotlib`.
|
|
64
|
+
|
|
65
|
+
## Three test cases
|
|
66
|
+
|
|
67
|
+
The synthetic catalog merges, with absolute time offsets, three configurations
|
|
68
|
+
that stress different parts of the problem:
|
|
69
|
+
|
|
70
|
+
| Case | Setup | What it tests |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| 1 | same `t0`, different locations | spatial separation (M, D carry only distance, so association is pure trilateration) |
|
|
73
|
+
| 2 | same location, different `t0` | temporal separation via `u = M − αD` |
|
|
74
|
+
| 3 | both close (~3 s, ~5 km) | the hardest case (still identifiable) |
|
|
75
|
+
|
|
76
|
+
## Initialization
|
|
77
|
+
|
|
78
|
+
Two strategies, selected by the sklearn-style `init_params` (they differ only in
|
|
79
|
+
whether the init also fixes the source parameters; both feed the same EM/VB loop):
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
BayesianGaussianMixture(init_params="smallest_d", n_init=1, ...) # deterministic (default)
|
|
83
|
+
BayesianGaussianMixture(init_params="kmeans", n_init=20, ...) # random, restart-selected
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The default, `"smallest_d"`, seeds components deterministically from **candidate
|
|
87
|
+
event locations**, not from picks. Within each t0 group, picks are scanned in
|
|
88
|
+
order of increasing `D`
|
|
89
|
+
(= q·distance): a small `D` means the station is near the source, so its
|
|
90
|
+
location is the best epicenter proxy. The smallest-`D` picks (spatially
|
|
91
|
+
de-duplicated so several same-t0 events each get a seed) become the initial
|
|
92
|
+
events `(t0 = group mean of u, location = that station)`, and these are used
|
|
93
|
+
**directly** as the starting hypocenters; the first trilateration runs in the
|
|
94
|
+
first M-step. No randomness is involved, so `n_init = 1` suffices.
|
|
95
|
+
|
|
96
|
+
A controlled comparison (6 random catalogs, 20% false picks) shows why this is
|
|
97
|
+
the right default:
|
|
98
|
+
|
|
99
|
+
| initialization | `n_init=1` | `n_init=20` |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| k-means on (t0, station x, y) | ~0.8 (seed-dependent) | 0.95 |
|
|
102
|
+
| smallest-D candidate locations (deterministic) | **0.91** (reproducible) | 0.91 (restarts are no-ops) |
|
|
103
|
+
|
|
104
|
+
No single initialization exceeds ~0.91: the likelihood is multimodal and the
|
|
105
|
+
jump to ~0.95 comes from restart *selection by ELBO*, not from init quality.
|
|
106
|
+
The deterministic init matches the best single shot while being reproducible and
|
|
107
|
+
restart-free.
|
|
108
|
+
|
|
109
|
+
## Results
|
|
110
|
+
|
|
111
|
+
Across 6 random catalogs (8 events, ~20% false picks), deterministic
|
|
112
|
+
`n_init = 1`: mean association ARI ≈ **0.91**, median origin-time error ≈ 0.16 s,
|
|
113
|
+
epicenter ≈ 0.6 km, depth ≈ 1.8 km, no spurious events. Case 1 (same t0,
|
|
114
|
+
different location) and Case 2 (different t0, same location) recover cleanly with
|
|
115
|
+
the Dirichlet process pruning the event count automatically.
|
|
116
|
+
|
|
117
|
+
Case 3 (close in both, ~3 s and ~5 km) is the hardest but **identifiable**:
|
|
118
|
+
exhaustive enumeration of all partitions confirms the true labeling is the
|
|
119
|
+
maximum-likelihood one (gap = 0, under both free and fixed covariance). The
|
|
120
|
+
remaining pipeline misses on Case 3 are EM local optima, not fundamental
|
|
121
|
+
ambiguity, and randomized restarts (`n_init = 20`) raise the mean ARI to ≈ 0.95.
|
|
122
|
+
(Pushing the separation down to ~2 s crosses an identifiability threshold: two
|
|
123
|
+
events that close produce too few, too noisy picks to distinguish, and the ML
|
|
124
|
+
partition then overfits the source parameters to noise — the true labeling is no
|
|
125
|
+
longer the maximum-likelihood one.)
|
|
126
|
+
|
|
127
|
+
## Phase weights
|
|
128
|
+
|
|
129
|
+
Each pick carries a quality weight `w_n ∈ [0,1]` (e.g. a picker's confidence).
|
|
130
|
+
Following GaMMA, the weight enters the **likelihood** (`log P += log w_n` in the
|
|
131
|
+
E-step), not the M-step. Added to every component, it cancels in the
|
|
132
|
+
responsibility normalization, so it **never changes the geometric fit** — it
|
|
133
|
+
only lowers a poor pick's marginal score. This is the right choice for an
|
|
134
|
+
*uncalibrated* ML confidence: putting `w` on `P` (a constant offset) is immune to
|
|
135
|
+
its absolute scale, whereas putting `w` on `log P` (observation-weighting) would
|
|
136
|
+
shrink effective counts and make the Dirichlet process prune real events. The
|
|
137
|
+
pipeline consumes the quality signal post-hoc: a pick is kept only if
|
|
138
|
+
`max_k γ_nk · w_n ≥ min_resp` (fit confidence × quality) and its Mahalanobis
|
|
139
|
+
residual is small, and each event is relocated from its kept picks weighted by
|
|
140
|
+
`w_n`.
|
|
141
|
+
|
|
142
|
+
False picks are otherwise handled post-hoc: drop picks that fail the gate above,
|
|
143
|
+
then refit each event's hypocenter from its own kept picks. Because depth is well
|
|
144
|
+
constrained by the Wadati distance `r = β·D` (each pick fixes the source-station
|
|
145
|
+
distance), depth errors trace to association mistakes, not to depth being
|
|
146
|
+
unresolvable. A dedicated uniform noise component in the mixture (GaMMA's dummy
|
|
147
|
+
component, the principled home for `w` as `P(real)` once calibrated) is left for
|
|
148
|
+
future work.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/gamma_wadati.egg-info/PKG-INFO
|
|
4
|
+
src/gamma_wadati.egg-info/SOURCES.txt
|
|
5
|
+
src/gamma_wadati.egg-info/dependency_links.txt
|
|
6
|
+
src/gamma_wadati.egg-info/requires.txt
|
|
7
|
+
src/gamma_wadati.egg-info/top_level.txt
|
|
8
|
+
src/wadati/__init__.py
|
|
9
|
+
src/wadati/_base.py
|
|
10
|
+
src/wadati/_bayesian_mixture.py
|
|
11
|
+
src/wadati/_gaussian_mixture.py
|
|
12
|
+
src/wadati/forward.py
|
|
13
|
+
src/wadati/pairing.py
|
|
14
|
+
src/wadati/windowing.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wadati
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Wadati (M, D) mixture models for joint phase association and 3D location.
|
|
2
|
+
|
|
3
|
+
Vendored from scikit-learn 1.9.0 ``sklearn.mixture`` and modified so each
|
|
4
|
+
mixture component's mean is the Wadati forward prediction of an event's
|
|
5
|
+
``(t0, x, y, z)`` at each station, rather than a free parameter.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from ._bayesian_mixture import BayesianGaussianMixture
|
|
9
|
+
from ._gaussian_mixture import GaussianMixture
|
|
10
|
+
|
|
11
|
+
__all__ = ["GaussianMixture", "BayesianGaussianMixture"]
|