Introduction to grwat R package

Timofey Samsonov

2025年10月02日

Example data

Throughout grwat package documentation a sample dataset spas containing the daily runoff data for Spas-Zagorye gauge on Protva river in Central European plane is used. The dataset is supplemented by meteorological variables (temperature and precipitation) obtained from CIRES-DOE (1880-1949) and ERA5 (1950-2021) data averaged inside gauge’s basin:

 library(grwat)
 library(dplyr)
 library(ggplot2)
 library(lubridate)
 
 data(spas)
 head(spas)
 #> # A tibble: 6 ×ばつ 4
 #> Date Q Temp Prec
 #> <date> <dbl> <dbl> <dbl>
 #> 1 1956年01月01日 5.18 -6.46 0.453
 #> 2 1956年01月02日 5.18 -11.4 0.825
 #> 3 1956年01月03日 5.44 -10.7 0.26 
 #> 4 1956年01月04日 5.44 -8.05 0.397
 #> 5 1956年01月05日 5.44 -11.7 0.102
 #> 6 1956年01月06日 5.58 -20.1 0.032

This 4-column representation is standard for advanced separation discussed below.

Baseflow filtering

For more information on baseflow filtering, read the Baseflow filtering vignette.

grwat implements several methods for baseflow filtering. The get_baseflow() function does the job:

Qbase = gr_baseflow(spas$Q, method = 'lynehollick', a = 0.925, passes = 3)
 head(Qbase)
 #> [1] 3.698598 3.789843 3.876099 3.958334 4.037031 4.112454

Though get_baseflow() needs just a vector of runoff values, it can be applied in a traditional tidyverse pipeline like follows:

 # Calculate baseflow using Jakeman approach
hdata = spas |> 
 mutate(Qbase = gr_baseflow(Q, method = 'jakeman'))
 
 # Visualize for 2020 year
 ggplot(hdata) +
 geom_area(aes(Date, Q), fill = 'steelblue', color = 'black') +
 geom_area(aes(Date, Qbase), fill = 'orangered', color = 'black') +
 scale_x_date(limits = c(ymd(19800101), ymd(19801231)))
 #> Warning: Removed 23376 rows containing non-finite outside the scale range
 #> (`stat_align()`).
 #> Removed 23376 rows containing non-finite outside the scale range
 #> (`stat_align()`).

Advanced hydrograph separation

For more information on advanced separation, read the Advanced separation vignette.

Advanced separation by gr_separate() implements the method by (Rets et al. 2022), which involves additional data on temperatures and precipitation to detect and classify flood events into the rain, thaw and spring (seasonal thaw). Between these events \(100\%\) of the runoff is considered to be ground. Inside those events the ground flow is filtered either by one of the baseflow functions, or by Kudelin’s method, which degrades baseflow to \(0\) under the maximum runoff value during the year.

The method is controlled by more than 20 parameters, which can be region-specific. Therefore, to ease the management and distribution of these parameters, they are organized as list, as returned by gr_get_params():

sep = gr_separate(spas, params = gr_get_params(reg = 'center'))
 #> grwat: data frame is correct
 #> grwat: parameters list and types are OK
 head(sep)
 #> # A tibble: 6 ×ばつ 11
 #> Date Q Temp Prec Qbase Quick Qspri Qrain Qthaw Season Year
 #> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <int>
 #> 1 1956年01月01日 5.18 -6.46 0.453 NA NA NA NA NA NA NA
 #> 2 1956年01月02日 5.18 -11.4 0.825 NA NA NA NA NA NA NA
 #> 3 1956年01月03日 5.44 -10.7 0.26 NA NA NA NA NA NA NA
 #> 4 1956年01月04日 5.44 -8.05 0.397 NA NA NA NA NA NA NA
 #> 5 1956年01月05日 5.44 -11.7 0.102 NA NA NA NA NA NA NA
 #> 6 1956年01月06日 5.58 -20.1 0.032 NA NA NA NA NA NA NA

Resulting separation can be visualized by gr_plot_sep() function. In addition to classification of the flow, the function shows the dates of the spring seasonal flood:

 gr_plot_sep(sep, years = c(1978, 1989))

Summaries

For more information on annual variables, read the Summaries vignette.

After hydrograph is separated, its characteristics can be summarized by gr_summarize() into annual variables which characterize the annual runoff, its components (ground, spring, rain and thaw) and low flow periods (summer and winter):

vars = gr_summarize(sep)
 head(vars)
 #> # A tibble: 6 ×ばつ 57
 #> Year Year1 Year2 Dspstart Dspend Tsp Qy Qspmax Dspmax Qygr
 #> <dbl> <dbl> <dbl> <date> <date> <int> <dbl> <dbl> <date> <dbl>
 #> 1 1956 1956 1957 1956年04月08日 1956年05月05日 27 18.4 467 1956年04月22日 8.59
 #> 2 1957 1957 1958 1957年03月25日 1957年05月04日 40 20.2 460 1957年04月08日 9.77
 #> 3 1958 1958 1959 1958年04月02日 1958年05月13日 41 27.3 537 1958年04月21日 10.2 
 #> 4 1959 1959 1960 1959年03月28日 1959年04月28日 31 27.1 406 1959年04月16日 10.9 
 #> 5 1960 1960 1961 1960年03月27日 1960年04月27日 31 29.6 406 1960年04月15日 12.3 
 #> 6 1961 1961 1962 1961年03月07日 1961年05月02日 56 18.8 296 1961年04月10日 10.8 
 #> # i 47 more variables: Qsmin <dbl>, Dsmin <date>, Qwmin <dbl>, Dwmin <date>,
 #> # Q30s <dbl>, D30s1 <date>, D30s2 <date>, Q30w <dbl>, D30w1 <date>,
 #> # D30w2 <date>, Q10s <dbl>, D10s1 <date>, D10s2 <date>, Q10w <dbl>,
 #> # D10w1 <date>, D10w2 <date>, Q5s <dbl>, D5s1 <date>, D5s2 <date>, Q5w <dbl>,
 #> # D5w1 <date>, D5w2 <date>, Wy <dbl>, Wygr <dbl>, Wsp <dbl>, Wspgr <dbl>,
 #> # Wsprngr <dbl>, Wrn <dbl>, Wrngr <dbl>, Wth <dbl>, Wthgr <dbl>, Wgrs <dbl>,
 #> # Ws <dbl>, Wgrw <dbl>, Ww <dbl>, Qrnmax <dbl>, Qthmax <dbl>, ...

These characteristics can be plotted by gr_plot_vars():

 gr_plot_vars(vars, Qygr)
 #> Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
 #> i Please use tidy evaluation idioms with `aes()`.
 #> i See also `vignette("ggplot2-in-packages")` for more information.
 #> i The deprecated feature was likely used in the grwat package.
 #> Please report the issue at <https://github.com/tsamsonov/grwat/issues>.
 #> This warning is displayed once every 8 hours.
 #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
 #> generated.
 #> Warning: Removed 1 row containing non-finite outside the scale range
 #> (`stat_smooth()`).
 #> Warning: Removed 1 row containing missing values or values outside the scale range
 #> (`geom_ribbon()`).
 gr_plot_vars(vars, D10w1, Wsprngr, Nthw, Qrnmax, tests = TRUE,
 layout = matrix(1:4, nrow = 2, byrow = TRUE)) 
 #> Warning: Removed 1 row containing non-finite outside the scale range
 #> (`stat_smooth()`).
 #> Warning: Removed 1 row containing missing values or values outside the scale range
 #> (`geom_point()`).
 #> Warning: Removed 1 row containing non-finite outside the scale range
 #> (`stat_smooth()`).
 #> Warning: Removed 1 row containing missing values or values outside the scale range
 #> (`geom_ribbon()`).
 #> Warning: Removed 1 row containing non-finite outside the scale range (`stat_smooth()`).
 #> Removed 1 row containing non-finite outside the scale range (`stat_smooth()`).
 #> Warning: Removed 1 row containing missing values or values outside the scale range
 #> (`geom_ribbon()`).

Additional features

grwat contains some useful functions that can facilitate your work with runoff data. In particular:

References

Rets, E. P., M. B. Kireeva, T. E. Samsonov, N. N. Ezerova, A. V. Gorbarenko, and N. L. Frolova. 2022. "Algorithm Grwat for Automated Hydrograph Separation by B. I. Kudelins Method: Problems and Perspectives." Water Resources 49 (1): 23–37.

AltStyle によって変換されたページ (->オリジナル) /