Skip to content

Commit 2a2185f

Browse files
Update some comments and whatsnew
1 parent f6c8070 commit 2a2185f

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ Deprecations
1414

1515
Bug fixes
1616
~~~~~~~~~
17-
17+
* Fix :py:func:`pvlib.irradiance.perez` to not return NaN when both DHI and
18+
DNI are zero. (:issue:`2801`, :pull:`2808`)
19+
* Fix :py:func:`pvlib.irradiance.perez` to not return zero (instead NaN) when
20+
airmass is NaN and either DHI or DNI are NaN. (:issue:`2801`, :pull:`2808`)
1821

1922
Enhancements
2023
~~~~~~~~~~~~
@@ -48,3 +51,4 @@ Contributors
4851
* Eesh Saxena (:ghuser:`eeshsaxena`)
4952
* Karl Hill (:ghuser:`karlhillx`)
5053
* Yonry Zhu (:ghuser:`yonryzhu`)
54+
* Mark Campanelli (:ghuser:`markcampanelli`)

pvlib/irradiance.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,18 +1211,19 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
12111211
B = np.maximum(B, tools.cosd(85))
12121212

12131213
# Calculate Diffuse POA from sky dome
1214-
term1 = 0.5 * (1 - F1) * (1 + tools.cosd(surface_tilt))
1215-
term2 = F1 * A / B
1216-
term3 = F2 * tools.sind(surface_tilt)
1214+
term1 = 0.5 * (1 - F1) * (1 + tools.cosd(surface_tilt)) # isotropic
1215+
term2 = F1 * A / B # circumsolar
1216+
term3 = F2 * tools.sind(surface_tilt) # horizon
12171217

12181218
sky_diffuse = np.maximum(dhi * (term1 + term2 + term3), 0)
12191219

1220-
# we've preserved the input type until now, so don't ruin it!
1220+
# Use NaN airmass to coerce to zero values that are not otherwise NaN.
12211221
airmass_nan_idx = np.logical_and(
12221222
np.isnan(airmass), np.logical_not(
12231223
np.logical_or(np.isnan(dhi), np.isnan(dni))
12241224
)
12251225
)
1226+
# we've preserved the input type until now, so don't ruin it!
12261227
if isinstance(sky_diffuse, pd.Series):
12271228
sky_diffuse[airmass_nan_idx] = 0
12281229
else:

0 commit comments

Comments
 (0)