gr_separate: Advanced hydrograph separation

View source: R/separate.R

gr_separateR Documentation

Advanced hydrograph separation

Description

Separates the runoff into genetic components: groundwater, thaw, rain and spring.

Usage

gr_separate(df, params = gr_get_params(), debug = FALSE)

Arguments

df

data.frame with four columns: date, runoff, temperature, precipitation.

params

list of separation parameters, as returned by gr_get_params() function. Can also be a list of such lists if modified parameters are required for some years. In this case the length of params must be equal to the number of calendar years in df or be equal to 1.

debug

Boolean. If TRUE then additional attributes jittered and params are written to the output data.frame. jittered is an integer vector of years for which the separation parameters were randomly jittered. params is a list of separation parameter lists used for each year (some o those may have been jittered). Defaults to FALSE.

Value

A data.frame with 11 columns:

Column Description
Date date
Q total runoff
Temp temperature
Prec precipitation
Qbase baseflow
Quick quickflow
Qspri spring flood
Qrain rain floods
Qthaw thaw floods
Season a season of the year
Year a water-resources year

Examples

library(grwat)

data(spas) # example Spas-Zagorye data is included with grwat package
head(spas)

# separate
sep = gr_separate(spas, params = gr_get_params(reg = 'center'))

# Visualize
gr_plot_sep(sep, c(1978, 1989)) 

# Debug mode gives access to additional information
sep_debug = gr_separate(spas, 
                        params = gr_get_params(reg = 'center'), 
                        debug = TRUE)

# a vector of years with jittered params
jit = attributes(sep_debug)$jittered
print(jit)

# actual params used for each year
parlist = attributes(sep_debug)$params
partab = do.call(dplyr::bind_rows, parlist) # View as table
head(partab)

# extract and tweak parameters for selected year
p = parlist[['1989']]
p$grad1 = 1
p$grad2 = 2.5

# use tweaked parameters for all years
sep_debug = gr_separate(spas, params = p, debug = TRUE)

# Visualize
gr_plot_sep(sep_debug, c(1978, 1989)) 

# actual params used for each year
parlist = attributes(sep_debug)$params

# tweak parameters for selected year
parlist[['1989']]$grad1 = 3
parlist[['1989']]$grad2 = 6

# set the sprecdays parameter for multiple years
parlist = gr_set_param(parlist, sprecdays, 
                       years = c(1978, 1989:1995), 
                       value = 15)

# set the spcomp parameter for all years
parlist = gr_set_param(parlist, spcomp, value = 2.5)

# use the list of parameters for separation
sep_debug = gr_separate(spas, params = parlist, debug = TRUE)

# Visualize
gr_plot_sep(sep_debug, c(1978, 1989))




grwat documentation built on Nov. 2, 2023, 5:21 p.m.