Source code for src.functions.SOLWEIGpython.sunlit_shaded_patches
importnumpyasnp
[docs]defshaded_or_sunlit(solar_altitude,solar_azimuth,patch_altitude,patch_azimuth,asvf):''' This unchanged function calculates whether a point is sunlit or shaded based on a sky view factor (in a cylinder), solar altitude, solar azimuth '''# Patch azimuth in relation to sun azimuthpatch_to_sun_azi=np.abs(solar_azimuth-patch_azimuth)# Degrees to radiansdeg2rad=np.pi/180# Radians to degreesrad2deg=180/np.pi# xi=np.cos(patch_to_sun_azi*deg2rad)# yi=2*xi*np.tan(solar_altitude*deg2rad)hsvf=np.tan(asvf)ifyi>0:yi_=0else:yi_=yi# tan_delta=hsvf+yi_# Degrees where below is in shade and above is sunlitsunlit_degrees=np.arctan(tan_delta)*rad2deg# Boolean for pixels where patch is sunlitsunlit_patches=sunlit_degrees<patch_altitude# Boolean for pixels where patch is shadedshaded_patches=sunlit_degrees>patch_altitudereturnsunlit_patches,shaded_patches