From f3c129932c4f69fd9e87a5809c69022a6bf876b7 Mon Sep 17 00:00:00 2001 From: Joshua Stein Date: Fri, 29 Jan 2021 13:31:25 -0700 Subject: [PATCH 1/6] fixed reindl model to generate zeros when irradiance is zero. Also revised the test --- pvlib/irradiance.py | 5 +++-- pvlib/tests/test_irradiance.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 65800300b9..56c139c848 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -886,8 +886,9 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra, # these are the () and [] sub-terms of the second term of eqn 8 term1 = 1 - AI term2 = 0.5 * (1 + tools.cosd(surface_tilt)) - term3 = 1 + np.sqrt(HB / ghi) * (tools.sind(0.5 * surface_tilt) ** 3) - + with np.errstate(invalid='ignore', divide='ignore'): + hb_to_ghi = np.where(ghi==0, 0, np.divide(HB, ghi)) + term3 = 1 + np.sqrt(hb_to_ghi) * (pvlib.tools.sind(0.5 * tilt)**3) sky_diffuse = dhi * (AI * Rb + term1 * term2 * term3) sky_diffuse = np.maximum(sky_diffuse, 0) diff --git a/pvlib/tests/test_irradiance.py b/pvlib/tests/test_irradiance.py index dd914eba34..ba5821f750 100644 --- a/pvlib/tests/test_irradiance.py +++ b/pvlib/tests/test_irradiance.py @@ -203,7 +203,7 @@ def test_reindl(irrad_data, ephem_data, dni_et): 40, 180, irrad_data['dhi'], irrad_data['dni'], irrad_data['ghi'], dni_et, ephem_data['apparent_zenith'], ephem_data['azimuth']) # values from matlab 1.4 code - assert_allclose(result, [np.nan, 27.9412, 104.1317, 34.1663], atol=1e-4) + assert_allclose(result, [0., 27.9412, 104.1317, 34.1663], atol=1e-4) def test_king(irrad_data, ephem_data): From 95c10347c5abe7633c452899b3cc3c8c9b03c220 Mon Sep 17 00:00:00 2001 From: Joshua Stein Date: Fri, 29 Jan 2021 13:42:56 -0700 Subject: [PATCH 2/6] typo fix --- pvlib/irradiance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 56c139c848..429462e089 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -888,7 +888,7 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra, term2 = 0.5 * (1 + tools.cosd(surface_tilt)) with np.errstate(invalid='ignore', divide='ignore'): hb_to_ghi = np.where(ghi==0, 0, np.divide(HB, ghi)) - term3 = 1 + np.sqrt(hb_to_ghi) * (pvlib.tools.sind(0.5 * tilt)**3) + term3 = 1 + np.sqrt(hb_to_ghi) * (tools.sind(0.5 * surface_tilt)**3) sky_diffuse = dhi * (AI * Rb + term1 * term2 * term3) sky_diffuse = np.maximum(sky_diffuse, 0) From 112e2d0b7bdd8ada76b71002ae08f80eb7e17626 Mon Sep 17 00:00:00 2001 From: Joshua Stein Date: Fri, 29 Jan 2021 13:56:49 -0700 Subject: [PATCH 3/6] stickler-ci edits --- pvlib/irradiance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 429462e089..3ec6b213f9 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -887,7 +887,7 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra, term1 = 1 - AI term2 = 0.5 * (1 + tools.cosd(surface_tilt)) with np.errstate(invalid='ignore', divide='ignore'): - hb_to_ghi = np.where(ghi==0, 0, np.divide(HB, ghi)) + hb_to_ghi = np.where(ghi == 0, 0, np.divide(HB, ghi)) term3 = 1 + np.sqrt(hb_to_ghi) * (tools.sind(0.5 * surface_tilt)**3) sky_diffuse = dhi * (AI * Rb + term1 * term2 * term3) sky_diffuse = np.maximum(sky_diffuse, 0) From 39e2d4dd535c16054dfba207ee5651b29669c1c3 Mon Sep 17 00:00:00 2001 From: Joshua Stein Date: Fri, 29 Jan 2021 14:09:07 -0700 Subject: [PATCH 4/6] added to what's new --- docs/sphinx/source/whatsnew/v0.9.0.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.0.rst b/docs/sphinx/source/whatsnew/v0.9.0.rst index 605898cf61..9d23a2752d 100644 --- a/docs/sphinx/source/whatsnew/v0.9.0.rst +++ b/docs/sphinx/source/whatsnew/v0.9.0.rst @@ -100,7 +100,8 @@ Bug fixes * Pass weather data to solar position calculations in :ref:meth:`~pvlib.modelchain.ModelChain.prepare_inputs_from_poa`. (:issue:`1065`, :pull:`1140`) - +* Reindl model fixed to generate sky_diffuse=0 when GHI=0. + (:issue:'1153', :pull:'1154') Testing ~~~~~~~ From c2fec75240196cec9195738e1be6bf990d79b9ef Mon Sep 17 00:00:00 2001 From: Joshua Stein Date: Fri, 29 Jan 2021 14:11:11 -0700 Subject: [PATCH 5/6] added to what's new --- docs/sphinx/source/whatsnew/v0.9.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.0.rst b/docs/sphinx/source/whatsnew/v0.9.0.rst index 9d23a2752d..57392a45e6 100644 --- a/docs/sphinx/source/whatsnew/v0.9.0.rst +++ b/docs/sphinx/source/whatsnew/v0.9.0.rst @@ -101,7 +101,7 @@ Bug fixes :ref:meth:`~pvlib.modelchain.ModelChain.prepare_inputs_from_poa`. (:issue:`1065`, :pull:`1140`) * Reindl model fixed to generate sky_diffuse=0 when GHI=0. - (:issue:'1153', :pull:'1154') + (:issue:'1153', :pull:'1154', :ghuser:'jsstein') Testing ~~~~~~~ From d88e3bb6d6b2a1aa88c12789feee93e0ffb10d26 Mon Sep 17 00:00:00 2001 From: Joshua Stein Date: Tue, 2 Feb 2021 13:40:17 -0700 Subject: [PATCH 6/6] formatting --- docs/sphinx/source/whatsnew/v0.9.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.0.rst b/docs/sphinx/source/whatsnew/v0.9.0.rst index 57392a45e6..e7907efc7d 100644 --- a/docs/sphinx/source/whatsnew/v0.9.0.rst +++ b/docs/sphinx/source/whatsnew/v0.9.0.rst @@ -101,7 +101,7 @@ Bug fixes :ref:meth:`~pvlib.modelchain.ModelChain.prepare_inputs_from_poa`. (:issue:`1065`, :pull:`1140`) * Reindl model fixed to generate sky_diffuse=0 when GHI=0. - (:issue:'1153', :pull:'1154', :ghuser:'jsstein') + (:issue:`1153`, :pull:`1154`) Testing ~~~~~~~