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).

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

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

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.

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)
#> $class
#> [1] "xts" "zoo"
#> 
#> $index
#>   [1] 1033430400 1033516800 1033603200 1033689600 1033776000 1033862400
#>   [7] 1033948800 1034035200 1034121600 1034208000 1034294400 1034380800
#>  [13] 1034467200 1034553600 1034640000 1034726400 1034812800 1034899200
#>  [19] 1034985600 1035072000 1035158400 1035244800 1035331200 1035417600
#>  [25] 1035504000 1035590400 1035676800 1035763200 1035849600 1035936000
#>  [31] 1036022400 1036108800 1036195200 1036281600 1036368000 1036454400
#>  [37] 1036540800 1036627200 1036713600 1036800000 1036886400 1036972800
#>  [43] 1037059200 1037145600 1037232000 1037318400 1037404800 1037491200
#>  [49] 1037577600 1037664000 1037750400 1037836800 1037923200 1038009600
#>  [55] 1038096000 1038182400 1038268800 1038355200 1038441600 1038528000
#>  [61] 1038614400 1038700800 1038787200 1038873600 1038960000 1039046400
#>  [67] 1039132800 1039219200 1039305600 1039392000 1039478400 1039564800
#>  [73] 1039651200 1039737600 1039824000 1039910400 1039996800 1040083200
#>  [79] 1040169600 1040256000 1040342400 1040428800 1040515200 1040601600
#>  [85] 1040688000 1040774400 1040860800 1040947200 1041033600 1041120000
#>  [91] 1041206400 1041292800 1041379200 1041465600 1041552000 1041638400
#>  [97] 1041724800 1041811200 1041897600 1041984000 1042070400 1042156800
#> [103] 1042243200 1042329600 1042416000 1042502400 1042588800 1042675200
#> [109] 1042761600 1042848000 1042934400 1043020800 1043107200 1043193600
#> [115] 1043280000 1043366400 1043452800 1043539200 1043625600 1043712000
#> [121] 1043798400 1043884800 1043971200 1044057600 1044144000 1044230400
#> [127] 1044316800 1044403200 1044489600 1044576000 1044662400 1044748800
#> [133] 1044835200 1044921600 1045008000 1045094400 1045180800 1045267200
#> [139] 1045353600 1045440000 1045526400 1045612800 1045699200 1045785600
#> [145] 1045872000 1045958400 1046044800 1046131200 1046217600 1046304000
#> [151] 1046390400 1046476800 1046563200 1046649600 1046736000 1046822400
#> [157] 1046908800 1046995200 1047081600 1047168000 1047254400 1047340800
#> [163] 1047427200 1047513600 1047600000 1047686400 1047772800 1047859200
#> [169] 1047945600 1048032000 1048118400 1048204800 1048291200 1048377600
#> [175] 1048464000 1048550400 1048636800 1048723200 1048809600 1048896000
#> [181] 1048982400 1049068800 1049155200 1049241600 1049328000 1049414400
#> [187] 1049500800 1049587200 1049673600 1049760000 1049846400 1049932800
#> [193] 1050019200 1050105600 1050192000 1050278400 1050364800 1050451200
#> [199] 1050537600 1050624000 1050710400 1050796800 1050883200 1050969600
#> [205] 1051056000 1051142400 1051228800 1051315200 1051401600 1051488000
#> [211] 1051574400 1051660800 1051747200 1051833600 1051920000 1052006400
#> [217] 1052092800 1052179200 1052265600 1052352000 1052438400 1052524800
#> [223] 1052611200 1052697600 1052784000 1052870400 1052956800 1053043200
#> [229] 1053129600 1053216000 1053302400 1053388800 1053475200 1053561600
#> [235] 1053648000 1053734400 1053820800 1053907200 1053993600 1054080000
#> [241] 1054166400 1054252800 1054339200 1054425600 1054512000 1054598400
#> [247] 1054684800 1054771200 1054857600 1054944000 1055030400 1055116800
#> [253] 1055203200 1055289600 1055376000 1055462400 1055548800 1055635200
#> [259] 1055721600 1055808000 1055894400 1055980800 1056067200 1056153600
#> [265] 1056240000 1056326400 1056412800 1056499200 1056585600 1056672000
#> [271] 1056758400 1056844800 1056931200 1057017600 1057104000 1057190400
#> [277] 1057276800 1057363200 1057449600 1057536000 1057622400 1057708800
#> [283] 1057795200 1057881600 1057968000 1058054400 1058140800 1058227200
#> [289] 1058313600 1058400000 1058486400 1058572800 1058659200 1058745600
#> [295] 1058832000 1058918400 1059004800 1059091200 1059177600 1059264000
#> [301] 1059350400 1059436800 1059523200 1059609600 1059696000 1059782400
#> [307] 1059868800 1059955200 1060041600 1060128000 1060214400 1060300800
#> [313] 1060387200 1060473600 1060560000 1060646400 1060732800 1060819200
#> [319] 1060905600 1060992000 1061078400 1061164800 1061251200 1061337600
#> [325] 1061424000 1061510400 1061596800 1061683200 1061769600 1061856000
#> [331] 1061942400 1062028800 1062115200 1062201600 1062288000 1062374400
#> [337] 1062460800 1062547200 1062633600 1062720000 1062806400 1062892800
#> [343] 1062979200 1063065600 1063152000 1063238400 1063324800 1063411200
#> [349] 1063497600 1063584000 1063670400 1063756800 1063843200 1063929600
#> [355] 1064016000 1064102400 1064188800 1064275200 1064361600 1064448000
#> [361] 1064534400 1064620800 1064707200 1064793600 1064880000 1064966400
#> [367] 1065052800 1065139200 1065225600 1065312000 1065398400 1065484800
#> [373] 1065571200 1065657600 1065744000 1065830400 1065916800 1066003200
#> [379] 1066089600 1066176000 1066262400 1066348800 1066435200 1066521600
#> [385] 1066608000 1066694400 1066780800 1066867200 1066953600 1067040000
#> [391] 1067126400 1067212800 1067299200 1067385600 1067472000 1067558400
#> [397] 1067644800 1067731200 1067817600 1067904000 1067990400 1068076800
#> [403] 1068163200 1068249600 1068336000 1068422400 1068508800 1068595200
#> [409] 1068681600 1068768000 1068854400 1068940800 1069027200 1069113600
#> [415] 1069200000 1069286400 1069372800 1069459200 1069545600 1069632000
#> [421] 1069718400 1069804800 1069891200 1069977600 1070064000 1070150400
#> [427] 1070236800 1070323200 1070409600 1070496000 1070582400 1070668800
#> [433] 1070755200 1070841600 1070928000 1071014400 1071100800 1071187200
#> [439] 1071273600 1071360000 1071446400 1071532800 1071619200 1071705600
#> [445] 1071792000 1071878400 1071964800 1072051200 1072137600 1072224000
#> [451] 1072310400 1072396800 1072483200 1072569600 1072656000 1072742400
#> [457] 1072828800 1072915200 1073001600 1073088000 1073174400 1073260800
#> [463] 1073347200 1073433600 1073520000 1073606400 1073692800 1073779200
#> [469] 1073865600 1073952000 1074038400 1074124800 1074211200 1074297600
#> [475] 1074384000 1074470400 1074556800 1074643200 1074729600 1074816000
#> [481] 1074902400 1074988800 1075075200 1075161600 1075248000 1075334400
#> [487] 1075420800 1075507200 1075593600 1075680000 1075766400 1075852800
#> [493] 1075939200 1076025600 1076112000 1076198400 1076284800 1076371200
#> [499] 1076457600 1076544000 1076630400 1076716800 1076803200 1076889600
#> [505] 1076976000 1077062400 1077148800 1077235200 1077321600 1077408000
#> [511] 1077494400 1077580800 1077667200 1077753600 1077840000 1077926400
#> [517] 1078012800 1078099200 1078185600 1078272000 1078358400 1078444800
#> [523] 1078531200 1078617600 1078704000 1078790400 1078876800 1078963200
#> [529] 1079049600 1079136000 1079222400 1079308800 1079395200 1079481600
#> [535] 1079568000 1079654400 1079740800 1079827200 1079913600 1080000000
#> [541] 1080086400 1080172800 1080259200 1080345600 1080432000 1080518400
#> [547] 1080604800 1080691200 1080777600 1080864000 1080950400 1081036800
#> [553] 1081123200 1081209600 1081296000 1081382400 1081468800 1081555200
#> [559] 1081641600 1081728000 1081814400 1081900800 1081987200 1082073600
#> [565] 1082160000 1082246400 1082332800 1082419200 1082505600 1082592000
#> [571] 1082678400 1082764800 1082851200 1082937600 1083024000 1083110400
#> [577] 1083196800 1083283200 1083369600 1083456000 1083542400 1083628800
#> [583] 1083715200 1083801600 1083888000 1083974400 1084060800 1084147200
#> [589] 1084233600 1084320000 1084406400 1084492800 1084579200 1084665600
#> [595] 1084752000 1084838400 1084924800 1085011200 1085097600 1085184000
#> [601] 1085270400 1085356800 1085443200 1085529600 1085616000 1085702400
#> [607] 1085788800 1085875200 1085961600 1086048000 1086134400 1086220800
#> [613] 1086307200 1086393600 1086480000 1086566400 1086652800 1086739200
#> [619] 1086825600 1086912000 1086998400 1087084800 1087171200 1087257600
#> [625] 1087344000 1087430400 1087516800 1087603200 1087689600 1087776000
#> [631] 1087862400 1087948800 1088035200 1088121600 1088208000 1088294400
#> [637] 1088380800 1088467200 1088553600 1088640000 1088726400 1088812800
#> [643] 1088899200 1088985600 1089072000 1089158400 1089244800 1089331200
#> [649] 1089417600 1089504000 1089590400 1089676800 1089763200 1089849600
#> [655] 1089936000 1090022400 1090108800 1090195200 1090281600 1090368000
#> [661] 1090454400 1090540800 1090627200 1090713600 1090800000 1090886400
#> [667] 1090972800 1091059200 1091145600 1091232000 1091318400 1091404800
#> [673] 1091491200 1091577600 1091664000 1091750400 1091836800 1091923200
#> [679] 1092009600 1092096000 1092182400 1092268800 1092355200 1092441600
#> [685] 1092528000 1092614400 1092700800 1092787200 1092873600 1092960000
#> [691] 1093046400 1093132800 1093219200 1093305600 1093392000 1093478400
#> [697] 1093564800 1093651200 1093737600 1093824000 1093910400 1093996800
#> [703] 1094083200 1094169600 1094256000 1094342400 1094428800 1094515200
#> [709] 1094601600 1094688000 1094774400 1094860800 1094947200 1095033600
#> [715] 1095120000 1095206400 1095292800 1095379200 1095465600 1095552000
#> [721] 1095638400 1095724800 1095811200 1095897600 1095984000 1096070400
#> [727] 1096156800 1096243200 1096329600 1096416000 1096502400
#> attr(,"tzone")
#> [1] "UTC"
#> attr(,"tclass")
#> [1] "POSIXct" "POSIXt" 
#> 
#> $dim
#> [1] 731   2
#> 
#> $dimnames
#> $dimnames[[1]]
#> NULL
#> 
#> $dimnames[[2]]
#> [1] "sim" "obs"
#> 
#> 

# 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)
#> Warning: 'precip' column name not found in precip object, using first column as precipitation data anyway.
#> 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()`).