Skip to content

Commit 6bfa16e

Browse files
joallen6cwhanse
authored andcommitted
Update pvl_perez.m (#24)
* Update pvl_perez.m These correlations are not numerically stable; i.e. you can get physically unreasonable values for inputs that are reasonable (I'll send figure separately to Cliff). And unreasonable inputs that generate unreasonable outputs are not flagged. This change warns user of unreasonable outputs and converts them to NaNs so unreasonable values are not propagated. * Update pvl_perez.m Added comments. Thanks. * Update pvl_perez.m
1 parent 5f4bbea commit 6bfa16e

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

pvl_perez.m

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
% reflected irradiance or the irradiance due to the beam.
6262
% SkyDiffuse is a column vector vector with a number of elements equal to
6363
% the input vector(s).
64+
% User is warned if calculated SkyDiffuse is negative or greater than
65+
% extraterrestrial radiation; all outputs are NaN for unreasonable
66+
% calculated SkyDiffuse.
6467
% SkyDiffuse_Iso - the isotropic diffuse component of the solar radiation on an
6568
% arbitrarily tilted surface defined by the Perez model as given in
6669
% reference [3].
@@ -89,10 +92,10 @@
8992
% Solar Energy vol. 81. pp. 254-267.
9093
% [2] Perez, R., Seals, R., Ineichen, P., Stewart, R., Menicucci, D., 1987. A new
9194
% simplified version of the Perez diffuse irradiance model for tilted
92-
% surfaces. Solar Energy 39 (3), 221–232.
95+
% surfaces. Solar Energy 39 (3), 221–232.
9396
% [3] Perez, R., Ineichen, P., Seals, R., Michalsky, J., Stewart, R., 1990.
9497
% Modeling daylight availability and irradiance components from direct
95-
% and global irradiance. Solar Energy 44 (5), 271–289.
98+
% and global irradiance. Solar Energy 44 (5), 271–289.
9699
% [4] Perez, R. et. al 1988. The Development and Verification of the
97100
% Perez Diffuse Radiation Model,.SAND88-7030, Sandia National
98101
% Laboratories.
@@ -246,11 +249,21 @@
246249

247250
% SkyDiffuse(ebinfilter) = DHI(ebinfilter).* 0.5.* (1-F1(ebinfilter)).*(1+cosd(SurfTilt)) +...
248251
% F1(ebinfilter) .* A(ebinfilter)./ B(ebinfilter) + F2(ebinfilter).* sind(SurfTilt);
249-
con = (SkyDiffuse <= 0);
250-
SkyDiffuse(con) = 0;
251-
SkyDiffuse_Iso(con) = 0;
252-
SkyDiffuse_Cir(con) = 0;
253-
SkyDiffuse_Hor(con) = 0;
252+
% con = (SkyDiffuse <= 0);
253+
% SkyDiffuse(con) = 0;
254+
% SkyDiffuse_Iso(con) = 0;
255+
% SkyDiffuse_Cir(con) = 0;
256+
% SkyDiffuse_Hor(con) = 0;
257+
258+
% screen invalid SkyDiffuse and warn user
259+
idx = SkyDiffuse < 0 | SkyDiffuse > max(HExtra);
260+
if any(idx)
261+
SkyDiffuse(idx) = NaN;
262+
SkyDiffuse_Iso(idx) = NaN;
263+
SkyDiffuse_Cir(idx) = NaN;
264+
SkyDiffuse_Hor(idx) = NaN;
265+
warning('NaNs returned for SkyDiffuse < 0 or > max(HExtra).');
266+
end
254267

255268
SkyDiffuse = SkyDiffuse(:);
256269
SkyDiffuse_Iso = SkyDiffuse_Iso(:);
@@ -390,4 +403,4 @@
390403

391404
F1coeffs = PerezCoeffs(:,1:3);
392405
F2coeffs = PerezCoeffs(:,4:6);
393-
end
406+
end

0 commit comments

Comments
 (0)