[docs]defclearnessindex_2013b(zen,jday,Ta,RH,radG,location,P):""" Unchanged function: Clearness Index at the Earth's surface calculated from Crawford and Duchon 1999 :param zen: zenith angle in radians :param jday: day of year :param Ta: air temperature :param RH: relative humidity :param radG: global shortwave radiation :param location: distionary including lat, lon and alt :param P: pressure """ifP==-999.0:p=1013.# Pressure in millibarselse:p=P*10.# Convert from hPa to millibarsItoa=1370.0# Effective solar constantD=sun_distance.sun_distance(jday)# irradiance differences due to Sun-Earth distancesm=35.*np.cos(zen)*((1224.*(np.cos(zen)**2)+1)**(-1/2.))# optical air mass at p=1013Trpg=1.021-0.084*(m*(0.000949*p+0.051))**0.5# Transmission coefficient for Rayliegh scattering and permanent gases# empirical constant depending on latitudeiflocation['latitude']<10.:G=[3.37,2.85,2.80,2.64]eliflocation['latitude']>=10.andlocation['latitude']<20.:G=[2.99,3.02,2.70,2.93]eliflocation['latitude']>=20.andlocation['latitude']<30.:G=[3.60,3.00,2.98,2.93]eliflocation['latitude']>=30.andlocation['latitude']<40.:G=[3.04,3.11,2.92,2.94]eliflocation['latitude']>=40.andlocation['latitude']<50.:G=[2.70,2.95,2.77,2.71]eliflocation['latitude']>=50.andlocation['latitude']<60.:G=[2.52,3.07,2.67,2.93]eliflocation['latitude']>=60.andlocation['latitude']<70.:G=[1.76,2.69,2.61,2.61]eliflocation['latitude']>=70.andlocation['latitude']<80.:G=[1.60,1.67,2.24,2.63]eliflocation['latitude']>=80.andlocation['latitude']<90.:G=[1.11,1.44,1.94,2.02]ifjday>335orjday<=60:G=G[0]elifjday>60andjday<=152:G=G[1]elifjday>152andjday<=244:G=G[2]elifjday>244andjday<=335:G=G[3]# dewpoint calculationa2=17.27b2=237.7Td=(b2*(((a2*Ta)/(b2+Ta))+np.log(RH)))/(a2-(((a2*Ta)/(b2+Ta))+np.log(RH)))Td=(Td*1.8)+32# Dewpoint (F)u=np.exp(0.1133-np.log(G+1)+0.0393*Td)# Precipitable waterTw=1-0.077*((u*m)**0.3)# Transmission coefficient for water vaporTar=0.935**m# Transmission coefficient for aerosolsI0=Itoa*np.cos(zen)*Trpg*Tw*D*Tarifabs(zen)>np.pi/2:I0=0# b=I0==abs(zen)>np.pi/2# I0(b==1)=0# clear b;ifnot(np.isreal(I0)):I0=0corr=0.1473*np.log(90-(zen/np.pi*180))+0.3454# 20070329CIuncorr=radG/I0CI=CIuncorr+(1-corr)I0et=Itoa*np.cos(zen)*D# extra terrestial solar radiationKt=radG/I0etifmath.isnan(CI):CI=float('Inf')returnI0,CI,Kt,I0et,CIuncorr