R/get_day_length.R

Defines functions get_day_length

Documented in get_day_length

get_day_length <-
function(lat, day) {
  lat[lat > 90 | lat < -90] <- NA 
  P <- asin(0.39795 * cos(0.2163108 + 2 * atan(0.9671396 * tan(0.00860*(day-186)))))
  a <- (sin(0.8333 * pi/180) + sin(lat * pi/180) * sin(P)) / (cos(lat * pi/180) * cos(P))
  a <- pmin(pmax(a, -1), 1)
  day_length <- 24 - (24/pi) * acos(a)
  return(day_length)
}

Try the phenModel package in your browser

Any scripts or data that you put into this service are public.

phenModel documentation built on Aug. 2, 2019, 5:05 p.m.