phasenet 0.2.6.dev2__tar.gz → 0.2.6.dev3__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.
- {phasenet-0.2.6.dev2/phasenet.egg-info → phasenet-0.2.6.dev3}/PKG-INFO +1 -1
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/utils/inference.py +8 -1
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3/phasenet.egg-info}/PKG-INFO +1 -1
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/pyproject.toml +1 -1
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/predict_mseed.py +2 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/tests/test_models.py +14 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/.github/workflows/publish.yml +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/.gitignore +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/README.md +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/docs/notebooks/lab2a_phasenet_das_inference.ipynb +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/docs/notebooks/lab2b_pick_association.ipynb +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/docs/notebooks/lab2c_semisupervised_training.ipynb +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/examples/ceed_training_plots.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/examples/italy/prepare_inventory.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/examples/italy/prepare_mseed_list.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/examples/italy/run_all_years.sh +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/examples/italy/upload_loop.sh +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/examples/italy/upload_phasenet_origin.sh +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/__init__.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/data/README.md +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/data/__init__.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/data/ceed.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/data/das.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/data/plot_ceed.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/data/plot_das.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/data/preprocess.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/data/sample.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/data/tables.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/data/transforms.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/models/README.md +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/models/__init__.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/models/phasenet.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/models/prompt/__init__.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/models/prompt/common.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/models/prompt/mask_decoder.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/models/prompt/prompt_encoder.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/models/prompt/transformer.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/models/unet.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/models/unet2018.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/normalize.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/utils/__init__.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/utils/detect_peaks_cpu.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/utils/postprocess.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet/utils/visualization.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet.egg-info/SOURCES.txt +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet.egg-info/dependency_links.txt +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet.egg-info/entry_points.txt +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet.egg-info/requires.txt +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/phasenet.egg-info/top_level.txt +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/requirements.txt +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/aug_verify.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/augmentation_gallery.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/das_catalog_events.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/plot_normalization.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/predict_ceed.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/predict_ceed.sh +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/predict_das.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/predict_das.sh +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/semisupervised_das.sh +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/train_ceed.sh +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/train_das.sh +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/scripts/upgrade_checkpoint.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/setup.cfg +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/tests/benchmark_dataloader.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/tests/test_augmentations.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/tests/test_labels.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/tests/test_normalize.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/tests/test_recipes.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/tests/test_transforms.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/train.py +0 -0
- {phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/utils.py +0 -0
|
@@ -85,7 +85,8 @@ def predict_2d(model: torch.nn.Module,
|
|
|
85
85
|
max_batch_size: Max patches per forward pass (memory safety valve).
|
|
86
86
|
|
|
87
87
|
Returns:
|
|
88
|
-
Phase scores of shape (3, nx, nt) — [noise, P, S]
|
|
88
|
+
Phase scores of shape (3, nx, nt) — [noise, P, S]; with a polarity head (4, nx, nt), the fourth row the
|
|
89
|
+
probability that the first motion is up.
|
|
89
90
|
If model outputs event_center/event_time, returns
|
|
90
91
|
(scores, event_center, event_time) at their native resolution.
|
|
91
92
|
"""
|
|
@@ -167,6 +168,10 @@ def predict_2d(model: torch.nn.Module,
|
|
|
167
168
|
with torch.autocast(device_type=dev.type, dtype=torch.bfloat16, enabled=bf16):
|
|
168
169
|
out = model({"data": batch})
|
|
169
170
|
probs = torch.softmax(out["phase"].float(), dim=1)
|
|
171
|
+
if "polarity" in out: # P(up), carried as a fourth row through the same overlap-discard
|
|
172
|
+
probs = torch.cat([probs, torch.sigmoid(out["polarity"].float())], dim=1)
|
|
173
|
+
if scores_sum.shape[0] != probs.shape[1]:
|
|
174
|
+
scores_sum = torch.zeros(probs.shape[1], nx, nt, dtype=torch.float32, device=acc_device)
|
|
170
175
|
if not use_gpu:
|
|
171
176
|
probs = probs.cpu()
|
|
172
177
|
|
|
@@ -328,6 +333,8 @@ def detect_picks(scores: np.ndarray,
|
|
|
328
333
|
"phase_score": round(prob, 4),
|
|
329
334
|
"phase_type": phase,
|
|
330
335
|
"dt_s": dt_s,
|
|
336
|
+
**({"phase_polarity": round(scores[3, ch_idx, tidx].item(), 4)}
|
|
337
|
+
if phase == "P" and scores.shape[0] > 3 else {}), # P(up) at the P pick
|
|
331
338
|
})
|
|
332
339
|
|
|
333
340
|
return picks
|
|
@@ -242,6 +242,8 @@ def run_inference(model, waveform, velocity, station_id, begin_iso, dt,
|
|
|
242
242
|
waveform_3d = waveform[:, np.newaxis, :] # (3, 1, nt)
|
|
243
243
|
# whole trace or overlapping windows: predict_2d follows model.input
|
|
244
244
|
scores = predict_2d(model, waveform_3d, device=DEVICE, max_batch_size=batch_size)
|
|
245
|
+
if isinstance(scores, tuple): # a model with event heads also returns its event detections
|
|
246
|
+
scores = scores[0]
|
|
245
247
|
|
|
246
248
|
picks = detect_picks(
|
|
247
249
|
scores,
|
|
@@ -31,6 +31,20 @@ def test_window_nx_1():
|
|
|
31
31
|
assert np.abs(single - patches).max() < 1e-5
|
|
32
32
|
|
|
33
33
|
|
|
34
|
+
def test_polarity_at_picks():
|
|
35
|
+
"""a polarity model's scores carry P(up) as a fourth row, equal to the head's sigmoid, and its P picks carry it"""
|
|
36
|
+
from phasenet.utils.inference import detect_picks
|
|
37
|
+
torch.manual_seed(0)
|
|
38
|
+
m = phasenet.models.build_model("phasenet_plus", input=replace(SPEC, window_nx=1, window_nt=None).asdict()).eval()
|
|
39
|
+
x = np.random.default_rng(0).standard_normal((3, 2, 2048)).astype(np.float32)
|
|
40
|
+
scores = predict_2d(m, x, max_batch_size=8)[0]
|
|
41
|
+
with torch.no_grad():
|
|
42
|
+
up = torch.sigmoid(m({"data": m.normalizer(torch.from_numpy(x)[None])})["polarity"])[0, 0].numpy()
|
|
43
|
+
assert scores.shape == (4, 2, 2048) and np.abs(scores[3] - up).max() < 1e-5
|
|
44
|
+
picks = detect_picks(scores, ["a", "b"], {}, None, vmin=0.0)
|
|
45
|
+
assert all(("phase_polarity" in p) == (p["phase_type"] == "P") for p in picks) and picks
|
|
46
|
+
|
|
47
|
+
|
|
34
48
|
def test_time_downsample():
|
|
35
49
|
"""every family declares the length multiple a whole trace is padded to, and a trace of any length comes back
|
|
36
50
|
scored at its own length (a strided stage added without updating time_downsample breaks this)"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/docs/notebooks/lab2a_phasenet_das_inference.ipynb
RENAMED
|
File without changes
|
|
File without changes
|
{phasenet-0.2.6.dev2 → phasenet-0.2.6.dev3}/docs/notebooks/lab2c_semisupervised_training.ipynb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|