Calculates the median annual ldc with confidence intervals.
Arguments
- .tbl
data frame with at least three columns Q (discharge or flow), C (associated pollutant concentration), and Date.
- Q
variable name in .tbl for discharge or flow. This must be of class `units`, typically with a units value of "ft^3/s".
- C
variable name in .tbl for associated pollutant concentration at a given flow value. This must be of class `units`, typically with a units value of "mg/L" or "cfu/100mL".
- Date
variable name in .tbl for the event Date. This variable must be of class `Date`.
- allowable_concentration
an object of class
units
specifying the allowable pollutant concentration.- breaks
a numeric vector of break points for flow categories. Must be of length of labels + 1. defaults to
c(1, 0.8, 0.4, 0)
.- labels
labels for the categories specified by breaks.
- conf_level
numeric, confidence level (default is 0.9) of the median interval at given exceedance probability.
- estimator
one of
c(5,6,7,8,9,"hd")
.6
is the default method correponding to the Weibull plotting position. Further details are provided inquantile
."hd"
uses the Harrell-Davis Distribution-Free Quantile Estimator (see:hdquantile
).- n
numeric, the length of generated probability points. Larger n may result in a slightly smoother curve at a cost of increased processing time. The probability points are used to generate the continuous sample quantiles types 5 to 9 (see
quantile
).
Value
list of two tibbles (Q and C). Includes variables in .tbl and Daily_Flow_Volume (discharge volume), Daily_Load (pollutant sample volume), P_Exceedance (exeedance probability), Flow_Category (as defined by breaks and labels).
Details
The median annual ldc is calculated by computing the flow duration curve for each individual year in the dataset. Exceedance probabilities are calculated from the descending order of Daily Flows. By default, the Weibull plotting position is used: $$p = P(Q > q_i) = \frac{i}{n+1}$$ where \(q_i, i = 1, 2, ... n\), is the i-th sorted streamflow value.
The median streamflow +/- chosen confidence interval is calculated at each exceedance probability. The load duration curve is calculated by multiplying the median streamflow by the allowable concentration and appropriate conversions.
References
Vogel, Richard M., and Neil M. Fennessey. "Flow-duration curves. I: New interpretation and confidence intervals." Journal of Water Resources Planning and Management 120, no. 4 (1994): 485-504. doi: 10.1061/(ASCE)0733-9496(1994)120:4(485)
Examples
# Basic example using built in Tres Palacios data
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
library(units)
#> udunits database from /usr/share/xml/udunits/udunits2.xml
# Format data
install_unit("cfu")
df <- as_tibble(tres_palacios) %>%
## filter data so this run quicker
filter(!is.na(Indicator_Bacteria)) %>%
## flow must have units, here is is in cfs
mutate(Flow = set_units(Flow, "ft^3/s")) %>%
## pollutant concentration must have units
mutate(Indicator_Bacteria = set_units(Indicator_Bacteria, "cfu/100mL"))
# Calculate LDC
## specify the allowable concentration
allowable_concentration <- 126
## set the units
units(allowable_concentration) <- "cfu/100mL"
df_ldc <- calc_annual_ldc(df,
Q = Flow,
C = Indicator_Bacteria,
Date = Date,
allowable_concentration = allowable_concentration,
estimator = 5,
n = 1000)
df_ldc$Q
#> # A tibble: 1,000 × 11
#> P_Exceedance median_Q lwr.ci_Q upr.ci_Q median_Daily_Flow_V… lwr.ci_Daily_Fl…
#> <dbl> [ft^3/s] [ft^3/s] [ft^3/s] [100mL/d] [100mL/d]
#> 1 0.000500 29.3 23.8 66.5 716846635. 582284980.
#> 2 0.00150 29.3 23.8 66.5 716846635. 582284980.
#> 3 0.00250 29.3 23.8 66.5 716846635. 582284980.
#> 4 0.00350 29.3 23.8 66.5 716846635. 582284980.
#> 5 0.00450 29.3 23.8 66.5 716846635. 582284980.
#> 6 0.00550 29.3 23.8 66.5 716846635. 582284980.
#> 7 0.00650 29.3 23.8 66.5 716846635. 582284980.
#> 8 0.00750 29.3 23.8 66.5 716846635. 582284980.
#> 9 0.00850 29.3 23.8 66.5 716846635. 582284980.
#> 10 0.00950 29.3 23.8 66.5 716846635. 582284980.
#> # … with 990 more rows, and 5 more variables:
#> # upr.ci_Daily_Flow_Volume [100mL/d], median_Allowable_Daily_Load [cfu/d],
#> # lwr.ci_Allowable_Daily_Load [cfu/d], upr.ci_Allowable_Daily_Load [cfu/d],
#> # Flow_Category <fct>
## cleanup
remove_unit("cfu")