From a7ff7a372465d5ef9fbe3b1cd710c60d468a0f0f Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 9 Jul 2026 11:39:58 -0800 Subject: [PATCH 1/7] Add dni to VARIABLE_MAP in get_era5 iotools function --- pvlib/iotools/era5.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pvlib/iotools/era5.py b/pvlib/iotools/era5.py index 525848bb27..d95ad56f47 100644 --- a/pvlib/iotools/era5.py +++ b/pvlib/iotools/era5.py @@ -11,6 +11,7 @@ 't2m': 'temp_air', 'sp': 'pressure', 'ssrd': 'ghi', + 'fdir': 'dni', 'tp': 'precipitation', 'strd': 'longwave_down', @@ -19,6 +20,7 @@ '2m_temperature': 'temp_air', 'surface_pressure': 'pressure', 'surface_solar_radiation_downwards': 'ghi', + 'total_sky_direct_solar_radiation_at_surface': 'dni', 'total_precipitation': 'precipitation', 'surface_thermal_radiation_downwards': 'longwave_down', } From 34271c1a47dd18129b29451a01793b98e4cc880c Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 9 Jul 2026 11:41:29 -0800 Subject: [PATCH 2/7] Add dni to example variable in doc --- pvlib/iotools/era5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/iotools/era5.py b/pvlib/iotools/era5.py index d95ad56f47..14c0f28e8d 100644 --- a/pvlib/iotools/era5.py +++ b/pvlib/iotools/era5.py @@ -82,7 +82,7 @@ def get_era5(latitude, longitude, start, end, variables, api_key, Last day of the requested period. Assumed to be UTC if not localized. variables : list of str List of variable names to retrieve, for example - ``['ghi', 'temp_air']``. Both pvlib and ERA5 names can be used. + ``['ghi', 'dni', 'temp_air']``. Both pvlib and ERA5 names can be used. See [1]_ for additional options. api_key : str ECMWF CDS API key. From 7bdb4a62a07532cc7c1d9e219f8ea2e0d88d5b49 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 9 Jul 2026 12:08:29 -0800 Subject: [PATCH 3/7] Convert dni from J to W --- pvlib/iotools/era5.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pvlib/iotools/era5.py b/pvlib/iotools/era5.py index 14c0f28e8d..50ae2ab748 100644 --- a/pvlib/iotools/era5.py +++ b/pvlib/iotools/era5.py @@ -54,6 +54,7 @@ def _m_to_cm(m): 'skt': _k_to_c, 'sp': _same, 'ssrd': _j_to_w, + 'fdir': _j_to_w, 'strd': _j_to_w, 'tp': _m_to_cm, } From e886e285db8ca7595e2884ec56edc9dacb2ece81 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 9 Jul 2026 14:34:05 -0800 Subject: [PATCH 4/7] Change dni to bhi --- pvlib/iotools/era5.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/iotools/era5.py b/pvlib/iotools/era5.py index 50ae2ab748..5465039536 100644 --- a/pvlib/iotools/era5.py +++ b/pvlib/iotools/era5.py @@ -11,7 +11,7 @@ 't2m': 'temp_air', 'sp': 'pressure', 'ssrd': 'ghi', - 'fdir': 'dni', + 'fdir': 'bhi', 'tp': 'precipitation', 'strd': 'longwave_down', @@ -20,7 +20,7 @@ '2m_temperature': 'temp_air', 'surface_pressure': 'pressure', 'surface_solar_radiation_downwards': 'ghi', - 'total_sky_direct_solar_radiation_at_surface': 'dni', + 'total_sky_direct_solar_radiation_at_surface': 'bhi', 'total_precipitation': 'precipitation', 'surface_thermal_radiation_downwards': 'longwave_down', } @@ -83,7 +83,7 @@ def get_era5(latitude, longitude, start, end, variables, api_key, Last day of the requested period. Assumed to be UTC if not localized. variables : list of str List of variable names to retrieve, for example - ``['ghi', 'dni', 'temp_air']``. Both pvlib and ERA5 names can be used. + ``['ghi', 'bhi', 'temp_air']``. Both pvlib and ERA5 names can be used. See [1]_ for additional options. api_key : str ECMWF CDS API key. From 5481954b11419cf6ded58d1502d2f599afb38499 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 9 Jul 2026 14:36:32 -0800 Subject: [PATCH 5/7] Update v0.16.0.rst --- docs/sphinx/source/whatsnew/v0.16.0.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.16.0.rst b/docs/sphinx/source/whatsnew/v0.16.0.rst index 6d62b9e1c6..d94c2d8c86 100644 --- a/docs/sphinx/source/whatsnew/v0.16.0.rst +++ b/docs/sphinx/source/whatsnew/v0.16.0.rst @@ -23,7 +23,9 @@ Bug fixes Enhancements ~~~~~~~~~~~~ - +* Map beam horizontal irradiance to ``bhi`` when + :py:func:`~pvlib.iotools.get_era5` is called with ``map_variables=True``. + (:pull:`2819`) Documentation ~~~~~~~~~~~~~ From 5a48da76ce4b1bf37892d19bac19a8264b57be45 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 9 Jul 2026 14:51:54 -0800 Subject: [PATCH 6/7] Update test_era5.py --- tests/iotools/test_era5.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/iotools/test_era5.py b/tests/iotools/test_era5.py index 452097c83c..6477d0ad09 100644 --- a/tests/iotools/test_era5.py +++ b/tests/iotools/test_era5.py @@ -17,7 +17,9 @@ def params(): return { 'latitude': 40.01, 'longitude': -80.01, 'start': '2020-06-01', 'end': '2020-06-01', - 'variables': ['ghi', 'temp_air'], + # Test a mix of pvlib and ERA5 variable names + 'variables': [ + 'ghi', 'temp_air', 'total_sky_direct_solar_radiation_at_surface'], 'api_key': api_key, } @@ -33,7 +35,10 @@ def expected(): ghi = [153., 18.4, 0., 0., 0., 0., 0., 0., 0., 0., 0., 60., 229.5, 427.8, 620.1, 785.5, 910.1, 984.2, 1005.9, 962.4, 844.1, 685.2, 526.9, 331.4] - df = pd.DataFrame({'temp_air': temp_air, 'ghi': ghi}, index=index) + bhi = [102.6, 8.3, 0., 0., 0., 0., 0., 0., 0., 0., 0., 34.9, 167.8, 345.6, + 524.3, 679.5, 796.1, 866.1, 893.4, 841.7, 724. , 539.6, 415.1, + 239.6] + df = pd.DataFrame({'temp_air': temp_air, 'ghi': ghi, 'bhi': bhi}, index=index) return df @@ -66,9 +71,11 @@ def test_get_era5_timezone(params, expected): @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY) def test_get_era5_map_variables(params, expected): df, meta = pvlib.iotools.get_era5(**params, map_variables=False) - expected = expected.rename(columns={'temp_air': 't2m', 'ghi': 'ssrd'}) + expected = expected.rename(columns={ + 'temp_air': 't2m', 'ghi': 'ssrd', "bhi": "fdir"}) df['t2m'] -= 273.15 # apply unit conversions manually df['ssrd'] /= 3600 + df['fdir'] /= 3600 pd.testing.assert_frame_equal(df, expected, check_freq=False, atol=0.1) assert meta['longitude'] == -80.0 assert meta['latitude'] == 40.0 From 61b11445b27e3a46e0dfcc274ad576cc8d32bfe9 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 9 Jul 2026 14:53:36 -0800 Subject: [PATCH 7/7] Fix linter --- tests/iotools/test_era5.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/iotools/test_era5.py b/tests/iotools/test_era5.py index 6477d0ad09..8ef1602fea 100644 --- a/tests/iotools/test_era5.py +++ b/tests/iotools/test_era5.py @@ -36,9 +36,10 @@ def expected(): 427.8, 620.1, 785.5, 910.1, 984.2, 1005.9, 962.4, 844.1, 685.2, 526.9, 331.4] bhi = [102.6, 8.3, 0., 0., 0., 0., 0., 0., 0., 0., 0., 34.9, 167.8, 345.6, - 524.3, 679.5, 796.1, 866.1, 893.4, 841.7, 724. , 539.6, 415.1, + 524.3, 679.5, 796.1, 866.1, 893.4, 841.7, 724., 539.6, 415.1, 239.6] - df = pd.DataFrame({'temp_air': temp_air, 'ghi': ghi, 'bhi': bhi}, index=index) + df = pd.DataFrame({'temp_air': temp_air, 'ghi': ghi, 'bhi': bhi}, + index=index) return df