Files
astrape-oracle/astrape_oracle/scripts/debug/debug_duplicates.py
T
rpotter6298 ccd4e7a48c Initial commit: astrape-oracle split out of the combined Astrape tree
The forecasting runtime gibil pilots: weather ingest (Open-Meteo
forecasts and the Ecowitt station), the oracle and weather stores, the
snapshot daemon, the forecast evaluator, and the TCN training
scheduler.

classes/datasets.py holds the shapes the stores return for display.
They sit beside the stores deliberately: a store's return type belongs
to the store, and keeping them with the renderers would mean this repo
importing the dashboard, which is backwards.

Extracted from a single repository where the forecasting engine, the
database plumbing, the hardware client, the ingest daemons and the web
UI all imported each other freely. Verified that every module imports
with gibil resolved from its own installed checkout.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 14:19:04 +02:00

32 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Debug script to find duplicate target times in forecast data."""
from astrape_ems.classes.env import EnvLoader
from astrape_oracle.classes.weather.store import WeatherStore
from collections import defaultdict
EnvLoader().load()
store = WeatherStore.from_env()
dataset = store.load_display_dataset()
# Group by (target_at, horizon_hours) to find duplicates
by_key = defaultdict(list)
for point in dataset.forecast_points:
key = (point.target_at, point.horizon_hours)
by_key[key].append(point)
# Find duplicates
duplicates = {k: v for k, v in by_key.items() if len(v) > 1}
print(f"\nTotal forecast points: {len(dataset.forecast_points)}")
print(f"Unique (target_at, horizon) pairs: {len(by_key)}")
print(f"Duplicate (target_at, horizon) pairs: {len(duplicates)}")
if duplicates:
print("\nFirst 3 duplicates:")
for (target_at, horizon), points in list(duplicates.items())[:3]:
print(f"\n target_at={target_at}, horizon={horizon}h ({len(points)} points):")
for i, p in enumerate(points):
print(f" [{i}] issued_at={p.issued_at}, temp={p.temperature_c}, source={p.source}")