rvn_rvt_obsweights {RavenR}R Documentation

Create Raven observation data weight (rvt) file

Description

Writes observation weights generated from rvn_gen_obsweights to a Raven rvt format.

Usage

rvn_rvt_obsweights(
  filename = "_obsweights.rvt",
  wts,
  SBID = 1,
  typestr = "HYDROGRAPH"
)

Arguments

filename

observation data file to be created, with .rvt extension

wts

xts time series with single data column of observation weights

SBID

Subbasin ID for hydrographs and reservoir stages or HRU ID for observations of state variables (e.g., snow depth)

typestr

Raven-recognized data type string: 'HYDROGRAPH', 'RESERVOIR_STAGE', 'RESERVOIR_INFLOW', 'RESERVOIR_NET_INFLOW', or a state variable name (e.g., SOIL[0] or SNOW)

Details

Any NA values in the weights are converted to the flag -1.2345, used in Raven as NA values.

Value

TRUE returns TRUE if function runs properly

Author(s)

James R. Craig, University of Waterloo

See Also

rvn_rvt_obsfile rvn_gen_obsweights

Examples

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

 # read in Raven Hydrographs file, store into mydata
 mydata <- rvn_hyd_read(ff, tzone="EST")

 # generate rvt file using just observations from Subbasin ID 36
 flows <- rvn_ts_infill(mydata$hyd$Sub36_obs)
 rvn_rvt_obsfile(filename=file.path(tempdir(),"run1_Hydrographs.rvt"),
   flows, 36, typestr = "HYDROGRAPH")

 # weight March-October flows:
 wts <- rvn_gen_obsweights(flows,criterion = "BETWEEN_CYCLIC",
   startdate="2000-03-01", enddate="2003-11-01")

 # and only after March 2003:
 wts2 <- rvn_gen_obsweights(flows,criterion = "AFTER",
   startdate="2003-03-01")
 wts2 <- wts2*wts # product merges weights

 # show weights over time
 plot(wts2)

 # write observation weights to rvt file
 rvn_rvt_obsweights(filename=file.path(tempdir(), "run1_Hydrographs_obsweights.rvt"),
   wts2, 36, typestr="HYDROGRAPH")



[Package RavenR version 2.1.0 Index]