# Function "heatload" # Calculates heat load or potential annual direct incident radiation, using the formulas published in # McCune & Keon (2002) based on aspect, slope and latitude. heatload <- function (aspect, slope, latitude, method = 'heatload', units = 'degrees', equation = 1) { if (units == 'degrees') # convert degrees to radians { aspect <- aspect/180*pi slope <- slope/180*pi aspect[slope == 0] <- 0 latitude <- latitude/180*pi } A <- if (method == 'heatload') abs (pi - abs (aspect - (5*pi/4))) else pi - abs (aspect-pi) S <- slope L <- if (length (latitude) == 1) rep (latitude, length (A)) else latitude if (equation == 1) res <- exp (-1.467 +1.582*cos(L)*cos(S) -1.500*cos(A)*sin(S)*sin(L) -0.262*sin(L)*sin(S) +0.607*sin(A)*sin(S)) if (equation == 2) res <- exp (-1.236 +1.350*cos(L)*cos(S) -1.376*cos(A)*sin(S)*sin(L) -0.331*sin(L)*sin(S) +0.375*sin(A)*sin(S)) if (equation == 3) res <- +0.339 +0.808*cos(L)*cos(S) -0.196*sin(L)*sin(S) - 0.482*cos(A)*sin(S) return (res) }