@@ -967,32 +967,30 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
967
967
solar_zenith , solar_azimuth , airmass ,
968
968
modelt = 'allsitescomposite1990' ):
969
969
'''
970
- Determine diffuse irradiance from the sky on a tilted surface using one of
971
- the Perez models.
970
+ Determine diffuse irradiance from the sky on a tilted surface using
971
+ one of the Perez models.
972
972
973
973
Perez models determine the diffuse irradiance from the sky (ground
974
974
reflected irradiance is not included in this algorithm) on a tilted
975
975
surface using the surface tilt angle, surface azimuth angle, diffuse
976
976
horizontal irradiance, direct normal irradiance, extraterrestrial
977
977
irradiance, sun zenith angle, sun azimuth angle, and relative (not
978
- pressure-corrected) airmass. Optionally a selector may be used to use
979
- any of Perez's model coefficient sets.
978
+ pressure-corrected) airmass. Optionally a selector may be used to
979
+ use any of Perez's model coefficient sets.
980
980
981
981
982
982
Parameters
983
983
----------
984
984
985
985
surface_tilt : float or Series
986
- Surface tilt angles in decimal degrees.
987
- surface_tilt must be >=0 and <=180. The tilt angle is defined as
988
- degrees from horizontal (e.g. surface facing up = 0, surface facing
989
- horizon = 90)
986
+ Surface tilt angles in decimal degrees. surface_tilt must be >=0
987
+ and <=180. The tilt angle is defined as degrees from horizontal
988
+ (e.g. surface facing up = 0, surface facing horizon = 90)
990
989
991
990
surface_azimuth : float or Series
992
- Surface azimuth angles in decimal degrees.
993
- surface_azimuth must be >=0 and <=360. The Azimuth convention is defined
994
- as degrees east of north (e.g. North = 0, South=180 East = 90,
995
- West = 270).
991
+ Surface azimuth angles in decimal degrees. surface_azimuth must
992
+ be >=0 and <=360. The Azimuth convention is defined as degrees
993
+ east of north (e.g. North = 0, South=180 East = 90, West = 270).
996
994
997
995
dhi : float or Series
998
996
Diffuse horizontal irradiance in W/m^2.
@@ -1011,22 +1009,20 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
1011
1009
solar_zenith must be >=0 and <=180.
1012
1010
1013
1011
solar_azimuth : float or Series
1014
- Sun azimuth angles in decimal degrees.
1015
- solar_azimuth must be >=0 and <=360. The Azimuth convention is defined
1016
- as degrees east of north (e.g. North = 0, East = 90, West = 270).
1012
+ Sun azimuth angles in decimal degrees. solar_azimuth must be >=0
1013
+ and <=360. The Azimuth convention is defined as degrees east of
1014
+ north (e.g. North = 0, East = 90, West = 270).
1017
1015
1018
1016
airmass : float or Series
1019
- relative (not pressure-corrected) airmass
1020
- values. If AM is a DataFrame it must be of the same size as all other
1021
- DataFrame inputs. AM must be >=0 (careful using the 1/sec(z) model of
1022
- AM generation)
1017
+ Relative (not pressure-corrected) airmass values. If AM is a
1018
+ DataFrame it must be of the same size as all other DataFrame
1019
+ inputs. AM must be >=0 (careful using the 1/sec(z) model of AM
1020
+ generation)
1023
1021
1024
1022
model : string (optional, default='allsitescomposite1990')
1025
-
1026
- A string which selects the desired set of Perez
1027
- coefficients. If model is not provided as an input, the default,
1028
- '1990' will be used.
1029
- All possible model selections are:
1023
+ A string which selects the desired set of Perez coefficients. If
1024
+ model is not provided as an input, the default, '1990' will be
1025
+ used. All possible model selections are:
1030
1026
1031
1027
* '1990'
1032
1028
* 'allsitescomposite1990' (same as '1990')
@@ -1046,44 +1042,42 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
1046
1042
1047
1043
float or Series
1048
1044
1049
- The diffuse component of the solar radiation on an
1050
- arbitrarily tilted surface defined by the Perez model as given in
1051
- reference [3].
1052
- SkyDiffuse is the diffuse component ONLY and does not include the
1053
- ground reflected irradiance or the irradiance due to the beam.
1045
+ The diffuse component of the solar radiation on an arbitrarily
1046
+ tilted surface defined by the Perez model as given in reference
1047
+ [3]. SkyDiffuse is the diffuse component ONLY and does not
1048
+ include the ground reflected irradiance or the irradiance due to
1049
+ the beam.
1054
1050
1055
1051
1056
1052
References
1057
1053
----------
1058
1054
1059
- [1] Loutzenhiser P.G. et. al. "Empirical validation of models to compute
1060
- solar irradiance on inclined surfaces for building energy simulation"
1061
- 2007, Solar Energy vol. 81. pp. 254-267
1055
+ [1] Loutzenhiser P.G. et. al. "Empirical validation of models to
1056
+ compute solar irradiance on inclined surfaces for building energy
1057
+ simulation" 2007, Solar Energy vol. 81. pp. 254-267
1062
1058
1063
- [2] Perez, R., Seals, R., Ineichen, P., Stewart, R., Menicucci, D., 1987.
1064
- A new simplified version of the Perez diffuse irradiance model for tilted
1065
- surfaces. Solar Energy 39(3), 221-232.
1059
+ [2] Perez, R., Seals, R., Ineichen, P., Stewart, R., Menicucci, D.,
1060
+ 1987. A new simplified version of the Perez diffuse irradiance model
1061
+ for tilted surfaces. Solar Energy 39(3), 221-232.
1066
1062
1067
- [3] Perez, R., Ineichen, P., Seals, R., Michalsky, J., Stewart, R., 1990.
1068
- Modeling daylight availability and irradiance components from direct
1069
- and global irradiance. Solar Energy 44 (5), 271-289.
1063
+ [3] Perez, R., Ineichen, P., Seals, R., Michalsky, J., Stewart, R.,
1064
+ 1990. Modeling daylight availability and irradiance components from
1065
+ direct and global irradiance. Solar Energy 44 (5), 271-289.
1070
1066
1071
1067
[4] Perez, R. et. al 1988. "The Development and Verification of the
1072
1068
Perez Diffuse Radiation Model". SAND88-7030
1073
1069
'''
1074
1070
1075
- pvl_logger .debug ('diffuse_sky.perez()' )
1076
-
1077
1071
kappa = 1.041 # for solar_zenith in radians
1078
1072
z = np .radians (solar_zenith ) # convert to radians
1079
1073
1080
1074
# epsilon is the sky's "clearness"
1081
1075
eps = ((dhi + dni ) / dhi + kappa * (z ** 3 )) / (1 + kappa * (z ** 3 ))
1082
1076
1083
- # Perez et al define clearness bins according to the following rules.
1084
- # 1 = overcast ... 8 = clear
1085
- # (these names really only make sense for small zenith angles, but...)
1086
- # these values will eventually be used as indicies for coeffecient look ups
1077
+ # Perez et al define clearness bins according to the following
1078
+ # rules. 1 = overcast ... 8 = clear (these names really only make
1079
+ # sense for small zenith angles, but...) these values will
1080
+ # eventually be used as indicies for coeffecient look ups
1087
1081
ebin = eps .copy ()
1088
1082
ebin [(eps < 1.065 )] = 1
1089
1083
ebin [(eps >= 1.065 ) & (eps < 1.23 )] = 2
@@ -1100,31 +1094,29 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
1100
1094
ebin = ebin .dropna ().astype (int )
1101
1095
1102
1096
# This is added because in cases where the sun is below the horizon
1103
- # (var.solar_zenith > 90) but there is still diffuse horizontal light
1104
- # (var.DHI>0), it is possible that the airmass (var.AM) could be NaN, which
1105
- # messes up later calculations. Instead, if the sun is down, and there is
1106
- # still var.DHI, we set the airmass to the airmass value on the horizon
1107
- # (approximately 37-38).
1097
+ # (var.solar_zenith > 90) but there is still diffuse horizontal
1098
+ # light (var.DHI>0), it is possible that the airmass (var.AM) could
1099
+ # be NaN, which messes up later calculations. Instead, if the sun is
1100
+ # down, and there is still var.DHI, we set the airmass to the
1101
+ # airmass value on the horizon (approximately 37-38).
1108
1102
# var.AM(var.solar_zenith >=90 & var.DHI >0) = 37;
1109
1103
1110
1104
# var.DNI_ET[var.DNI_ET==0] = .00000001 #very hacky, fix this
1111
1105
1112
1106
# delta is the sky's "brightness"
1113
1107
delta = dhi * airmass / dni_extra
1114
1108
1115
- # keep only valid times
1116
- delta = delta [ebin .index ]
1117
- z = z [ebin .index ]
1118
-
1119
1109
# The various possible sets of Perez coefficients are contained
1120
1110
# in a subfunction to clean up the code.
1121
1111
F1c , F2c = _get_perez_coefficients (modelt )
1122
1112
1123
- F1 = F1c [ebin , 0 ] + F1c [ebin , 1 ] * delta + F1c [ebin , 2 ] * z
1113
+ F1 = (F1c [ebin , 0 ] + F1c [ebin , 1 ] * delta [ebin .index ] +
1114
+ F1c [ebin , 2 ] * z [ebin .index ])
1124
1115
F1 [F1 < 0 ] = 0
1125
1116
F1 = F1 .astype (float )
1126
1117
1127
- F2 = F2c [ebin , 0 ] + F2c [ebin , 1 ] * delta + F2c [ebin , 2 ] * z
1118
+ F2 = (F2c [ebin , 0 ] + F2c [ebin , 1 ] * delta [ebin .index ] +
1119
+ F2c [ebin , 2 ] * z [ebin .index ])
1128
1120
F2 [F2 < 0 ] = 0
1129
1121
F2 = F2 .astype (float )
1130
1122
@@ -1141,8 +1133,9 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
1141
1133
term2 = F1 * A [ebin .index ] / B [ebin .index ]
1142
1134
term3 = F2 * tools .sind (surface_tilt )
1143
1135
1144
- sky_diffuse = dhi [ ebin . index ] * (term1 + term2 + term3 )
1136
+ sky_diffuse = dhi * (term1 + term2 + term3 )
1145
1137
sky_diffuse [sky_diffuse < 0 ] = 0
1138
+ sky_diffuse [airmass .isnull ()] = 0
1146
1139
1147
1140
return sky_diffuse
1148
1141
0 commit comments