Creates a reservoir stage plot for the supplied stage series.
rvn_res_plot(
sim = NULL,
obs = NULL,
precip = NULL,
prd = NULL,
winter_shading = FALSE,
wsdates = c(12, 1, 3, 31)
)
time series object of simulated stage
time series object of observed stage
time series object of precipitation
period to use in plotting
optionally adds shading for winter months (default FALSE
)
integer vector of winter shading period dates (see details)
returns ggplot plot object
Creates a reservoir stage plot using the supplied time series; any series not supplied will not be plotted. If the precip time series is supplied, the secondary y axis will be used to plot the precip time series.
The function assumes that the supplied time series have the same length and
duration in time. If this is not true, then the defined period or period
calculated from the first available stage series will be used to determine
the plotting limits in time. If the data is used directly from Raven output,
this is not a concern. The supplied time series should be in xts format,
which again can be obtained directly by using the rvn_res_extract
function.
The winter_shading argument will add a transparent grey shading for the December 1st to March 31st period in each year that is plotted (or other period specified by wsdates).
wsdates is formatted as c(winter start month, winter start day, winter end month, winter end day).
rvn_hyd_read
for reading in the Hydrographs.csv file, and
rvn_res_extract
to extract time series from Raven objects
# read in sample reservoir file
ff <- system.file("extdata","ReservoirStages.csv", package="RavenR")
rvn_res_read(ff) %>%
rvn_res_extract(subs="sub36", res=.) -> mystage
sim <- mystage$sim
obs <- mystage$obs
precip <- rvn_res_read(ff)$res$precip
# create a nice reservoir stage plot
rvn_res_plot(sim,obs)
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_line()`).
# create a reservoir stage plot with precip as well
rvn_res_plot(sim,obs,precip=precip)
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_bar()`).
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_line()`).
# create a reservoir stage plot with precip as well for a specific subperiod
prd <- "2003-10-01/2005-10-01"
rvn_res_plot(sim,obs,precip=precip,prd=prd)
# add winter shading
rvn_res_plot(sim,obs,precip=precip, winter_shading=TRUE)
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_bar()`).
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_line()`).