fix(weather): map instantaneous Open-Meteo GHI, DNI and DHI

WeatherOpenMeteo stored Open-Meteo's direct_radiation, the beam on the
horizontal plane, as weather_dni. PVForecastPVLib transposes weather_dni
as direct normal irradiance, so for a 40 deg south plane in Berlin the
clear-sky plane-of-array irradiance came out at 25 % of the true value
on 21 December, 58 % on 21 March and 80 % on 21 June. The plain
Open-Meteo radiation variables are also means over the preceding hour,
stored at the hour's end, while EOS weather irradiance is the value at
the record time, as BrightSky and ClearOutside derive it from the cloud
cover and as PVForecastPVLib reads it with the sun position at the
record time.

The provider now requests and maps shortwave_radiation_instant,
direct_normal_irradiance_instant and diffuse_radiation_instant. The
instantaneous variables (temperature, humidity, clouds, wind) keep
their stamps; no record is shifted.

test_update_data and test_openmeteo_radiation_mapping pinned the old
mapping of direct_radiation to weather_dni and now expect the instant
variables. The recorded sample response predates them, so the tests
add clear-sky irradiance to it instead of a new recording.

Additional changes
Describe the irradiance of the OpenMeteo provider in the prediction docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
This commit is contained in:
Christin
2026-11-20 21:45:04 +01:00
committed by Bobby Noelte
co-authored by Claude Opus 5.5
parent 966fc7ba7f
commit 926818fbd4
3 changed files with 193 additions and 35 deletions
@@ -36,16 +36,19 @@ WeatherDataOpenMeteoMapping: List[Tuple[str, Optional[str], Optional[Union[str,
("wind_speed_10m", "Wind Speed (kmph)", 3.6), # m/s to km/h
("wind_direction_10m", "Wind Direction (°)", 1),
("wind_gusts_10m", "Wind Gust Speed (kmph)", 3.6), # m/s to km/h
("shortwave_radiation", "Global Horizontal Irradiance (W/m2)", 1),
("direct_radiation", "Direct Normal Irradiance (W/m2)", 1),
("diffuse_radiation", "Diffuse Horizontal Irradiance (W/m2)", 1),
# Plain radiation variables are means over the preceding hour, and `direct_radiation`
# is the beam on the horizontal plane. EOS irradiance is the value at the record time
# and DNI the beam on the plane normal to the sun, so the `*_instant` variables are used.
("shortwave_radiation", None, None),
("direct_radiation", None, None),
("diffuse_radiation", None, None),
("direct_normal_irradiance", None, None),
("global_tilted_irradiance", None, None),
("terrestrial_radiation", None, None),
("shortwave_radiation_instant", None, None),
("shortwave_radiation_instant", "Global Horizontal Irradiance (W/m2)", 1),
("direct_radiation_instant", None, None),
("diffuse_radiation_instant", None, None),
("direct_normal_irradiance_instant", None, None),
("diffuse_radiation_instant", "Diffuse Horizontal Irradiance (W/m2)", 1),
("direct_normal_irradiance_instant", "Direct Normal Irradiance (W/m2)", 1),
("global_tilted_irradiance_instant", None, None),
("terrestrial_radiation_instant", None, None),
("dew_point_2m", "Dew Point (°C)", 1),
@@ -146,9 +149,9 @@ class WeatherOpenMeteo(WeatherProvider):
"wind_speed_10m",
"wind_direction_10m",
"wind_gusts_10m",
"shortwave_radiation", # GHI
"direct_radiation", # DNI
"diffuse_radiation", # DHI
"shortwave_radiation_instant", # GHI
"direct_normal_irradiance_instant", # DNI
"diffuse_radiation_instant", # DHI
"dew_point_2m",
"apparent_temperature",
"precipitation_probability",
@@ -246,9 +249,9 @@ class WeatherOpenMeteo(WeatherProvider):
Retrieves data from Open-Meteo, maps each Open-Meteo field to the corresponding
`WeatherDataRecord` attribute using `WeatherDataOpenMeteoMapping`, and applies
any necessary scaling. Open-Meteo provides direct GHI, DNI, and DHI values which
are used directly without additional calculation. The final mapped and processed
data is inserted into the sequence as `WeatherDataRecord`.
any necessary scaling. Open-Meteo provides GHI, DNI, and DHI at the indicated time
(`*_instant`), which are used directly without additional calculation. The final
mapped and processed data is inserted into the sequence as `WeatherDataRecord`.
"""
import pvlib