weather package

Submodules

Module contents

Weather and irradiance data for the simulator.

Exposes OpenMeteoClient for hourly weather and solar data (Open-Meteo forecast and archive APIs).

class weather.OpenMeteoClient(latitude: float, longitude: float)[source]

Bases: object

Fetches hourly weather and irradiance from Open-Meteo for a fixed (lat, lon).

FORECAST_URL = 'https://api.open-meteo.com/v1/forecast'
HISTORICAL_URL = 'https://archive-api.open-meteo.com/v1/archive'
fetch_forecast(start_date: datetime, days: int = 7) Dict[str, List] | None[source]

Fetch hourly weather for the date range; uses historical API for past dates, forecast API otherwise.

Parameters:
  • start_date – Start date (timezone-aware or naive).

  • days – Number of days to fetch (forecast free tier typically limited to 7).

Returns:

Parsed dict with ‘timestamps’ and metric lists, or None on request error.

get_current_conditions(current_time: datetime) Dict | None[source]

Return conditions for the hour closest to current_time (fetches 1-day forecast).

Parameters:

current_time – Time to resolve (timezone-aware or naive).

Returns:

Dict with “timestamp” and one value per metric for that hour, or None if fetch fails.