capturegraph.scheduling.forecast.weather
#
Weather Forecasting - Open-Meteo Integration#
Fetches hourly weather forecasts from the Open-Meteo API (free, no API key required).
hourly_weather(location, days=3)
#
Fetch hourly weather forecast from Open-Meteo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
Location
|
Location with latitude and longitude attributes. |
required |
days
|
int
|
Number of days to forecast (1-16). Defaults to 3. |
3
|
Returns:
| Type | Description |
|---|---|
List[Weather]
|
List of Weather objects for each hour. |
Source code in capturegraph-lib/capturegraph/scheduling/forecast/weather.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
nearest_weather(weather, times)
#
Find the nearest weather entry for each timestamp.
Sorts the weather list by date and uses binary search to find the closest weather entry for each query time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weather
|
List[Weather]
|
List of Weather objects with date attributes. |
required |
times
|
List[datetime]
|
List of datetimes to find weather for. |
required |
Returns:
| Type | Description |
|---|---|
List[Weather]
|
List of Weather objects, one for each query time. |