Skip to content

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:

StationCityLatitudeLongitudeZoneWeight
Madrid-BarajasMadrid40.47°N3.56°WCenter/West0.35
Barcelona-El PratBarcelona41.30°N2.08°EEast0.25
Valencia-AirportValencia39.49°N0.47°WEast0.15
Bilbao-AirportBilbao43.30°N2.91°WNorth0.13
Sevilla-AirportSevilla37.42°N5.90°WSouth0.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 ParameterColumn NameUnitDescription
temperature_2mtemp_c°CAir temperature at 2m height
wind_speed_10mwind_speed_kmhkm/hWind speed at 10m height
precipitationprecipitation_mmmmPrecipitation amount
sunshine_durationsunshine_hourshoursSunshine duration (converted from seconds)
cloud_covercloud_cover_pct%Total cloud cover percentage
direct_radiationdirect_radiation_wm2W/m²Direct solar radiation
diffuse_radiationdiffuse_radiation_wm2W/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:

  1. Real-time forecasting: Fetches past_days=2, forecast_days=7 to 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.

  2. 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.