From 379d1f88686a8d51cea221b5553d857a1458dcf1 Mon Sep 17 00:00:00 2001 From: cbcrespo Date: Tue, 9 Jun 2026 10:33:23 +0100 Subject: [PATCH 1/3] Remove empty horizon brightening component from haydavies --- pvlib/irradiance.py | 5 +---- tests/test_irradiance.py | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 50f02426de..df9ed37b9e 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -797,8 +797,7 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra, * poa_sky_diffuse: Total sky diffuse * poa_isotropic * poa_circumsolar - * poa_horizon (always zero, not accounted for by the - Hay-Davies model) + The model does not support a horizon brightening component. Notes ------ @@ -862,8 +861,6 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra, # Calculate the individual components diffuse_components['poa_isotropic'] = poa_isotropic diffuse_components['poa_circumsolar'] = poa_circumsolar - diffuse_components['poa_horizon'] = np.where( - np.isnan(diffuse_components['poa_isotropic']), np.nan, 0.) if isinstance(sky_diffuse, pd.Series): diffuse_components = pd.DataFrame(diffuse_components) diff --git a/tests/test_irradiance.py b/tests/test_irradiance.py index a416636ae9..839ea45316 100644 --- a/tests/test_irradiance.py +++ b/tests/test_irradiance.py @@ -209,13 +209,11 @@ def test_haydavies(irrad_data, ephem_data, dni_et): def test_haydavies_components(irrad_data, ephem_data, dni_et): - keys = ['poa_sky_diffuse', 'poa_isotropic', 'poa_circumsolar', - 'poa_horizon'] + keys = ['poa_sky_diffuse', 'poa_isotropic', 'poa_circumsolar'] expected = pd.DataFrame(np.array( [[0, 27.1775, 102.9949, 33.1909], [0, 27.1775, 30.1818, 27.9837], - [0, 0, 72.8130, 5.2071], - [0, 0, 0, 0]]).T, + [0, 0, 72.8130, 5.2071]]).T, columns=keys, index=irrad_data.index ) From 25b9f274ba8579dec54572ffae04e04b9611f483 Mon Sep 17 00:00:00 2001 From: cbcrespo Date: Mon, 15 Jun 2026 11:18:48 +0100 Subject: [PATCH 2/3] Change OrderedDict to Dict --- pvlib/irradiance.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index df9ed37b9e..8651af8fe2 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -783,7 +783,7 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra, Returns -------- - numeric, OrderedDict, or DataFrame + numeric, Dict, or DataFrame Return type controlled by ``return_components`` argument. If `False`, ``sky_diffuse`` is returned. If `True`, ``diffuse_components`` is returned. @@ -792,7 +792,7 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra, The sky diffuse component of the solar radiation on a tilted surface. [Wm⁻²] - diffuse_components : OrderedDict (array input) or DataFrame (Series input) + diffuse_components : Dict (array input) or DataFrame (Series input) Keys/columns are: * poa_sky_diffuse: Total sky diffuse * poa_isotropic @@ -855,12 +855,11 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra, sky_diffuse = poa_isotropic + poa_circumsolar if return_components: - diffuse_components = OrderedDict() - diffuse_components['poa_sky_diffuse'] = sky_diffuse - - # Calculate the individual components - diffuse_components['poa_isotropic'] = poa_isotropic - diffuse_components['poa_circumsolar'] = poa_circumsolar + diffuse_components = { + 'poa_sky_diffuse': sky_diffuse, + 'poa_isotropic': poa_isotropic, + 'poa_circumsolar': poa_circumsolar + } if isinstance(sky_diffuse, pd.Series): diffuse_components = pd.DataFrame(diffuse_components) From 6ebc8988f46da99e87685df995854b8b83e200a0 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Fri, 19 Jun 2026 11:02:46 +0200 Subject: [PATCH 3/3] Apply suggestion from @AdamRJensen --- pvlib/irradiance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 8651af8fe2..c491fdd884 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -797,7 +797,7 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra, * poa_sky_diffuse: Total sky diffuse * poa_isotropic * poa_circumsolar - The model does not support a horizon brightening component. + The model does not include a horizon brightening component. Notes ------