Skip to content

Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)

Preserve competing ridge paths as unresolved joint hypotheses

Cinna Davisc60ec5e7c8d0
diff --git a/scripts/benchmark_real_clock_batch.py b/scripts/benchmark_real_clock_batch.py
index 3a772f4..bd9f4f3 100644
--- a/scripts/benchmark_real_clock_batch.py
+++ b/scripts/benchmark_real_clock_batch.py
@@ -50,7 +50,7 @@ def main():
result = score_candidate(candidates[index], point, tracks, events, measurements, mode="robust_ridge")
score = result["score"]
rows.append({"candidate_index": index, "group_count": len(candidates[index]["event_indices"]),
- "score": float(score) if math.isfinite(score) else None,
+ "score": float(score) if score is not None and math.isfinite(score) else None,
"recording_start_time_s": result.get("recording_start_time_s"),
"scoring_assessment": result["scoring_assessment"]})
return rows
diff --git a/src/dopplergeist/confidence.py b/src/dopplergeist/confidence.py
index 0583c11..b3ec4f8 100644
--- a/src/dopplergeist/confidence.py
+++ b/src/dopplergeist/confidence.py
@@ -44,33 +44,21 @@ def _near_tied(gap, margin):
def _possible_harmonic_overlap(events):
"""Flag an uncalibrated ambiguity; do not merge ridges or assert identity."""
from .discovery import _HARMONIC_RATIOS
+ from .ridge_overlap import aligned_ridge_observations, reused_ridge_observations
for index, first in enumerate(events):
for second in events[index + 1:]:
- if first.get("harmonic_group_id", first["event_id"]) == second.get("harmonic_group_id", second["event_id"]):
+ aligned = aligned_ridge_observations(first, second)
+ if aligned is None:
continue
- low, high = first, second
- a = {point["time_s"]: point["frequency_hz"] for point in low["ridge"]}
- b = {point["time_s"]: point["frequency_hz"] for point in high["ridge"]}
- times = sorted(a.keys() & b.keys())
- if len(times) < 10:
- continue
- span = min(low["ridge"][-1]["time_s"] - low["ridge"][0]["time_s"],
- high["ridge"][-1]["time_s"] - high["ridge"][0]["time_s"])
- if span <= 0 or times[-1] - times[0] < 0.6 * span:
- continue
- x, y = (np.array([ridge[t] for t in times], dtype=float) for ridge in (a, b))
# Chunk paths can follow the same measured peak before branching.
# A reused sequence is not independent evidence, even when the
# later divergence fails the whole-ridge harmonic check below.
- shared = x == y
- starts = np.flatnonzero(np.convolve(shared, np.ones(5, dtype=int), mode="valid") == 5)
- if len(starts):
- start = int(starts[0])
- return {"event_ids": [low["event_id"], high["event_id"]],
- "ambiguity": "reused_ridge_observations", "harmonic_ratio": 1.0,
- "aligned_samples": len(times), "shared_ridge_samples": int(shared.sum()),
- "shared_run_start_s": times[start], "shared_run_end_s": times[start + 4]}
+ reused = reused_ridge_observations(first, second, aligned=aligned)
+ if reused is not None:
+ return reused
+ low, high = first, second
+ times, x, y = aligned
if np.median(x) > np.median(y):
low, high, x, y = high, low, y, x
with np.errstate(over="ignore", invalid="ignore", divide="ignore"):
diff --git a/src/dopplergeist/matching.py b/src/dopplergeist/matching.py
index 246c02e..d6e9dec 100644
--- a/src/dopplergeist/matching.py
+++ b/src/dopplergeist/matching.py
@@ -457,10 +457,13 @@ def prepare_events(detected_events, c=343.0, max_distance_m=20000.0):
Keep every ridge in a harmonic group as evidence for one pass. Rational
harmonic ratios are normalized to its lowest observed band; no fundamental
needs to be present. Groups with inconsistent ratios must be fixed by discovery.
+ Separate paths that reuse measured peaks remain separate hypotheses, with
+ an explicit conflict preventing their joint independent-support score.
Timing uncertainty spans the observed window, because a curved track need
not have its geometric CPA at a fitted straight-pass center.
"""
from .discovery import _HARMONIC_RATIOS, _overlap
+ from .ridge_overlap import reused_ridge_observations
groups = {}
for event in detected_events:
@@ -510,6 +513,16 @@ def prepare_events(detected_events, c=343.0, max_distance_m=20000.0):
event["event_ids"] = [e["event_id"] for e in members]
settings.append(event)
measurements.append((RidgeTimes(t), f, w, {}))
+ grouped = list(groups.items())
+ for index, (first_id, first_members) in enumerate(grouped):
+ for following in range(index + 1, len(grouped)):
+ second_id, second_members = grouped[following]
+ conflict = next((found for first in first_members for second in second_members
+ if (found := reused_ridge_observations(first, second)) is not None), None)
+ if conflict is not None:
+ conflict = dict(conflict, group_ids=[first_id, second_id])
+ for setting in (settings[index], settings[following]):
+ setting.setdefault("shared_ridge_observations", []).append(conflict)
order = np.argsort([e["cpa_receive_s"] for e in settings])
return [settings[i] for i in order], [measurements[i] for i in order]
diff --git a/src/dopplergeist/pipeline.py b/src/dopplergeist/pipeline.py
index c723436..1700e9c 100644
--- a/src/dopplergeist/pipeline.py
+++ b/src/dopplergeist/pipeline.py
@@ -53,7 +53,7 @@ def score_block(candidates,lookup,track_lookup,events,measurements,parameters,or
else:
unreported+=1
known=parameters["mode"]=="robust_ridge" and classified_assessment(row)
- finite=bool(np.isfinite(row["score"]))
+ finite=bool(row["score"] is not None and np.isfinite(row["score"]))
pass_times=[float(p["emission_time"]) for p in candidate["passes"]]
if not known:
anchor=(origin if origin is not None else
@@ -70,7 +70,8 @@ def score_block(candidates,lookup,track_lookup,events,measurements,parameters,or
"event_indices":list(candidate.get("event_indices",range(len(events)))),
"pass_emission_times_s":pass_times,"recording_start_domain_s":[float(lo),float(hi)],
"clock_domain_kind":"scorer_proposal_not_independent_recording_time",
- "clock_settings":parameters,"scoring_assessment":assessment,"failure":failure,
+ "clock_settings":parameters,"score_kind":row.get("score_kind"),
+ "scoring_assessment":assessment,"failure":failure,
"finite_best":finite,"finite_score":float(row["score"]) if finite else None,
"reason":(failure["reason"] if failure else "unclassified_clock_envelope"),
"coverage_envelope":"whole_candidate_clock_domain_conservative"})
diff --git a/src/dopplergeist/ridge_overlap.py b/src/dopplergeist/ridge_overlap.py
new file mode 100644
index 0000000..0b037d8
--- /dev/null
+++ b/src/dopplergeist/ridge_overlap.py
@@ -0,0 +1,53 @@
+"""Measured ridge reuse, without inferring a shared physical source."""
+import numpy as np
+
+
+def aligned_ridge_observations(first, second):
+ """Use the existing confidence guard's alignment and overlap requirements."""
+ if first.get("harmonic_group_id", first["event_id"]) == second.get("harmonic_group_id", second["event_id"]):
+ return None
+ if (not first["ridge"] or not second["ridge"]
+ or first["ridge"][-1]["time_s"] < second["ridge"][0]["time_s"]
+ or second["ridge"][-1]["time_s"] < first["ridge"][0]["time_s"]):
+ return None
+ a = {point["time_s"]: point["frequency_hz"] for point in first["ridge"]}
+ b = {point["time_s"]: point["frequency_hz"] for point in second["ridge"]}
+ times = sorted(a.keys() & b.keys())
+ if len(times) < 10:
+ return None
+ span = min(first["ridge"][-1]["time_s"] - first["ridge"][0]["time_s"],
+ second["ridge"][-1]["time_s"] - second["ridge"][0]["time_s"])
+ if span <= 0 or times[-1] - times[0] < 0.6 * span:
+ return None
+ x, y = (np.array([ridge[t] for t in times], dtype=float) for ridge in (a, b))
+ return times, x, y
+
+
+def reused_ridge_observations(first, second, *, aligned=None):
+ """Identify five reused aligned peaks; retain both diverging path hypotheses."""
+ aligned = aligned_ridge_observations(first, second) if aligned is None else aligned
+ if aligned is None:
+ return None
+ times, x, y = aligned
+ shared = x == y
+ starts = np.flatnonzero(np.convolve(shared, np.ones(5, dtype=int), mode="valid") == 5)
+ if not len(starts):
+ return None
+ start = int(starts[0])
+ return {"event_ids": [first["event_id"], second["event_id"]],
+ "ambiguity": "reused_ridge_observations", "harmonic_ratio": 1.0,
+ "aligned_samples": len(times), "shared_ridge_samples": int(shared.sum()),
+ "shared_run_start_s": times[start], "shared_run_end_s": times[start + 4]}
+
+
+def selected_ridge_conflicts(events):
+ """Return prepared conflicts only when both affected groups are selected."""
+ selected = {event.get("harmonic_group_id") or event.get("event_id") for event in events}
+ conflicts, seen = [], set()
+ for event in events:
+ for conflict in event.get("shared_ridge_observations", ()):
+ groups = tuple(conflict["group_ids"])
+ if groups not in seen and set(groups).issubset(selected):
+ conflicts.append(conflict)
+ seen.add(groups)
+ return conflicts
diff --git a/src/dopplergeist/search.py b/src/dopplergeist/search.py
index f68307a..60cd1a5 100644
--- a/src/dopplergeist/search.py
+++ b/src/dopplergeist/search.py
@@ -798,6 +798,8 @@ def score_candidate(candidate, point, tracks, events, measurements, mode="bright
raise ValueError(f"Unknown scoring mode: {mode}")
if time_step_s <= 0 or time_sweep_s < 0:
raise ValueError("Need positive clock step and nonnegative sweep")
+ from .ridge_overlap import selected_ridge_conflicts
+ shared_observations = selected_ridge_conflicts(events) if association else []
if score_floor is not None:
if not association or mode != "robust_ridge":
raise ValueError("score_floor is only supported for robust_ridge associations")
@@ -810,6 +812,8 @@ def score_candidate(candidate, point, tracks, events, measurements, mode="bright
if not np.isfinite(score_floor):
raise ValueError("score_floor must be finite")
_validate_score_ceiling_inputs(events, measurements)
+ elif shared_observations:
+ _validate_score_ceiling_inputs(events, measurements)
observer = _candidate_observer(point.lat,point.lon,point.elev_m)
# Derive one recording start from the first event; all other events retain
# their true absolute geometry/time. This implements the locked offset.
@@ -852,15 +856,23 @@ def score_candidate(candidate, point, tracks, events, measurements, mode="bright
partial_prunes = 0
# Every accepted group contributes at most one; a strict comparison keeps ties eligible.
floor_pruned = bool(score_floor is not None and len(shifts) > 0 and len(events) < score_floor)
- if floor_pruned:
+ unresolved_overlap = bool(shared_observations and len(shifts) > 0)
+ skip_fits = floor_pruned or unresolved_overlap
+ if skip_fits:
best["score"] = None
assessment["unknown_trials"] = len(shifts)
+ if floor_pruned:
reasons.add("matched_group_count_below_score_floor")
+ if unresolved_overlap:
+ # Keep the joint assignment as an unresolved envelope, not a rejected
+ # physical source combination. Its group count is only an upper bound.
+ reasons.add("reused_ridge_observations")
+ assessment["shared_ridge_observations"] = shared_observations
selected_tracks = ([tracks[p["flight_id"]] for p in candidate["passes"]]
- if mode == "robust_ridge" and not floor_pruned else None)
+ if mode == "robust_ridge" and not skip_fits else None)
batches = None
lazy_batches = None
- if mode == "robust_ridge" and not floor_pruned and len(shifts) > 1:
+ if mode == "robust_ridge" and not skip_fits and len(shifts) > 1:
from .matching import _iter_acoustic_trials, batch_acoustic_trials
if association and score_floor is not None:
lazy_batches = iter(_iter_acoustic_trials(selected_tracks, measurements, observer, anchor + shifts, c))
@@ -874,7 +886,7 @@ def score_candidate(candidate, point, tracks, events, measurements, mode="bright
batched_trials = None
# Bound the retained per-clock diagnostics; large products keep the scalar
# traversal rather than allocating an unbounded event-by-clock table.
- if (mode == "robust_ridge" and not floor_pruned and batches is not None
+ if (mode == "robust_ridge" and not skip_fits and batches is not None
and len(shifts) >= 4 and len(shifts) * len(events) <= 4096):
batched_trials, dual_pruned, floor_dual_pruned = _batched_ridge_trials(
selected_tracks, events, measurements, observer, anchor + shifts, c,
@@ -882,7 +894,7 @@ def score_candidate(candidate, point, tracks, events, measurements, mode="bright
score_floor if association else None,
association and score_floor is not None and time_origin is None,
legacy_first_batch and association and score_floor is not None and time_origin is None)
- for trial, shift in enumerate(() if floor_pruned else shifts):
+ for trial, shift in enumerate(() if skip_fits else shifts):
if mode == "robust_ridge":
from .matching import score_ridges
def acoustic_at(index):
@@ -1005,7 +1017,7 @@ def score_candidate(candidate, point, tracks, events, measurements, mode="bright
assessment["complete"] = bool(len(shifts) and assessment["unknown_trials"] == 0)
assessment["reasons"] = sorted(reasons)
if association and assessment["unknown_trials"]:
- if floor_pruned:
+ if skip_fits:
assessment.update(
bounded_unknown_trials=len(shifts),
bounded_unknown_rejections=0,
@@ -1032,12 +1044,13 @@ def score_candidate(candidate, point, tracks, events, measurements, mode="bright
def rank_candidates(candidates, points, tracks, events, measurements, **kwargs):
+ """Return finite rankings; ``pipeline.score_block`` also retains unknown work."""
lookup = {row.point_id:row for row in points.itertuples()}
track_lookup = {track.id:track for track in tracks}
result = []
for i,candidate in enumerate(candidates):
row = score_candidate(candidate,lookup[candidate["point_id"]],track_lookup,events,measurements,**kwargs)
- if np.isfinite(row["score"]):
+ if row["score"] is not None and np.isfinite(row["score"]):
result.append(row)
if i and i%100==0:
print(f"Scored {i}/{len(candidates)} candidates",flush=True)
diff --git a/src/dopplergeist/tiled_search.py b/src/dopplergeist/tiled_search.py
index a14e73c..a031421 100644
--- a/src/dopplergeist/tiled_search.py
+++ b/src/dopplergeist/tiled_search.py
@@ -769,7 +769,9 @@ def _score(points, tracks, events, measurements, budget, parameters, filters, st
row["core_assessment_complete"] = bool(known and finite_score)
if settings.get("mode") == "robust_ridge":
assessment = row.get("scoring_assessment")
- if isinstance(assessment, dict) and assessment.get("unknown_score_bound_method") == "group_count_ceiling":
+ if (isinstance(assessment, dict)
+ and assessment.get("unknown_score_bound_method") == "group_count_ceiling"
+ and "matched_group_count_below_score_floor" in assessment.get("reasons", ())):
assessment["retention_score_floor"] = settings["score_floor"]
if isinstance(assessment, dict) and all(type(assessment.get(k)) is int and assessment[k] >= 0
for k in ("evaluated_trials", "rejected_trials", "unknown_trials")):
diff --git a/tests/data/shared-ridges-real.json b/tests/data/shared-ridges-real.json
new file mode 100644
index 0000000..da2806c
--- /dev/null
+++ b/tests/data/shared-ridges-real.json
@@ -0,0 +1,1085 @@
+{
+ "description": "Unmodified automatically measured ridge points from two public recordings; no generated audio, tracks, source-identity labels, or location result.",
+ "shared": {
+ "record_url": "https://zenodo.org/records/22049202",
+ "member": "ESID_103_2024_04_08/20240408_042453.WAV",
+ "duration_s": 600,
+ "pcm_prefix_sha256": "335285b7123e838ce4d363ba62d0c22bf9e0778af0b5673bc1fe2cd02819bfc2",
+ "encoded_mp3_sha256": "de334b5659326765bcd584924fdd3b0832f1eb7c999fa7afa518b4f4f55e4ef1",
+ "events": [
+ {
+ "event_id": "event-0001",
+ "harmonic_group_id": "harmonics-0001",
+ "start_s": 366.5,
+ "end_s": 399.0,
+ "band_hz": [
+ 523.693366214633,
+ 575.25
+ ],
+ "ridge": [
+ {
+ "time_s": 367.5,
+ "frequency_hz": 573.8695598989725,
+ "weight": 3.19755220413208
+ },
+ {
+ "time_s": 368.0,
+ "frequency_hz": 574.25,
+ "weight": 2.9163994789123535
+ },
+ {
+ "time_s": 368.5,
+ "frequency_hz": 570.3869589716196,
+ "weight": 3.413175106048584
+ },
+ {
+ "time_s": 369.0,
+ "frequency_hz": 569.5035489725415,
+ "weight": 4.037382125854492
+ },
+ {
+ "time_s": 369.5,
+ "frequency_hz": 569.1565427929163,
+ "weight": 3.9304556846618652
+ },
+ {
+ "time_s": 370.0,
+ "frequency_hz": 565.4629346989095,
+ "weight": 2.9632115364074707
+ },
+ {
+ "time_s": 371.0,
+ "frequency_hz": 561.1279443651438,
+ "weight": 4.042417049407959
+ },
+ {
+ "time_s": 371.5,
+ "frequency_hz": 561.2875696122646,
+ "weight": 5.503195285797119
+ },
+ {
+ "time_s": 372.0,
+ "frequency_hz": 561.357295140624,
+ "weight": 5.497149467468262
+ },
+ {
+ "time_s": 372.5,
+ "frequency_hz": 561.2454952299595,
+ "weight": 3.3446545600891113
+ },
+ {
+ "time_s": 373.0,
+ "frequency_hz": 559.1620463132858,
+ "weight": 2.836742639541626
+ },
+ {
+ "time_s": 373.5,
+ "frequency_hz": 552.1938848793507,
+ "weight": 2.710132360458374
+ },
+ {
+ "time_s": 374.0,
+ "frequency_hz": 553.9583169259131,
+ "weight": 4.747042179107666
+ },
+ {
+ "time_s": 374.5,
+ "frequency_hz": 553.4949822244234,
+ "weight": 4.683799743652344
+ },
+ {
+ "time_s": 375.0,
+ "frequency_hz": 551.845979988575,
+ "weight": 3.892108678817749
+ },
+ {
+ "time_s": 376.0,
+ "frequency_hz": 547.897981338203,
+ "weight": 3.006371259689331
+ },
+ {
+ "time_s": 377.0,
+ "frequency_hz": 554.1356706023216,
+ "weight": 2.5401060581207275
+ },
+ {
+ "time_s": 377.5,
+ "frequency_hz": 542.1798942238092,
+ "weight": 5.437748908996582
+ },
+ {
+ "time_s": 378.0,
+ "frequency_hz": 541.75,
+ "weight": 4.328770160675049
+ },
+ {
+ "time_s": 378.5,
+ "frequency_hz": 539.0933360606432,
+ "weight": 4.3718438148498535
+ },
+ {
+ "time_s": 379.0,
+ "frequency_hz": 537.609312042594,
+ "weight": 4.95092248916626
+ },
+ {
+ "time_s": 379.5,
+ "frequency_hz": 537.7734264433384,
+ "weight": 5.354640007019043
+ },
+ {
+ "time_s": 380.0,
+ "frequency_hz": 535.6162846460938,
+ "weight": 4.176200866699219
+ },
+ {
+ "time_s": 380.5,
+ "frequency_hz": 533.9568816646934,
+ "weight": 2.9937069416046143
+ },
+ {
+ "time_s": 381.0,
+ "frequency_hz": 533.3874558806419,
+ "weight": 3.4164235591888428
+ },
+ {
+ "time_s": 382.5,
+ "frequency_hz": 529.659164711833,
+ "weight": 3.362767219543457
+ },
+ {
+ "time_s": 383.0,
+ "frequency_hz": 529.7086267918348,
+ "weight": 3.1239516735076904
+ },
+ {
+ "time_s": 383.5,
+ "frequency_hz": 527.399056121707,
+ "weight": 3.3442904949188232
+ },
+ {
+ "time_s": 384.0,
+ "frequency_hz": 527.6101171523333,
+ "weight": 3.6853928565979004
+ },
+ {
+ "time_s": 384.5,
+ "frequency_hz": 527.280642837286,
+ "weight": 2.692741632461548
+ },
+ {
+ "time_s": 385.0,
+ "frequency_hz": 526.637164503336,
+ "weight": 2.5793650150299072
+ },
+ {
+ "time_s": 385.5,
+ "frequency_hz": 527.1681976169348,
+ "weight": 3.8150339126586914
+ },
+ {
+ "time_s": 386.0,
+ "frequency_hz": 527.4303819090128,
+ "weight": 3.7829031944274902
+ },
+ {
+ "time_s": 386.5,
+ "frequency_hz": 526.0948485657573,
+ "weight": 4.592789173126221
+ },
+ {
+ "time_s": 387.0,
+ "frequency_hz": 526.3347639143467,
+ "weight": 4.839073181152344
+ },
+ {
+ "time_s": 387.5,
+ "frequency_hz": 526.5608817599714,
+ "weight": 5.138721942901611
+ },
+ {
+ "time_s": 388.0,
+ "frequency_hz": 526.25,
+ "weight": 4.352392196655273
+ },
+ {
+ "time_s": 388.5,
+ "frequency_hz": 526.0487699955702,
+ "weight": 4.136519908905029
+ },
+ {
+ "time_s": 389.0,
+ "frequency_hz": 525.9698592498899,
+ "weight": 4.588303089141846
+ },
+ {
+ "time_s": 389.5,
+ "frequency_hz": 525.7984145581722,
+ "weight": 4.311871528625488
+ },
+ {
+ "time_s": 390.0,
+ "frequency_hz": 525.5332070216537,
+ "weight": 3.2710678577423096
+ },
+ {
+ "time_s": 390.5,
+ "frequency_hz": 525.9882189342752,
+ "weight": 3.9210643768310547
+ },
+ {
+ "time_s": 391.0,
+ "frequency_hz": 525.5038622170687,
+ "weight": 4.417089462280273
+ },
+ {
+ "time_s": 391.5,
+ "frequency_hz": 525.7015700042248,
+ "weight": 4.166598320007324
+ },
+ {
+ "time_s": 392.0,
+ "frequency_hz": 526.0502943098545,
+ "weight": 3.6364212036132812
+ },
+ {
+ "time_s": 392.5,
+ "frequency_hz": 524.8308641761541,
+ "weight": 2.896082878112793
+ },
+ {
+ "time_s": 393.0,
+ "frequency_hz": 525.2772241532803,
+ "weight": 2.5874271392822266
+ },
+ {
+ "time_s": 394.5,
+ "frequency_hz": 525.085006646812,
+ "weight": 4.399479389190674
+ },
+ {
+ "time_s": 395.0,
+ "frequency_hz": 525.1403749138117,
+ "weight": 4.743109226226807
+ },
+ {
+ "time_s": 395.5,
+ "frequency_hz": 525.3386499285698,
+ "weight": 3.407412528991699
+ },
+ {
+ "time_s": 396.0,
+ "frequency_hz": 525.4207236170769,
+ "weight": 3.2594940662384033
+ },
+ {
+ "time_s": 396.5,
+ "frequency_hz": 525.0837434008718,
+ "weight": 3.9576668739318848
+ },
+ {
+ "time_s": 397.0,
+ "frequency_hz": 524.797749593854,
+ "weight": 3.3457484245300293
+ },
+ {
+ "time_s": 397.5,
+ "frequency_hz": 524.8621115088463,
+ "weight": 3.129293203353882
+ },
+ {
+ "time_s": 398.0,
+ "frequency_hz": 524.693366214633,
+ "weight": 2.6091721057891846
+ }
+ ],
+ "quality": {
+ "median_contrast": 3.8150339126586914,
+ "harmonic_count": 1.0,
+ "support_fraction": 0.8870967741935484,
+ "frequency_resolution_hz": 0.5,
+ "time_uncertainty_s": 1.0,
+ "frequency_uncertainty_hz": 0.5,
+ "frequency_sigma_hz": 0.5,
+ "fragment_count": 1.0,
+ "max_observed_gap_s": 1.5,
+ "frequency_drop_hz": 44.071536146104336
+ }
+ },
+ {
+ "event_id": "event-0002",
+ "harmonic_group_id": "harmonics-0002",
+ "start_s": 366.5,
+ "end_s": 386.0,
+ "band_hz": [
+ 517.4943016623147,
+ 575.25
+ ],
+ "ridge": [
+ {
+ "time_s": 367.5,
+ "frequency_hz": 573.8695598989725,
+ "weight": 3.1312100887298584
+ },
+ {
+ "time_s": 368.0,
+ "frequency_hz": 574.25,
+ "weight": 2.855314016342163
+ },
+ {
+ "time_s": 368.5,
+ "frequency_hz": 570.3869589716196,
+ "weight": 3.521364688873291
+ },
+ {
+ "time_s": 369.0,
+ "frequency_hz": 569.5035489725415,
+ "weight": 4.077876091003418
+ },
+ {
+ "time_s": 369.5,
+ "frequency_hz": 569.1565427929163,
+ "weight": 3.9235153198242188
+ },
+ {
+ "time_s": 370.0,
+ "frequency_hz": 567.9380365423858,
+ "weight": 2.901430606842041
+ },
+ {
+ "time_s": 371.0,
+ "frequency_hz": 561.25,
+ "weight": 4.006040573120117
+ },
+ {
+ "time_s": 371.5,
+ "frequency_hz": 561.2875696122646,
+ "weight": 5.763403415679932
+ },
+ {
+ "time_s": 372.0,
+ "frequency_hz": 561.357295140624,
+ "weight": 5.624876022338867
+ },
+ {
+ "time_s": 372.5,
+ "frequency_hz": 557.6544747650623,
+ "weight": 4.0487751960754395
+ },
+ {
+ "time_s": 373.0,
+ "frequency_hz": 556.6314864009619,
+ "weight": 5.5460638999938965
+ },
+ {
+ "time_s": 373.5,
+ "frequency_hz": 556.25,
+ "weight": 5.886833190917969
+ },
+ {
+ "time_s": 374.0,
+ "frequency_hz": 556.0523391440511,
+ "weight": 4.400569438934326
+ },
+ {
+ "time_s": 374.5,
+ "frequency_hz": 550.6700807064772,
+ "weight": 3.708721399307251
+ },
+ {
+ "time_s": 375.0,
+ "frequency_hz": 547.8962408304214,
+ "weight": 2.9537484645843506
+ },
+ {
+ "time_s": 375.5,
+ "frequency_hz": 547.8747989833355,
+ "weight": 3.3279128074645996
+ },
+ {
+ "time_s": 376.0,
+ "frequency_hz": 547.897981338203,
+ "weight": 2.9037928581237793
+ },
+ {
+ "time_s": 376.5,
+ "frequency_hz": 544.8951529040933,
+ "weight": 3.6312143802642822
+ },
+ {
+ "time_s": 377.0,
+ "frequency_hz": 542.75,
+ "weight": 5.115782737731934
+ },
+ {
+ "time_s": 377.5,
+ "frequency_hz": 538.213239133358,
+ "weight": 2.744410514831543
+ },
+ {
+ "time_s": 378.0,
+ "frequency_hz": 538.5515288822353,
+ "weight": 3.915562152862549
+ },
+ {
+ "time_s": 378.5,
+ "frequency_hz": 531.9739138893783,
+ "weight": 2.9098567962646484
+ },
+ {
+ "time_s": 379.0,
+ "frequency_hz": 531.8517414778471,
+ "weight": 3.136296272277832
+ },
+ {
+ "time_s": 379.5,
+ "frequency_hz": 531.5911381244659,
+ "weight": 2.6410913467407227
+ },
+ {
+ "time_s": 380.0,
+ "frequency_hz": 526.4565728195012,
+ "weight": 3.2265586853027344
+ },
+ {
+ "time_s": 380.5,
+ "frequency_hz": 526.2177772670984,
+ "weight": 2.9780094623565674
+ },
+ {
+ "time_s": 382.0,
+ "frequency_hz": 522.436737626791,
+ "weight": 3.0746562480926514
+ },
+ {
+ "time_s": 384.0,
+ "frequency_hz": 518.6665146499872,
+ "weight": 3.448841094970703
+ },
+ {
+ "time_s": 384.5,
+ "frequency_hz": 518.5089625604451,
+ "weight": 4.210793495178223
+ },
+ {
+ "time_s": 385.0,
+ "frequency_hz": 518.4943016623147,
+ "weight": 3.681314706802368
+ }
+ ],
+ "quality": {
+ "median_contrast": 3.5762895345687866,
+ "harmonic_count": 1.0,
+ "support_fraction": 0.8333333333333334,
+ "frequency_resolution_hz": 0.5,
+ "time_uncertainty_s": 1.0,
+ "frequency_uncertainty_hz": 0.5,
+ "frequency_sigma_hz": 0.5,
+ "fragment_count": 1.0,
+ "max_observed_gap_s": 2.0,
+ "frequency_drop_hz": 51.720444321632385
+ }
+ }
+ ]
+ },
+ "separate": {
+ "record_url": "https://zenodo.org/records/10215080",
+ "case_id": "case-0003",
+ "source_sha256": "f2ca127e7c42eee8fb2f1224d9bfff351234f3521bd2b6f7f00785ff32996e58",
+ "events": [
+ {
+ "event_id": "event-0001",
+ "harmonic_group_id": "harmonics-0001",
+ "start_s": 10.5,
+ "end_s": 46.5,
+ "band_hz": [
+ 435.66845604777336,
+ 719.25
+ ],
+ "ridge": [
+ {
+ "time_s": 11.5,
+ "frequency_hz": 715.25,
+ "weight": 2.805093765258789
+ },
+ {
+ "time_s": 12.0,
+ "frequency_hz": 715.2802539616823,
+ "weight": 3.224445104598999
+ },
+ {
+ "time_s": 12.5,
+ "frequency_hz": 717.3038807809353,
+ "weight": 4.088992595672607
+ },
+ {
+ "time_s": 13.0,
+ "frequency_hz": 718.25,
+ "weight": 5.055695533752441
+ },
+ {
+ "time_s": 14.0,
+ "frequency_hz": 713.75,
+ "weight": 3.0533604621887207
+ },
+ {
+ "time_s": 14.5,
+ "frequency_hz": 715.75,
+ "weight": 5.298171520233154
+ },
+ {
+ "time_s": 15.0,
+ "frequency_hz": 715.5918631479144,
+ "weight": 5.089746952056885
+ },
+ {
+ "time_s": 15.5,
+ "frequency_hz": 713.5081031629816,
+ "weight": 4.204810619354248
+ },
+ {
+ "time_s": 16.0,
+ "frequency_hz": 714.25,
+ "weight": 4.058296203613281
+ },
+ {
+ "time_s": 16.5,
+ "frequency_hz": 714.25,
+ "weight": 3.5901477336883545
+ },
+ {
+ "time_s": 17.0,
+ "frequency_hz": 713.2512512803078,
+ "weight": 3.532680034637451
+ },
+ {
+ "time_s": 17.5,
+ "frequency_hz": 712.7494602054358,
+ "weight": 4.649007797241211
+ },
+ {
+ "time_s": 18.0,
+ "frequency_hz": 712.0847365930676,
+ "weight": 4.518145561218262
+ },
+ {
+ "time_s": 18.5,
+ "frequency_hz": 711.2910028249025,
+ "weight": 4.730865955352783
+ },
+ {
+ "time_s": 19.0,
+ "frequency_hz": 711.3510178476572,
+ "weight": 4.008627414703369
+ },
+ {
+ "time_s": 19.5,
+ "frequency_hz": 710.9802486561239,
+ "weight": 3.0725667476654053
+ },
+ {
+ "time_s": 20.5,
+ "frequency_hz": 710.75,
+ "weight": 4.682070255279541
+ },
+ {
+ "time_s": 21.0,
+ "frequency_hz": 708.8124684393406,
+ "weight": 3.7035458087921143
+ },
+ {
+ "time_s": 21.5,
+ "frequency_hz": 708.6855521500111,
+ "weight": 2.757188558578491
+ },
+ {
+ "time_s": 22.0,
+ "frequency_hz": 702.25,
+ "weight": 3.9965853691101074
+ },
+ {
+ "time_s": 22.5,
+ "frequency_hz": 701.8880538269877,
+ "weight": 4.104248046875
+ },
+ {
+ "time_s": 23.0,
+ "frequency_hz": 700.7206058502197,
+ "weight": 2.7735002040863037
+ },
+ {
+ "time_s": 23.5,
+ "frequency_hz": 698.4650193415582,
+ "weight": 3.6448569297790527
+ },
+ {
+ "time_s": 24.0,
+ "frequency_hz": 686.6959584802389,
+ "weight": 2.709970474243164
+ },
+ {
+ "time_s": 25.0,
+ "frequency_hz": 680.3582171201706,
+ "weight": 4.001631736755371
+ },
+ {
+ "time_s": 25.5,
+ "frequency_hz": 679.1252930611372,
+ "weight": 4.4132866859436035
+ },
+ {
+ "time_s": 26.0,
+ "frequency_hz": 671.6121786236763,
+ "weight": 3.902252435684204
+ },
+ {
+ "time_s": 26.5,
+ "frequency_hz": 665.25,
+ "weight": 2.9277615547180176
+ },
+ {
+ "time_s": 27.0,
+ "frequency_hz": 651.0775987803936,
+ "weight": 2.6014244556427
+ },
+ {
+ "time_s": 28.0,
+ "frequency_hz": 637.9227045997977,
+ "weight": 3.0084447860717773
+ },
+ {
+ "time_s": 28.5,
+ "frequency_hz": 636.7281924188137,
+ "weight": 3.2735795974731445
+ },
+ {
+ "time_s": 29.5,
+ "frequency_hz": 618.25,
+ "weight": 3.1128783226013184
+ },
+ {
+ "time_s": 30.5,
+ "frequency_hz": 596.2207586020231,
+ "weight": 3.842377185821533
+ },
+ {
+ "time_s": 31.0,
+ "frequency_hz": 595.4427677243948,
+ "weight": 3.2858755588531494
+ },
+ {
+ "time_s": 31.5,
+ "frequency_hz": 585.0536048449576,
+ "weight": 3.453684091567993
+ },
+ {
+ "time_s": 32.0,
+ "frequency_hz": 570.446357049048,
+ "weight": 4.297070503234863
+ },
+ {
+ "time_s": 32.5,
+ "frequency_hz": 563.5812568739057,
+ "weight": 3.567354917526245
+ },
+ {
+ "time_s": 33.0,
+ "frequency_hz": 548.3907737061381,
+ "weight": 4.2396440505981445
+ },
+ {
+ "time_s": 33.5,
+ "frequency_hz": 542.289545699954,
+ "weight": 4.003174304962158
+ },
+ {
+ "time_s": 34.5,
+ "frequency_hz": 521.1941121816635,
+ "weight": 2.6281957626342773
+ },
+ {
+ "time_s": 35.0,
+ "frequency_hz": 515.7975024580956,
+ "weight": 3.2939839363098145
+ },
+ {
+ "time_s": 35.5,
+ "frequency_hz": 509.78081128001213,
+ "weight": 3.425121545791626
+ },
+ {
+ "time_s": 36.0,
+ "frequency_hz": 499.2621378749609,
+ "weight": 2.545124053955078
+ },
+ {
+ "time_s": 36.5,
+ "frequency_hz": 500.58140493929386,
+ "weight": 3.2234890460968018
+ },
+ {
+ "time_s": 37.0,
+ "frequency_hz": 493.4812288489193,
+ "weight": 2.926659345626831
+ },
+ {
+ "time_s": 38.5,
+ "frequency_hz": 481.35894656181335,
+ "weight": 2.9261624813079834
+ },
+ {
+ "time_s": 39.0,
+ "frequency_hz": 481.25,
+ "weight": 3.5970299243927
+ },
+ {
+ "time_s": 39.5,
+ "frequency_hz": 476.17702117562294,
+ "weight": 3.455491065979004
+ },
+ {
+ "time_s": 41.0,
+ "frequency_hz": 470.7271149158478,
+ "weight": 3.603393077850342
+ },
+ {
+ "time_s": 41.5,
+ "frequency_hz": 466.25,
+ "weight": 4.177645206451416
+ },
+ {
+ "time_s": 42.0,
+ "frequency_hz": 463.30614836513996,
+ "weight": 4.698094367980957
+ },
+ {
+ "time_s": 44.0,
+ "frequency_hz": 452.9666261561215,
+ "weight": 2.5462067127227783
+ },
+ {
+ "time_s": 45.5,
+ "frequency_hz": 436.66845604777336,
+ "weight": 2.5624372959136963
+ }
+ ],
+ "quality": {
+ "median_contrast": 3.5901477336883545,
+ "harmonic_count": 1.0,
+ "support_fraction": 0.7681159420289855,
+ "frequency_resolution_hz": 0.5,
+ "time_uncertainty_s": 1.0,
+ "frequency_uncertainty_hz": 0.5,
+ "frequency_sigma_hz": 0.5,
+ "fragment_count": 1.0,
+ "max_observed_gap_s": 2.0,
+ "frequency_drop_hz": 246.94750109687448
+ }
+ },
+ {
+ "event_id": "event-0002",
+ "harmonic_group_id": "harmonics-0002",
+ "start_s": 25.5,
+ "end_s": 60.0,
+ "band_hz": [
+ 393.68301367759705,
+ 594.1720801889896
+ ],
+ "ridge": [
+ {
+ "time_s": 26.5,
+ "frequency_hz": 593.1720801889896,
+ "weight": 4.168932914733887
+ },
+ {
+ "time_s": 27.0,
+ "frequency_hz": 592.75,
+ "weight": 3.912858724594116
+ },
+ {
+ "time_s": 27.5,
+ "frequency_hz": 591.8039998412132,
+ "weight": 3.348376750946045
+ },
+ {
+ "time_s": 28.0,
+ "frequency_hz": 583.7051185667515,
+ "weight": 2.6717329025268555
+ },
+ {
+ "time_s": 29.0,
+ "frequency_hz": 552.1623083353043,
+ "weight": 2.8745603561401367
+ },
+ {
+ "time_s": 29.5,
+ "frequency_hz": 546.5246412660927,
+ "weight": 4.330907821655273
+ },
+ {
+ "time_s": 30.0,
+ "frequency_hz": 538.75,
+ "weight": 3.9219441413879395
+ },
+ {
+ "time_s": 31.0,
+ "frequency_hz": 518.3985987305641,
+ "weight": 2.655508518218994
+ },
+ {
+ "time_s": 31.5,
+ "frequency_hz": 518.1317258030176,
+ "weight": 3.484376907348633
+ },
+ {
+ "time_s": 32.0,
+ "frequency_hz": 509.75,
+ "weight": 3.1691460609436035
+ },
+ {
+ "time_s": 32.5,
+ "frequency_hz": 500.22364078462124,
+ "weight": 2.683000087738037
+ },
+ {
+ "time_s": 33.0,
+ "frequency_hz": 495.77541299164295,
+ "weight": 2.813016414642334
+ },
+ {
+ "time_s": 34.0,
+ "frequency_hz": 476.96612019091845,
+ "weight": 3.6796715259552
+ },
+ {
+ "time_s": 34.5,
+ "frequency_hz": 472.70760211348534,
+ "weight": 3.764531135559082
+ },
+ {
+ "time_s": 35.0,
+ "frequency_hz": 468.25,
+ "weight": 3.541823387145996
+ },
+ {
+ "time_s": 35.5,
+ "frequency_hz": 465.48907536361367,
+ "weight": 3.59065842628479
+ },
+ {
+ "time_s": 36.0,
+ "frequency_hz": 460.9820355530828,
+ "weight": 2.779951810836792
+ },
+ {
+ "time_s": 36.5,
+ "frequency_hz": 455.9615464583039,
+ "weight": 3.2316722869873047
+ },
+ {
+ "time_s": 37.0,
+ "frequency_hz": 446.1151273548603,
+ "weight": 3.0679850578308105
+ },
+ {
+ "time_s": 37.5,
+ "frequency_hz": 443.08438294380903,
+ "weight": 2.971104383468628
+ },
+ {
+ "time_s": 38.0,
+ "frequency_hz": 439.69243381917477,
+ "weight": 2.602883815765381
+ },
+ {
+ "time_s": 38.5,
+ "frequency_hz": 437.4258002117276,
+ "weight": 3.2660462856292725
+ },
+ {
+ "time_s": 39.0,
+ "frequency_hz": 431.25,
+ "weight": 4.024897575378418
+ },
+ {
+ "time_s": 40.0,
+ "frequency_hz": 421.25,
+ "weight": 4.004462718963623
+ },
+ {
+ "time_s": 41.5,
+ "frequency_hz": 416.61671897768974,
+ "weight": 3.2214787006378174
+ },
+ {
+ "time_s": 43.5,
+ "frequency_hz": 409.75,
+ "weight": 2.8097124099731445
+ },
+ {
+ "time_s": 44.0,
+ "frequency_hz": 407.4996698886971,
+ "weight": 3.15995717048645
+ },
+ {
+ "time_s": 44.5,
+ "frequency_hz": 405.92195349931717,
+ "weight": 2.5890378952026367
+ },
+ {
+ "time_s": 45.0,
+ "frequency_hz": 405.3848185837269,
+ "weight": 2.8463172912597656
+ },
+ {
+ "time_s": 45.5,
+ "frequency_hz": 405.1035668104887,
+ "weight": 3.048689365386963
+ },
+ {
+ "time_s": 46.0,
+ "frequency_hz": 402.25,
+ "weight": 2.907545566558838
+ },
+ {
+ "time_s": 46.5,
+ "frequency_hz": 401.6940159201622,
+ "weight": 3.2377243041992188
+ },
+ {
+ "time_s": 47.0,
+ "frequency_hz": 401.30477000772953,
+ "weight": 3.852837324142456
+ },
+ {
+ "time_s": 47.5,
+ "frequency_hz": 400.9018023982644,
+ "weight": 3.6381688117980957
+ },
+ {
+ "time_s": 48.0,
+ "frequency_hz": 400.2503845244646,
+ "weight": 3.3018906116485596
+ },
+ {
+ "time_s": 48.5,
+ "frequency_hz": 398.89771235734224,
+ "weight": 4.0222296714782715
+ },
+ {
+ "time_s": 49.0,
+ "frequency_hz": 398.55748746171594,
+ "weight": 4.504557132720947
+ },
+ {
+ "time_s": 49.5,
+ "frequency_hz": 398.06144336238503,
+ "weight": 4.677244663238525
+ },
+ {
+ "time_s": 50.0,
+ "frequency_hz": 398.3069985806942,
+ "weight": 5.103837013244629
+ },
+ {
+ "time_s": 50.5,
+ "frequency_hz": 398.47023408301175,
+ "weight": 4.554528713226318
+ },
+ {
+ "time_s": 51.0,
+ "frequency_hz": 397.98948150407523,
+ "weight": 4.589947700500488
+ },
+ {
+ "time_s": 51.5,
+ "frequency_hz": 397.0948938205838,
+ "weight": 4.228206157684326
+ },
+ {
+ "time_s": 52.0,
+ "frequency_hz": 396.61898279190063,
+ "weight": 4.66852331161499
+ },
+ {
+ "time_s": 52.5,
+ "frequency_hz": 396.75,
+ "weight": 4.709985256195068
+ },
+ {
+ "time_s": 53.0,
+ "frequency_hz": 397.0128589756787,
+ "weight": 4.811178207397461
+ },
+ {
+ "time_s": 53.5,
+ "frequency_hz": 396.7659675478935,
+ "weight": 4.027394771575928
+ },
+ {
+ "time_s": 54.0,
+ "frequency_hz": 396.6937734335661,
+ "weight": 4.1609320640563965
+ },
+ {
+ "time_s": 54.5,
+ "frequency_hz": 396.82163093984127,
+ "weight": 4.279726982116699
+ },
+ {
+ "time_s": 55.0,
+ "frequency_hz": 397.2937656342983,
+ "weight": 3.256065845489502
+ },
+ {
+ "time_s": 55.5,
+ "frequency_hz": 396.8591630458832,
+ "weight": 3.26320743560791
+ },
+ {
+ "time_s": 56.0,
+ "frequency_hz": 396.5937148183584,
+ "weight": 3.876438856124878
+ },
+ {
+ "time_s": 56.5,
+ "frequency_hz": 396.4161336272955,
+ "weight": 3.491753578186035
+ },
+ {
+ "time_s": 57.0,
+ "frequency_hz": 395.84639570116997,
+ "weight": 3.8782787322998047
+ },
+ {
+ "time_s": 57.5,
+ "frequency_hz": 395.75845266878605,
+ "weight": 3.9171626567840576
+ },
+ {
+ "time_s": 58.5,
+ "frequency_hz": 394.68301367759705,
+ "weight": 3.4371230602264404
+ },
+ {
+ "time_s": 59.0,
+ "frequency_hz": 394.68505677580833,
+ "weight": 3.7735347747802734
+ }
+ ],
+ "quality": {
+ "median_contrast": 3.566240906715393,
+ "harmonic_count": 1.0,
+ "support_fraction": 0.8484848484848485,
+ "frequency_resolution_hz": 0.5,
+ "time_uncertainty_s": 1.0,
+ "frequency_uncertainty_hz": 0.5,
+ "frequency_sigma_hz": 0.5,
+ "fragment_count": 1.0,
+ "max_observed_gap_s": 2.0,
+ "frequency_drop_hz": 155.74617470800877
+ }
+ }
+ ]
+ }
+}
diff --git a/tests/test_real_shared_ridge_scoring.py b/tests/test_real_shared_ridge_scoring.py
new file mode 100644
index 0000000..f9de1d9
--- /dev/null
+++ b/tests/test_real_shared_ridge_scoring.py
@@ -0,0 +1,221 @@
+"""Keep recorded competing paths without counting reused peaks independently."""
+import copy
+import importlib.util
+import json
+import os
+from pathlib import Path
+from types import SimpleNamespace
+
+import numpy as np
+import pandas as pd
+import pytest
+
+from dopplergeist.confidence import _possible_harmonic_overlap
+from dopplergeist.contracts import validate_event
+from dopplergeist import pipeline, tiled_search
+from dopplergeist.data_access import FlightIndex, content_hash
+from dopplergeist.finite_search import RetentionLedger, bounded_assessment, classified_assessment
+from dopplergeist.matching import association_candidates, prepare_events
+from dopplergeist.ridge_overlap import selected_ridge_conflicts
+from dopplergeist.search import rank_candidates, score_candidate
+
+
+DATA = Path(__file__).parent / "data"
+
+
+def recorded_events(kind):
+ fixture = json.loads((DATA / "shared-ridges-real.json").read_text())
+ return [validate_event(event) for event in fixture[kind]["events"]]
+
+
[email protected](scope="module")
+def http_verifier():
+ spec = importlib.util.spec_from_file_location("verify_upload_http_shared_ridges",
+ DATA.parents[1] / "scripts/verify_upload_http.py")
+ verifier = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(verifier)
+ return verifier
+
+
+def joint_hypothesis(events):
+ # These archived ADS-B passages and receiver are only association/scorer
+ # wiring inputs. They are NOT the date, location or aircraft of ESID103.
+ # The conflict check must run before consulting or fitting any trajectory.
+ table = json.loads((DATA / "reference-cpa-real.json").read_text())["cpa_rows"]
+ candidates, _ = association_candidates(pd.DataFrame(table), events)
+ candidate = next(row for row in candidates if len(row["event_indices"]) == 2)
+ position = json.loads((DATA / "reference-retention-real.json").read_text())["rows"][0]["mode_seed"]["position"]
+ point = SimpleNamespace(point_id=candidate["point_id"],
+ **dict(zip(("x", "y", "lat", "lon", "elev_m"), position)))
+ return candidate, point
+
+
+def test_real_shared_paths_keep_every_observation_and_each_separate_hypothesis():
+ raw = recorded_events("shared")
+ original = copy.deepcopy(raw)
+ events, measurements = prepare_events(raw)
+ assert raw == original and len(events) == 2
+ assert {event["harmonic_group_id"] for event in events} == {event["harmonic_group_id"] for event in raw}
+ conflicts = selected_ridge_conflicts(events)
+ assert len(conflicts) == 1
+ flag = _possible_harmonic_overlap(raw)
+ assert {key: value for key, value in conflicts[0].items() if key != "group_ids"} == flag
+ assert flag["shared_ridge_samples"] == 8
+ assert (flag["shared_run_start_s"], flag["shared_run_end_s"]) == (367.5, 369.5)
+ for event, measurement in zip(events, measurements):
+ single, observed = prepare_events([next(item for item in raw if item["event_id"] == event["event_id"])])
+ assert selected_ridge_conflicts([event]) == []
+ assert {key: value for key, value in event.items() if key != "shared_ridge_observations"} == single[0]
+ for first, second in zip((measurement[0].time, *measurement[1:3]),
+ (observed[0][0].time, *observed[0][1:3])):
+ np.testing.assert_array_equal(first, second)
+
+
[email protected]("floor", [None, 0.0])
+def test_real_joint_subset_is_unknown_before_any_trajectory_access(floor):
+ events, measurements = prepare_events(recorded_events("shared"))
+ candidate, point = joint_hypothesis(events)
+ # An empty lookup makes any attempted trajectory access fail this check.
+ row = score_candidate(candidate, point, {}, events, measurements,
+ mode="robust_ridge", score_floor=floor)
+ assessment = row["scoring_assessment"]
+ assert row["score"] is None and not classified_assessment(row)
+ assert bounded_assessment(row)
+ assert assessment["reasons"] == ["reused_ridge_observations"]
+ assert assessment["scheduled_trials"] == assessment["unknown_trials"] > 0
+ assert assessment["evaluated_trials"] == assessment["rejected_trials"] == 0
+ assert assessment["unknown_score_upper_bound"] == 2.0
+ assert "retention_score_floor" not in assessment
+ assert assessment["shared_ridge_observations"] == selected_ridge_conflicts(events)
+
+
+def test_real_unknown_overlap_preserves_invalid_model_parameter_errors():
+ events, measurements = prepare_events(recorded_events("shared"))
+ candidate, point = joint_hypothesis(events)
+ events[0]["quality"]["source_drift_fraction"] = 0.2
+ with pytest.raises(ValueError, match="drift fraction"):
+ score_candidate(candidate, point, {}, events, measurements, mode="robust_ridge")
+
+
+def test_public_ranking_callers_preserve_real_unknown_overlap_accounting(tmp_path, http_verifier):
+ events, measurements = prepare_events(recorded_events("shared"))
+ candidate, point = joint_hypothesis(events)
+ parameters = {"mode": "robust_ridge", "time_sweep_s": 0}
+ scored = score_candidate(candidate, point, {}, events, measurements, **parameters)
+ assert rank_candidates([candidate], pd.DataFrame([vars(point)]), [], events, measurements,
+ **parameters) == []
+ ranked, unknown, reported, unreported = pipeline.score_block([candidate], {point.point_id: point}, {},
+ events, measurements, parameters, None)
+ assert ranked == [] and len(unknown) == 1 and unreported == 0
+ envelope = unknown[0]
+ assert envelope["scoring_assessment"] == scored["scoring_assessment"]
+ assert envelope["score_kind"] == scored["score_kind"]
+ assert not envelope["finite_best"] and envelope["finite_score"] is None
+ assert reported == {"evaluated_trials": 0, "rejected_trials": 0,
+ "unknown_trials": scored["scoring_assessment"]["scheduled_trials"]}
+ assert envelope["recording_start_domain_s"] == candidate["recording_start_bounds_s"]
+ path = tmp_path / "unknown.json"
+ pipeline.dump(path, unknown)
+ persisted = json.loads(path.read_text())
+ assert persisted == unknown
+ assert http_verifier.bounded_finite_clock_assessment(persisted[0], 2)
+ assert bounded_assessment(persisted[0]) and not classified_assessment(persisted[0])
+
+
+def test_real_overlap_bound_survives_ledger_and_independent_verifier(tmp_path, http_verifier):
+ events, measurements = prepare_events(recorded_events("shared"))
+ candidate, point = joint_hypothesis(events)
+ row = score_candidate(candidate, point, {}, events, measurements, mode="robust_ridge")
+ detail = dict(row, finite_best=False,
+ pass_emission_times_s=[entry["emission_time"] for entry in candidate["passes"]],
+ recording_start_bounds_s=candidate["recording_start_bounds_s"])
+ bound = {"bound_id": "bound-" + content_hash(detail), "detail": detail,
+ "groups_count": 2, "upper_score": 2.0}
+ ledger = RetentionLedger(tmp_path / "retention.sqlite", "real-shared-ridge-regression", row["score_kind"])
+ checksum = ledger.record("coarse:shared-paths", [], [], 0, bounds=[bound])
+ assert ledger.stage_valid("coarse:shared-paths", checksum)
+ with ledger.connect() as database:
+ persisted = json.loads(database.execute("SELECT detail FROM bounds").fetchone()[0])
+ assert persisted == detail and bounded_assessment(persisted)
+ evidence = ledger.evidence([], complete=True, spacing_m=2000, refine_spacing_m=100, max_event_groups=2)
+ assert evidence["evaluated_modes"] == 0
+ assert evidence["bounded_unknown_envelopes"] == evidence["discarded_count"] == 1
+ assert evidence["best_unknown_score_upper_bound"] == evidence["best_discarded_score"] == 2.0
+ assert evidence["bounded_unknown_rejections"] == 0
+
+ assert http_verifier.bounded_finite_clock_assessment(persisted, 2)
+ # Unknown observation ownership cannot become a fully assessed fit through
+ # serialization, even though its conservative bound is accounted for.
+ assert not classified_assessment(persisted)
+
+
+def test_real_separate_groups_are_not_marked_as_reusing_observations():
+ raw = recorded_events("separate")
+ events, _ = prepare_events(raw)
+ assert len(events) == 2 and _possible_harmonic_overlap(raw) is None
+ assert selected_ridge_conflicts(events) == []
+ assert all("shared_ridge_observations" not in event for event in events)
+
+
[email protected](scope="module")
+def real_flight_hypotheses():
+ source = os.environ.get("DOPPLERGEIST_REAL_CPA_FIXTURE")
+ if not source:
+ pytest.skip("set DOPPLERGEIST_REAL_CPA_FIXTURE to an archived real CPA/index fixture")
+ fixture = json.loads(Path(source).read_text())
+ events, measurements = prepare_events(recorded_events("shared"))
+ candidates, _ = association_candidates(pd.DataFrame(fixture["cpa_rows"]), events,
+ max_candidates=20000)
+ joint = next(row for row in candidates if len(row["event_indices"]) == 2)
+ singletons = [row for index in range(2)
+ for row in [item for item in candidates if item["event_indices"] == [index]][:3]]
+ identifiers = {entry["flight_id"] for row in [joint, *singletons] for entry in row["passes"]}
+ tracks = {track.id: track for track in FlightIndex(fixture["real_index"]).lookup(sorted(identifiers))}
+ assert set(tracks) == identifiers
+ # These real trajectories are deliberately unrelated hypotheses, with no
+ # claim that they recorded ESID103's date, receiver location or aircraft.
+ return events, measurements, fixture["point"], tracks, joint, singletons
+
+
+def test_real_single_path_scores_ignore_an_unselected_conflicting_path(real_flight_hypotheses):
+ events, measurements, position, tracks, _, candidates = real_flight_hypotheses
+ point = SimpleNamespace(**position)
+ unmarked = [{key: value for key, value in event.items() if key != "shared_ridge_observations"}
+ for event in events]
+ assert {tuple(row["event_indices"]) for row in candidates} == {(0,), (1,)}
+ for candidate in candidates:
+ marked = score_candidate(candidate, point, tracks, events, measurements,
+ mode="robust_ridge", time_sweep_s=0)
+ original = score_candidate(candidate, point, tracks, unmarked, measurements,
+ mode="robust_ridge", time_sweep_s=0)
+ assert json.dumps(marked, sort_keys=True) == json.dumps(original, sort_keys=True)
+
+
+def test_real_tiled_search_keeps_conflicts_separate_from_retention_pruning(real_flight_hypotheses, tmp_path, http_verifier):
+ events, measurements, position, tracks, joint, _ = real_flight_hypotheses
+ selected = [tracks[identifier] for identifier in dict.fromkeys(entry["flight_id"] for entry in joint["passes"])]
+ ledger = RetentionLedger(tmp_path / "retention.sqlite", "real-shared-path-tile",
+ "matched_group_support_minus_normalized_residual")
+ rows, counts = tiled_search._score(pd.DataFrame([position]), selected, events, measurements,
+ tiled_search.SearchBudget(top_k=100), {"mode": "robust_ridge", "time_sweep_s": 0},
+ {"association": "subsets"}, ledger=ledger, stage="coarse:shared-paths")
+ details = counts["unclassified_candidate_assessments"]
+ conflicts = [detail for detail in details
+ if "reused_ridge_observations" in detail["scoring_assessment"]["reasons"]]
+ assert conflicts and all(len(row["event_indices"]) == 1 for row in rows)
+ for detail in conflicts:
+ assessment = detail["scoring_assessment"]
+ assert not detail["finite_best"] and bounded_assessment(detail)
+ assert assessment["unknown_trials"] == assessment["scheduled_trials"] > 0
+ assert assessment["unknown_score_upper_bound"] == 2.0
+ assert "retention_score_floor" not in assessment
+ assert counts["retention_score_pruned_candidates"] == sum(
+ "retention_score_floor" in detail["scoring_assessment"] for detail in details if bounded_assessment(detail))
+ with ledger.connect() as database:
+ persisted = [json.loads(row[0]) for row in database.execute("SELECT detail FROM bounds")]
+ assert len(persisted) == counts["bounded_score_candidates"]
+ assert all(detail in persisted for detail in conflicts)
+ assert all(http_verifier.bounded_finite_clock_assessment(detail, 2) for detail in persisted)
+ evidence = ledger.evidence(rows, complete=True, spacing_m=2000, refine_spacing_m=100, max_event_groups=2)
+ assert evidence["bounded_unknown_envelopes"] == len(persisted)
+ assert evidence["best_unknown_score_upper_bound"] == 2.0