rvn_hyd_extract {RavenR}R Documentation

Extract function for Raven Hydrograph object

Description

rvn_hyd_extract is used for extracting data from the Raven hydrograph object. Works for objects passed from rvn_hyd_read function (which reads the Hydrographs.csv file produced by the modelling framework Raven).

Usage

rvn_hyd_extract(subs = NA, hyd = NA, prd = NULL, rename_cols = TRUE)

Arguments

subs

column name for plotting/extracting

hyd

full hydrograph data frame (including units) produced by rvn_hyd_read

prd

time period for plotting, as string. See details

rename_cols

boolean for whether to rename columns to generic terms (sim, obs, etc.) or leave column names as they appear in hyd

Details

Extracts the modelled and observed data from a Raven hydrograph 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 subbasin outflows, where the names will be of the form "subXX", for example "sub24".

The hyd object is the full hydrograph object (hyd and units in one data frame) created by the rvn_hyd_read function. Both the hyd 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.

Value

returns an xts object with sim, obs, inflow, and obs_inflow time series (if available)

sim

model simulation for specified column and period

obs

observed data for specified column and period

inflow

inflow simulation for specified column and period

obs_inflow

observed inflow simulation for specified column and period

See Also

rvn_hyd_read for reading in the Hydrographs.csv file and creating the object required in this function. rvn_hyd_plot for conveniently plotting the output object contents onto the same figure.

Examples

# read in hydrograph sample csv data from RavenR package
ff <- system.file("extdata","run1_Hydrographs.csv", package="RavenR")

# read in Raven Hydrographs file, store into myhyd
myhyd <- rvn_hyd_read(ff)

# no plot or observed data, specified period
flow_36 <- rvn_hyd_extract(subs="Sub36",myhyd)

attributes(flow_36)

# extract simulated and observed flows
sim <- flow_36$sim
obs <- flow_36$obs

# extract precipitation forcings
myprecip <- rvn_hyd_extract(subs="precip",hyd=myhyd)
myprecip <- myprecip$sim

# plot all components using rvn_hyd_plot
rvn_hyd_plot(sim,obs,precip=myprecip)


[Package RavenR version 2.2.2 Index]