rvn_res_extract is used for extracting data from the Raven reservoir object.
Works for objects from rvn_res_read
function (for reading in the ReservoirStages.csv
file).
rvn_res_extract(subs = NA, res = NA, prd = NULL)
column name for plotting/extracting
full reservoir data frame (including units) produced by res.read
time period for plotting, as string. See details
model simulation for specified column and period
observed data for specified column and period
inflow simulation for specified column and period
Extracts the modelled and observed data from a Raven reservoir object by name reference. It is also easy to create plots of modelled and observed data using this function. The simulated and observed files are outputted regardless of whether a plot is created, for the specified period.
The subs input is the name of the column desired for use; the most common use of this will be for subbasins, where the names will be of the form "subXX", for example "sub24".
The res object is the full reservoir object (res and units in one data frame) created by the res.read function. Both the res and units are required, since the units are placed onto the plots if one is created. This is useful to at least see the units of the plotted variable, even if the plot is later modified.
The prd input is used to specify a period for the plot and/or the data output. The period should be specified as a string start and end date, of the format "YYYY-MM-DD/YYYY-MM-DD", for example, "2006-10-01/2010-10-01". If no period is supplied, the entire time series will be used.
rvn_res_read
for reading in the Reservoirs.csv file and
creating the object required in this function. rvn_res_plot
for
plotting the extracted stage time series
ff <- system.file("extdata","ReservoirStages.csv", package="RavenR")
# Read in Raven Reservoirs file, store into myres
myres <- rvn_res_read(ff)
# Extract stage using this function
stage36 <- rvn_res_extract(subs="sub36",res=myres,prd="2002-10-01/2003-10-01")
summary(stage36)
#> Length Class Mode
#> sim 366 xts numeric
#> obs 366 xts numeric
#> inflow 0 -none- NULL
summary(stage36$sim)
#> Index sub36
#> Min. :2002-10-01 00:00:00 Min. :206.6
#> 1st Qu.:2002-12-31 06:00:00 1st Qu.:209.4
#> Median :2003-04-01 12:00:00 Median :210.1
#> Mean :2003-04-01 12:00:00 Mean :210.8
#> 3rd Qu.:2003-07-01 18:00:00 3rd Qu.:214.4
#> Max. :2003-10-01 00:00:00 Max. :215.1
# Example for precipitation
precip <- rvn_res_extract(subs="precip",res=myres)