Calculate annual flow statistics from daily data
calc_annual_flow_stats(
data = NULL,
Date,
year_group,
Q,
Q3 = NA_real_,
Q7 = NA_real_,
Q30 = NA_real_,
jd = NA_integer_,
calc_high = FALSE,
calc_low = FALSE,
calc_percentiles = FALSE,
calc_monthly = FALSE,
calc_WSCVD = FALSE,
longitude = NA,
calc_ICVD = FALSE,
zero_threshold = 33,
quantile_type = 8,
na.action = c("na.omit", "na.pass")
)A tibble (see tibble::tibble) with annual statistics depending on options selected.
See Details.
'data.frame'. Optional data.frame input, with columns containing Date,
year_group, Q, and Q3, Q7, Q30, jd (if required). Column names are specified as strings
in the corresponding parameter. Default is NULL.
'Date' or 'character' vector when data = NULL, or character' string identifying
Date column name when data is specified. Date associated with each value in Q parameter.
'numeric' vector when data = NULL, or 'character' string identifying
grouping column name when data is specified. Year grouping for each daily value in Q
parameter. Must be same length as Q parameter. Often year_group is water year or climate
year.
'numeric' vector when data = NULL, or 'character' string identifying streamflow values
column name when data is specified. Daily streamflow data. Must be same length as year_group.
'numeric' vector when data = NULL, or 'character' string identifying Q3 column name
when data is specified. 3-day moving average of daily streamflow data Q parameter, often
returned from preproc_precondition_data. Default is NA_real_, required if calc_high or
calc_low = TRUE. If specified, must be same length as Q parameter.
'numeric' vector when data = NULL, or 'character' string identifying Q7 column name
when data is specified. 7-day moving average of daily streamflow data Q parameter, often
returned from preproc_precondition_data. Default is NA_real_, required if calc_high or
calc_low = TRUE. If specified, must be same length as Q parameter.
'numeric' vector when data = NULL, or 'character' string identifying Q30 column name
when data is specified. 30-day average of daily streamflow data Q parameter, often returned
from preproc_precondition_data. Default is NA_real_, required if calc_high or
calc_low = TRUE. If specified, must be same length as Q parameter.
'numeric' vector when data = NULL, or 'character' string identifying jd column name
when data is specified. Calendar Julian day of daily streamflow data Q parameter, often
returned from preproc_precondition_data. Default is NA_integer_, required if calc_high,
calc_low, calc_WSCVD or calc_ICVD = TRUE. If specified, must be same length as Q
parameter.
'boolean' value. Calculate high flow statistics for years in year_group.
Default is FALSE. See Details for more information.
'boolean' value. Calculate low flow statistics for years in year_group.
Default is FALSE. See Details for more information.
'boolean' value. Calculate percentiles for years in year_group.
Default is FALSE. See Details for more information.
'boolean' value. Calculate monthly statistics for years in year_group.
Default is FALSE. See Details for more information.
'boolean' value. Calculate winter-spring center volume date for years in
year_group. Default is FALSE. See Details for more information.
'numeric' value. Site longitude in North American Datum of 1983 (NAD83),
required in WSCVD calculation. Default is NA. See Details for more information.
'boolean' value. Calculate inverse center volume date for years in year_group.
Default is FALSE. See Details for more information.
'numeric' value as percentage. The percentage of years of a statistic that
need to be zero in order for it to be deemed a zero flow site for that statistic. For use in
trend calculation. See Details on attributes. Default is 33 (33 percent) of the
annual statistic values.
'numeric' value. The distribution type used in the stats::quantile
function. Default is 8 (median-unbiased regardless of distribution). Other
types common in hydrology are 6 (Weibull) or 9 (unbiased for normal distributions).
'character' string indicating na.action passed to stats::aggregate
na.action parameter. Default is "na.omit", which removes NA values before aggregating
statistics, or "na.pass", which will pass NA values and return NA in the grouped calculation
if any NA values are present.
year_group is commonly water year, climate year, or calendar year.
Default annual statistics returned:
annual_meanannual mean in year_group
annual_sdannual standard deviation in year_group
annual_sumannual sum in year_group
If calc_high/low are selected, annual statistics returned:
1-, 3-, 7-, and 30-day high/low and Julian date (jd) of n-day high/low.
high_qnwhere n = 1, 3, 7, and 30
high_qn_jdwhere n = 1, 3, 7, and 30
low_qnwhere n = 1, 3, 7, and 30
low_qn_jdwhere n = 1, 3, 7, and 30
If calc_percentiles is selected, annual statistics returned:
1, 5, 10, 25, 50, 75, 90, 95, 99 percentile based on daily streamflow.
annual_n_percentilewhere n = 1, 5, 10, 25, 50, 75, 90, 95, and 99
If calc_monthly is selected, annual statistics returned:
Monthly mean, standard deviation, max, min, percent of annual for each month in year_group.
_meanmonthly mean, where month = month.abb
_sdmonthly standard deviation, where month = month.abb
_maxmonthly maximum, where month = month.abb
_minmonthly minimum, where month = month.abb
_percent_annualmonthly percent of annual, where month = month.abb
If calc_WSCVD is selected, Julian date of annual winter-spring center volume date is returned.
Longitude (in NAD83 datum) is used to determine the ending month of spring. July for longitudes
West of \(-\)95 degrees, May for longitudes east of \(-\)95 degrees. See References
Dudley and others, 2017. Commonly calculated when year_group is water year.
WSCVDJulian date of winter-spring center volume
If calc_ICVD is selected, Julian date of annual inverse center volume date is returned.
Commonly calculated when year_group is climate year.
ICVDJulian date of inverse center volume date
Attribute: zero_flow_years
A data.frame with each annual statistic calculated, the percentage of years where the
statistic = 0, a flag indicating if the percentage is over the zero_threshold parameter,
and the number of years with a zero value. Columns in zero_flow_years:
annual_statannual statistic
percent_zerospercentage of years with 0 statistic value
over_thresholdboolean if percentage is over threshold
number_yearsnumber of years with 0 value statistic
The zero_flow_years attribute can be useful in trend calculation, where a trend may not be
appropriate to calculate with many zero flow years.
Dudley, R.W., Hodgkins, G.A, McHale, M.R., Kolian, M.J., Renard, B., 2017, Trends in snowmelt-related streamflow timing in the conterminous United States: Journal of Hydrology, v. 547, p. 208-221. [Also available at https://doi.org/10.1016/j.jhydrol.2017.01.051.]
preproc_precondition_data
calc_annual_flow_stats(data = example_preproc, Date = "Date", year_group = "WY", Q = "value")
Run the code above in your browser using DataLab