#' Generates a Triangular Unit Hydrograph.
#'
#' @param r Rainfall Volume, in percent
#' @param t Time to Peak, in days
#' @param k Recession Constant
#'
#' @return Unit Hydrograph
#' @export
#'
#' @examples
#' plot(RTK(0.025,2,4), type="l")
RTK <- function(r,t,k) {
UH <- NULL
maxLength <- 30
h <- 2*r/t
m.up <- h/t
m.dn <- -h/((t*k))
for (i in 1:maxLength)
if (i>t) {
UH[i] <- m.dn*(i-t)+h
} else {
UH[i] <- m.up*i
}
UH[UH<0] <- 0
return(UH)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.