Skip to content

Commit 975b798

Browse files
authored
Reindl model bug fix to close #1153 (#1154)
* fixed reindl model to generate zeros when irradiance is zero. Also revised the test * typo fix * stickler-ci edits * added to what's new * added to what's new * formatting
1 parent 0b8f24c commit 975b798

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

docs/sphinx/source/whatsnew/v0.9.0.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ Bug fixes
100100
* Pass weather data to solar position calculations in
101101
:ref:meth:`~pvlib.modelchain.ModelChain.prepare_inputs_from_poa`.
102102
(:issue:`1065`, :pull:`1140`)
103-
103+
* Reindl model fixed to generate sky_diffuse=0 when GHI=0.
104+
(:issue:`1153`, :pull:`1154`)
104105
Testing
105106
~~~~~~~
106107

pvlib/irradiance.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,9 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra,
886886
# these are the () and [] sub-terms of the second term of eqn 8
887887
term1 = 1 - AI
888888
term2 = 0.5 * (1 + tools.cosd(surface_tilt))
889-
term3 = 1 + np.sqrt(HB / ghi) * (tools.sind(0.5 * surface_tilt) ** 3)
890-
889+
with np.errstate(invalid='ignore', divide='ignore'):
890+
hb_to_ghi = np.where(ghi == 0, 0, np.divide(HB, ghi))
891+
term3 = 1 + np.sqrt(hb_to_ghi) * (tools.sind(0.5 * surface_tilt)**3)
891892
sky_diffuse = dhi * (AI * Rb + term1 * term2 * term3)
892893
sky_diffuse = np.maximum(sky_diffuse, 0)
893894

pvlib/tests/test_irradiance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def test_reindl(irrad_data, ephem_data, dni_et):
203203
40, 180, irrad_data['dhi'], irrad_data['dni'], irrad_data['ghi'],
204204
dni_et, ephem_data['apparent_zenith'], ephem_data['azimuth'])
205205
# values from matlab 1.4 code
206-
assert_allclose(result, [np.nan, 27.9412, 104.1317, 34.1663], atol=1e-4)
206+
assert_allclose(result, [0., 27.9412, 104.1317, 34.1663], atol=1e-4)
207207

208208

209209
def test_king(irrad_data, ephem_data):

0 commit comments

Comments
 (0)