Skip to content

feat(weather): historical anomaly callouts vs normal (#325)#561

Open
Orinks wants to merge 1 commit intodevfrom
feat/historical-anomaly-325
Open

feat(weather): historical anomaly callouts vs normal (#325)#561
Orinks wants to merge 1 commit intodevfrom
feat/historical-anomaly-325

Conversation

@Orinks
Copy link
Copy Markdown
Owner

@Orinks Orinks commented Mar 31, 2026

Summary

  • Wires the previously-implemented but unused compute_anomaly() function into the weather enrichment pipeline
  • Current temperature is compared against a multi-year historical baseline (Open-Meteo Archive API, ±7-day window, 5 years back)
  • Result shown as a "Historical context" metric in current conditions (e.g. "Currently 5.0°F warmer than the 5-year average for this date.")
  • Gracefully handles insufficient data (returns None → metric not shown), network failures, and test mode

Changes

  • weather_client_base.py: new openmeteo_archive_client lazy property + _enrich_with_anomaly_callout async method + task registration in _launch_enrichment_tasks()
  • tests/test_weather_client_anomaly.py: 11 new tests covering enrichment success/None/missing-temp/exception/task-inclusion logic
  • CHANGELOG.md: user-facing entry under [Unreleased]

Acceptance criteria

  • Temperature anomaly callout shown when sufficient history exists (≥3 years)
  • Handles missing/partial history gracefully (returns None, no metric displayed)
  • No clutter in default view (single optional "Historical context" line, existing UI hook)
  • Unit tests for anomaly calculations (11 new + 22 existing = 33 total anomaly tests)

Closes #325

🤖 Generated with Claude Code

…ine (#325)

- Add `_enrich_with_anomaly_callout` async method that calls the
  existing (but previously unused) `compute_anomaly()` in a thread
  pool executor and stores the result in `WeatherData.anomaly_callout`
- Lazily create a dedicated `OpenMeteoApiClient` for archive queries
  via the new `openmeteo_archive_client` property
- Register the enrichment task in `_launch_enrichment_tasks()`; skipped
  in test mode and when no current temperature is available
- Add `tests/test_weather_client_anomaly.py` covering enrichment
  success, None result, missing data, exception handling, and task
  creation logic
- Update CHANGELOG with user-facing description

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant