Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Explain weak acoustic fits from retained per-event measurements (#407)
Cinna Davis9d5f717b907a
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 275eb1a..642377d 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -97,6 +97,8 @@ jobs:PY- name: Check metamorphic completion gates against real recorded outcomesrun: python -m pytest -q tests/test_real_metamorphic_runner.py::test_recorded_matrix_keeps_coverage_and_completion_separate_from_timing+ - name: Check weak-fit guidance against recorded real ridge diagnostics+ run: python -m pytest -q tests/test_real_guidance_fit.py- name: CLI smoke checkrun: dopplergeist --help- name: Check installed native validator and packaged browser assetsdiff --git a/docs/INCONCLUSIVE_GUIDANCE.md b/docs/INCONCLUSIVE_GUIDANCE.mdindex 9ac4687..52c8690 100644--- a/docs/INCONCLUSIVE_GUIDANCE.md+++ b/docs/INCONCLUSIVE_GUIDANCE.md@@ -48,6 +48,9 @@ different result was saved.| Missing recording time and required `time_window` | Supply a defensible UTC window for the original recording start. || No discovered events for a missing-time/no-events result | More of the original recording may contain a usable event. || Too few matched acoustic groups | Explain the observed group count; a separate flyover may provide more evidence. |+| Measured track support below the saved decision threshold | Identify the affected acoustic event, its support fraction and the recorded policy threshold. |+| Measured acoustic RMSE or outlier fraction above the saved decision threshold | Identify the affected event, offending measurement and threshold. This is a failed association, not a location estimate. |+| Recorded source-frequency drift at its bound | Identify the affected event and report the bounded fit as unresolved. || Possible harmonic or reused-ridge overlap | Explain that group independence is unestablished; do not assert aircraft identity. || Partial required data or explicit missing identifiers | Restore the identified flight or terrain data. || Unavailable data with a recorded acquisition/configuration limit | Inspect that limit before retrying; unavailability alone does not prove an archive gap. |diff --git a/src/dopplergeist/guidance.py b/src/dopplergeist/guidance.pyindex 63e0109..c163e24 100644--- a/src/dopplergeist/guidance.py+++ b/src/dopplergeist/guidance.py@@ -58,6 +58,52 @@ def guidance(result, decision=None):"If available, try more of the original recording containing a separate flyover. Another usable event is not guaranteed.",["result.json#/reason_code", "decision.json#/diagnostics/independent_event_groups"])+ # Explain measured fit failures only when the saved decision still matches+ # this result and identifies the offending event and policy threshold.+ if reason in {"insufficient_track_support", "inconsistent_event_match", "source_drift_unresolved"}:+ summary = diagnostics.get("candidate_evidence_summary")+ policy = diagnostics.get("policy")+ fits = summary.get("event_fits") if isinstance(summary, dict) else None+ if isinstance(fits, list) and isinstance(policy, dict):+ def measured(value):+ return type(value) in (int, float) and math.isfinite(value)++ for index, fit in enumerate(fits):+ if not isinstance(fit, dict) or not isinstance(fit.get("event_id"), str) or not fit["event_id"]:+ continue+ event_id = fit["event_id"]+ base = f"decision.json#/diagnostics/candidate_evidence_summary/event_fits/{index}"+ refs = ["result.json#/reason_code", base + "/event_id"]++ if reason == "insufficient_track_support":+ actual = fit.get("support_fraction")+ limit = policy.get("min_support_fraction")+ if (measured(actual) and measured(limit) and 0 <= actual < limit <= 1):+ add("track_support", f"Event {event_id} has {actual:.1%} observed trajectory support, below the decision policy's {limit:.1%} minimum.",+ "Inspect the saved track coverage and this event's original audio. Additional historical track data may help, but its availability and benefit are unmeasured.",+ refs + [base + "/support_fraction", "decision.json#/diagnostics/policy/min_support_fraction"])+ break++ elif reason == "inconsistent_event_match":+ rmse, outliers = fit.get("rmse_hz"), fit.get("outlier_fraction")+ rmse_limit, outlier_limit = policy.get("max_event_rmse_hz"), policy.get("max_outlier_fraction")+ if measured(rmse) and measured(rmse_limit) and rmse > rmse_limit >= 0:+ add("acoustic_fit", f"Event {event_id} has a measured fit RMSE of {rmse:.2f} Hz, above the policy limit of {rmse_limit:.2f} Hz.",+ "Inspect the original audio segment and competing flight associations. This failed fit does not establish a location; an improved result has not been measured.",+ refs + [base + "/rmse_hz", "decision.json#/diagnostics/policy/max_event_rmse_hz"])+ break+ if (measured(outliers) and measured(outlier_limit) and 0 <= outlier_limit < outliers <= 1):+ add("acoustic_fit", f"Event {event_id} has a measured outlier fraction of {outliers:.1%}, above the policy limit of {outlier_limit:.1%}.",+ "Inspect the original audio segment and competing flight associations. This failed fit does not establish a location; an improved result has not been measured.",+ refs + [base + "/outlier_fraction", "decision.json#/diagnostics/policy/max_outlier_fraction"])+ break++ elif fit.get("drift_at_bound") is True:+ add("source_drift", f"Event {event_id} reached the allowed source-frequency drift bound in the fitted model.",+ "Inspect the recorded ridge and drift fit before trusting this association. A different model or more audio has not been shown to resolve it.",+ refs + [base + "/drift_at_bound"])+ break+# Coverage and the primary reason can describe different simultaneous limits.# The initial unavailable state, before acquisition, is not an archive gap.missing = coverage.get("missing_data", [])diff --git a/tests/test_real_guidance_fit.py b/tests/test_real_guidance_fit.pynew file mode 100644index 0000000..6a63dff--- /dev/null+++ b/tests/test_real_guidance_fit.py@@ -0,0 +1,67 @@+"""Read-only guidance contract from archived real measured ridge fits, not accuracy evidence."""+from dataclasses import asdict+from datetime import datetime, timezone+import json+from pathlib import Path++from dopplergeist.confidence import DecisionPolicy, _candidate_evidence_summary+from dopplergeist.guidance import guidance+++ROOT = Path(__file__).resolve().parents[1]+++def recorded_case():+ source = json.loads((ROOT / "tests/data/real-refinement-profile.json").read_text())+ original = source["candidate"]+ candidate = {key: original[key] for key in+ ("lat", "lon", "score", "score_kind", "event_ids", "flight_ids")}+ candidate["recording_start_utc"] = datetime.fromtimestamp(+ original["recording_start_time_s"], tz=timezone.utc).isoformat().replace("+00:00", "Z")+ evidence = dict(zip(original["event_ids"], original["event_diagnostics"]))+ summary = _candidate_evidence_summary(source["events"], candidate, evidence)+ return candidate, {"policy": asdict(DecisionPolicy()), "candidate_evidence_summary": summary}+++def check_evidence_pointers(items, diagnostics, reason):+ saved_decision = {"diagnostics": diagnostics}+ saved_result = {"reason_code": reason}+ for item in items:+ for reference in item["evidence"]:+ name, pointer = reference.split("#", 1)+ value = saved_decision if name == "decision.json" else saved_result+ assert name in {"decision.json", "result.json"}+ for token in pointer.lstrip("/").split("/"):+ value = value[int(token)] if isinstance(value, list) else value[token]+ assert value is not None+++def test_real_recorded_bad_fit_and_drift_have_measured_guidance():+ candidate, diagnostics = recorded_case()+ fits = diagnostics["candidate_evidence_summary"]["event_fits"]+ assert fits[0]["rmse_hz"] > diagnostics["policy"]["max_event_rmse_hz"]+ assert fits[0]["drift_at_bound"] is True+ for reason, expected, field in (+ ("inconsistent_event_match", "acoustic_fit", "/rmse_hz"),+ ("source_drift_unresolved", "source_drift", "/drift_at_bound"),+ ):+ result = {"status": "inconclusive", "reason_code": reason, "candidates": [candidate]}+ decision = dict(result, diagnostics=diagnostics)+ items = guidance(result, decision)+ assert len(items) == 1+ assert items[0]["code"] == expected+ assert any(pointer.endswith(field) for pointer in items[0]["evidence"])+ assert items[0]["benefit"] == "unmeasured"+ check_evidence_pointers(items, diagnostics, reason)+ # A decision from an earlier candidate state cannot justify this guidance.+ stale = dict(decision, candidates=[dict(candidate, score=candidate["score"] - 1)])+ assert guidance(result, stale) == []+++def test_recorded_full_track_support_does_not_invent_a_failure():+ candidate, diagnostics = recorded_case()+ assert all(row["support_fraction"] == 1 for row in+ diagnostics["candidate_evidence_summary"]["event_fits"])+ result = {"status": "inconclusive", "reason_code": "insufficient_track_support",+ "candidates": [candidate]}+ assert guidance(result, dict(result, diagnostics=diagnostics)) == []