Skip to content

Commit 085d017

Browse files
committed
Comment and minor optimizations
1 parent 346d060 commit 085d017

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pvlib/shading.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,18 +272,24 @@ def projected_solar_zenith_angle(surface_tilt, surface_azimuth,
272272
Progress in Photovoltaics: Research and Applications, vol. 19, no. 6,
273273
pp. 747–753, 2011, :doi:`10.1002/pip.1085`.
274274
"""
275-
# Notation from [1]
276-
sx = cosd(solar_apparent_elevation) * sind(solar_azimuth)
277-
sy = cosd(solar_apparent_elevation) * cosd(solar_azimuth)
278-
sz = sind(solar_apparent_elevation)
275+
# Avoid recalculating these values
276+
cosd_solar_apparent_elevation = cosd(solar_apparent_elevation)
279277
cosd_surface_azimuth = cosd(surface_azimuth)
280278
sind_surface_azimuth = sind(surface_azimuth)
281279
sind_surface_tilt = sind(surface_tilt)
280+
281+
# Notation from [1]
282+
# Sun's x, y, z coords
283+
sx = cosd_solar_apparent_elevation * sind(solar_azimuth)
284+
sy = cosd_solar_apparent_elevation * cosd(solar_azimuth)
285+
sz = sind(solar_apparent_elevation)
286+
# Eq. (4); sx', sz' values from sun coordinates projected onto surface
282287
sx_prime = sx * cosd_surface_azimuth - sy * sind_surface_azimuth
283288
sz_prime = (
284289
sx * sind_surface_azimuth * sind_surface_tilt
285290
+ sy * sind_surface_tilt * cosd_surface_azimuth
286291
+ sz * cosd(surface_tilt)
287292
)
293+
# Eq. (5); angle between sun's beam and surface
288294
theta_T = np.degrees(np.arctan2(sx_prime, sz_prime))
289295
return theta_T

0 commit comments

Comments
 (0)