Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def aoi_projection(surf_tilt, surf_az, sun_zen, sun_az):
"""
Calculates the dot product of the solar vector and the surface normal.
Input all angles in degrees.
:param surf_tilt: float or Series. Panel tilt from horizontal.
:param surf_az: float or Series. Panel azimuth from north.
:param sun_zen: float or Series. Solar zenith angle.
:param sun_az: float or Series. Solar azimuth angle.
:returns: float or Series. Dot product of panel normal and solar angle.
"""
projection = pvl_tools.cosd(surf_tilt)*pvl_tools.cosd(sun_zen) + pvl_tools.sind(surf_tilt)*pvl_tools.sind(sun_zen)*pvl_tools.cosd(sun_az - surf_az)
try:
projection.name = 'aoi_projection'
except AttributeError:
pass
return projection
# ratio of titled and horizontal beam irradiance
# Will H: is this to avoid / 0? Shouldn't it be element-wise?
#Rb = np.max(cos_tt, 0) / np.max(pvl_tools.cosd(sun_zen), 0.01745)
Rb = cos_tt / cos_sun_zen
# Anisotropy Index
AI = DNI / DNI_ET
# DNI projected onto horizontal
HB = DNI * cos_sun_zen
HB[HB < 0] = 0
# these are actually the () and [] sub-terms of the second term of eqn 8
term1 = 1 - AI
term2 = 0.5 * (1 + pvl_tools.cosd(surf_tilt))
term3 = 1 + np.sqrt(HB / GHI) * (pvl_tools.sind(0.5*surf_tilt) ** 3)
sky_diffuse = DHI * ( AI*Rb + term1 * term2 * term3 )
sky_diffuse[sky_diffuse < 0] = 0
return sky_diffuse