old_udout <- function(dtime_est,
waterlevel_ft,
orifice_height_ft,
orifice_diam_in,
#DEFAULT VALUES
discharge_coeff = 0.62){ #Orifice discharge coefficient
#1. Prepare data
#1.1 Initialize data frame
df <- tibble::tibble(dtime_est = lubridate::force_tz(dtime_est, tz = "EST"),
depth_ft = waterlevel_ft)#, #observed data
#elapsed_time_hr = 0,
#WL_above_orifice_ft = 0,
#slow_release_vol_ft3 = 0)
#2. Calculate Orifice Outflow
# Orifice equation:
# Q_orifice = C * Area * sqrt(2 * gravity * depth) * time
#2.1 Calculate area of orifice (ft2)
orifice_area_ft2 <- pi*((orifice_diam_in[1]/12)^2)/4 #area of orifice (ft2)
df <- df %>%
dplyr:: mutate(#2.2 calculate elapsed time (hrs)
elapsed_time_hr = difftime(dtime_est, dplyr::lag(dtime_est), units = "hours"), #difftime(lead(dtime_est), dtime_est, units = "hours"),
#2.3 Calculate height of water above orifice (ft)
WL_above_orifice_ft = depth_ft - orifice_height_ft[1],
#2.4 Set height of water to 0 if below elevation of orifice
WL_correction = ifelse(WL_above_orifice_ft < 0,0, WL_above_orifice_ft),
#2.4 Calculate total discharge through orifice
slow_release_ft3 = discharge_coeff*
orifice_area_ft2*
sqrt(2 * 32.2 * WL_correction) *
60*60 * #convert cfs to cfhr
as.numeric(elapsed_time_hr))
return(df$slow_release_ft3)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.