|
15 | 15 |
|
16 | 16 | from pvlib import atmosphere, solarposition, tools
|
17 | 17 | from pvlib._deprecation import deprecated
|
| 18 | +from tools import nanmaximum |
18 | 19 |
|
19 | 20 | # see References section of grounddiffuse function
|
20 | 21 | SURFACE_ALBEDOS = {'urban': 0.18,
|
@@ -1147,24 +1148,24 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
|
1147 | 1148 | F2c = np.vstack((F2c, nans))
|
1148 | 1149 |
|
1149 | 1150 | F1 = (F1c[ebin, 0] + F1c[ebin, 1] * delta + F1c[ebin, 2] * z)
|
1150 |
| - F1 = np.where(np.isnan(F1), np.nan, np.maximum(F1, 0)) |
| 1151 | + F1 = nanmaximum(F1, 0) |
1151 | 1152 |
|
1152 | 1153 | F2 = (F2c[ebin, 0] + F2c[ebin, 1] * delta + F2c[ebin, 2] * z)
|
1153 |
| - F2 = np.where(np.isnan(F2), np.nan, np.maximum(F2, 0)) |
| 1154 | + F2 = nanmaximum(F2, 0) |
1154 | 1155 |
|
1155 | 1156 | A = aoi_projection(surface_tilt, surface_azimuth,
|
1156 | 1157 | solar_zenith, solar_azimuth)
|
1157 |
| - A = np.maximum(A, 0) |
| 1158 | + A = nanmaximum(A, 0) |
1158 | 1159 |
|
1159 | 1160 | B = tools.cosd(solar_zenith)
|
1160 |
| - B = np.where(np.isnan(B), np.nan, np.maximum(B, tools.cosd(85))) |
| 1161 | + B = nanmaximum(B, tools.cosd(85)) |
1161 | 1162 |
|
1162 | 1163 | # Calculate Diffuse POA from sky dome
|
1163 | 1164 | term1 = 0.5 * (1 - F1) * (1 + tools.cosd(surface_tilt))
|
1164 | 1165 | term2 = F1 * A / B
|
1165 | 1166 | term3 = F2 * tools.sind(surface_tilt)
|
1166 | 1167 |
|
1167 |
| - sky_diffuse = np.maximum(dhi * (term1 + term2 + term3), 0) |
| 1168 | + sky_diffuse = nanmaximum(dhi * (term1 + term2 + term3), 0) |
1168 | 1169 |
|
1169 | 1170 | # we've preserved the input type until now, so don't ruin it!
|
1170 | 1171 | if isinstance(sky_diffuse, pd.Series):
|
|
0 commit comments