#!/usr/bin/env python3 """Debug script to find duplicate target times in forecast data.""" from gibil.classes.env_loader import EnvLoader from gibil.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}")