Open-Meteo Weather
Weather is a primary driver of electricity prices through its effect on both supply (solar, wind generation) and demand (heating, cooling). EPF collects hourly weather data from 5 stations across Spain and aggregates them into a single national weather signal.
Data Provider
EPF uses Open-Meteo, an open-source weather API:
- Forecast endpoint:
https://api.open-meteo.com/v1/forecast— 7-day ahead hourly forecasts - Archive endpoint:
https://archive-api.open-meteo.com/v1/archive— historical data for training - Cost: Free, no API key required
- Resolution: Hourly
Weather Stations
Five stations are selected to represent Spain’s major climate zones, weighted by population density:
| Station | City | Latitude | Longitude | Zone | Weight |
|---|---|---|---|---|---|
| Madrid-Barajas | Madrid | 40.47°N | 3.56°W | Center/West | 0.35 |
| Barcelona-El Prat | Barcelona | 41.30°N | 2.08°E | East | 0.25 |
| Valencia-Airport | Valencia | 39.49°N | 0.47°W | East | 0.15 |
| Bilbao-Airport | Bilbao | 43.30°N | 2.91°W | North | 0.13 |
| Sevilla-Airport | Sevilla | 37.42°N | 5.90°W | South | 0.12 |
The population weighting reflects how demand is distributed: Madrid and Barcelona account for 60% of the weight because they drive the largest share of national electricity consumption.
Variables Collected
| API Parameter | Column Name | Unit | Description |
|---|---|---|---|
temperature_2m | temp_c | °C | Air temperature at 2m height |
wind_speed_10m | wind_speed_kmh | km/h | Wind speed at 10m height |
precipitation | precipitation_mm | mm | Precipitation amount |
sunshine_duration | sunshine_hours | hours | Sunshine duration (converted from seconds) |
cloud_cover | cloud_cover_pct | % | Total cloud cover percentage |
direct_radiation | direct_radiation_wm2 | W/m² | Direct solar radiation |
diffuse_radiation | diffuse_radiation_wm2 | W/m² | Diffuse solar radiation |
Aggregation
All 5 stations are fetched independently, then combined into a weighted national average:
national_value = sum(station_value × weight) / sum(weights)This produces a single hourly time series for each weather variable that represents national conditions.
Forecast vs. Historical
The weather pipeline serves two purposes:
-
Real-time forecasting: Fetches
past_days=2, forecast_days=7to provide a 2-day lookback plus 7-day forecast horizon. At forecast time, the model uses observed weather up to the present and forecast weather for target hours. -
Historical training: The archive endpoint provides years of historical weather aligned with historical electricity prices for model training. Archive requests are chunked into 3-month periods with rate-limiting delays between calls.
Weather-Derived Features
Raw weather variables are transformed into interaction features that capture their effect on electricity supply and demand:
- Temperature-demand interactions: heating degree days, cooling degree days, cold-demand cross-term
- Wind-generation interaction: wind speed × wind generation share
- Solar features: global horizontal irradiance (GHI = direct + diffuse), clear-sky index, solar elevation angle, daylight indicator
- Cloud-solar interaction: cloud cover × solar share
- Precipitation-hydro interaction: rainfall × hydro generation share
See the Weather Features section for computation details.