##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function(lat,Jday){
# potential solar radiation at the edge of the atmospher [kJ m-2 d-1]
#lat: latitdue [rad]
#Jday: Julian date or day of the year [day]
# solar declination [rad]
dec<-declination(Jday)
return(117500*(acos(-tan(dec)*tan(lat))*sin(lat)*sin(dec)+cos(lat)*cos(dec)*sin(acos(tan(dec)*tan(lat))))/pi)
}Run the code above in your browser using DataLab