diff --git a/DESCRIPTION b/DESCRIPTION index bae511a..b110628 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: RavenR Type: Package Title: Raven Hydrological Modelling Framework R Support and Analysis Version: 2.2.1 -Date: 2023-08-16 +Date: 2024-05-06 Authors@R: c( person("Robert", "Chlumsky", email = "rchlumsk@uwaterloo.ca", role = c("cre","aut"), comment = c(ORCID = "0000-0002-1303-5064")), person("James", "Craig", email = "jrcraig@uwaterloo.ca", role = c("ctb","aut"), comment = c(ORCID = "0000-0003-2715-7166")), @@ -52,6 +52,6 @@ URL: https://github.com/rchlumsk/RavenR License: GPL-3 Encoding: UTF-8 LazyData: TRUE -RoxygenNote: 7.2.2 +RoxygenNote: 7.3.1 VignetteBuilder: knitr LinkingTo: Rcpp diff --git a/NAMESPACE b/NAMESPACE index 7d27c8e..52fe719 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,6 +16,7 @@ export(rvn_apply_wyearly) export(rvn_apply_wyearly_which_max_xts) export(rvn_budyko_plot) export(rvn_calc_runoff_coeff) +export(rvn_csv_read) export(rvn_cum_plot_flow) export(rvn_custom_output_plot) export(rvn_custom_read) @@ -105,6 +106,7 @@ importFrom(cowplot,draw_label) importFrom(cowplot,ggdraw) importFrom(cowplot,plot_grid) importFrom(crayon,green) +importFrom(dplyr,"%>%") importFrom(dplyr,across) importFrom(dplyr,all_of) importFrom(dplyr,as_tibble) diff --git a/R/rvn_csv_read.R b/R/rvn_csv_read.R new file mode 100644 index 0000000..ea06f5c --- /dev/null +++ b/R/rvn_csv_read.R @@ -0,0 +1,93 @@ +#' @title Read in generic Raven output csv files +#' +#' @description +#' Reads in output csv files produced by Raven. +#' +#' @details +#' Expects a full file path to the Raven output file. +#' +#' The timezone is provided by the tzone argument as "UTC" by default, and should be adjusted by +#' the user to the local time zone as needed, based on the model run. +#' +#' @param ff full file path to the csv file +#' @param tzone string indicating the timezone of the data in ff +#' @param xtsformat boolean whether to return in xts format (if date and/or hour found) +#' @return \item{data frame (as xts if set with \code{xtsformat}) read from the file} +#' @seealso \code{\link{rvn_hyd_read}} for reading Hydrographs output files +#' +#' @examples +#' # create full file path +#' ff <- system.file("extdata","ReservoirStages.csv", package="RavenR") +#' +#' # read in the Reservoir file with the generic call +#' myres <- rvn_csv_read(ff) +#' +#' # view contents +#' head(myres) +#' +#' @export rvn_csv_read +#' @importFrom xts xts +#' @importFrom dplyr %>% +#' @importFrom xts xts +#' @importFrom utils read.csv +rvn_csv_read <- function(ff=NA, tzone="UTC", xtsformat=TRUE) { + + if (missing(ff)) { + stop("Requires the full file path to the Raven csv output file.") + } + + #read output + dd <- read.csv(ff,header=TRUE,nrows=5) + # careful in date-time formats; excel can screw it up if csv is saved over. This works for + # an untouched Raven output file + + cols <- colnames(dd) + classes <- rep(NA,length(cols)) + if ("time" %in% cols) { + classes[which(cols=="time")] <- "integer" + } + if ("date" %in% cols) { + classes[which(cols=="date")] <- "Date" + } + if ("hour" %in% cols) { + classes[which(cols=="hour")] <- "character" + } + + # re-read with specified colClasses + dd <- read.csv(ff,header=TRUE,colClasses = classes,na.strings=c("---",'NA')) + + dt <- NULL + if ("date" %in% cols) { + if ("hour" %in% cols) { + dt <- as.POSIXct(paste(dd$date,dd$hour), format="%Y-%m-%d %H:%M:%S", tz=tzone) + } else { + dt <- as.Date(dd$date) + } + # check if dt converted properly + if (any(is.na(dt))) { + warning("date and time failed to convert from date and hour columns, please check file format.") + dt <- NULL + } + } + + # change all dots to underscore + newcols <- cols %>% + gsub("\\.\\.\\.","\\.\\.",x=.) %>% + gsub("\\.\\.","\\.",x=.) %>% + gsub("\\.","_",x=.) + + # trim all last underscores + for (i in 1:length(newcols)) { + if (rvn_substrRight(newcols[i],1) == "_") { + newcols[i] <- rvn_substrMRight(newcols[i],1) + } + } + colnames(dd) <- newcols + + # change to xtsformat if desired + if (xtsformat & !is.null(dt)) { + dd <- xts(order.by=dt,x=dd) + } + + return(dd) +} diff --git a/R/rvn_rvi_write_template.R b/R/rvn_rvi_write_template.R index f8af2b7..176c0d2 100644 --- a/R/rvn_rvi_write_template.R +++ b/R/rvn_rvi_write_template.R @@ -7,7 +7,7 @@ #' @param filename Name of the rvi file, with extension (optional) #' @param overwrite boolean whether to overwrite file if it already exists (default \code{FALSE}) #' @param writeheader boolean whether to write a header to the rvi file (default \code{TRUE}) -#' @param filetype File extension, Encoding, Raven version (e.g. "rvp ASCII Raven 2.9.1") (optional) +#' @param filetype File extension, Encoding, Raven version (e.g. "rvp ASCII Raven v3.8") (optional) #' @param author Name of file author (optional) #' @param description File Description for header (e.g., Basin or project information, R script name) (optional) #' @@ -19,7 +19,7 @@ #' for ease of getting started with a model using Raven. #' #' The template_name parameter should be one of "UBCWM", "HBV-EC", "HBV-Light", "GR4J", -#' "CdnShield", "MOHYSE", "HMETS", "HYPR", "HYMOD", or "blended_v1". +#' "CdnShield", "MOHYSE", "HMETS", "HYPR", "HYMOD", "SAC-SMA", "blended", or "blended_v2". #' #' This function uses the same model template files that are provided in the Raven User's manual, Appendix D. #' @@ -44,8 +44,8 @@ rvn_rvi_write_template <- function(template_name="UBCWM", filename=NULL, filetype="rvi ASCII Raven", author="RavenR", description=NULL) { - known_templates <- c("UBCWM", "HBV-EC", "HBV-Light", "GR4J", "CdnShield", "MOHYSE", - "HMETS", "HYPR", "HYMOD", "blended_v1") + known_templates <- c("UBCWM", "HBV-EC", "HBV-Light", "GR4J", "CdnShield", "MOHYSE", "HMETS", "HYPR", + "HYMOD", "SAC-SMA", "blended","blended_v2") if (is.null(template_name) | template_name %notin% known_templates) { stop("template_name must be one of the available model templates, see function details") @@ -480,21 +480,52 @@ rvn_rvi_write_template <- function(template_name="UBCWM", filename=NULL, ", -"blended_v1"=" +"SAC-SMA"=" :StartDate 2000-01-01 00:00:00 :Duration 365 :TimeStep 1.0 -:PotentialMeltMethod POTMELT_HMETS +# Model options for SAC-SMA emulation +#------------------------------------------------------------------------ +:PotentialMeltMethod POTMELT_DEGREE_DAY +:RainSnowFraction RAINSNOW_DATA +:Evaporation PET_DATA +:CatchmentRoute ROUTE_DUMP +:Routing ROUTE_NONE -:RainSnowFraction RAINSNOW_HBV # RAINSNOW_DATA -#:SWRadiationMethod SW_RAD_NONE # no radiation is faster +:SoilModel SOIL_MULTILAYER 7 -:Evaporation PET_OUDIN +:Alias UZ_T SOIL[0] +:Alias UZ_F SOIL[1] +:Alias LZ_T SOIL[2] +:Alias LZ_PF SOIL[3] +:Alias LZ_PS SOIL[4] +:HydrologicProcesses + :SnowBalance SNOBAL_SIMPLE_MELT SNOW PONDED_WATER + :Precipitation RAVEN_DEFAULT ATMOS_PRECIP MULTIPLE + :SoilEvaporation SOILEVAP_SACSMA MULTIPLE ATMOSPHERE + :SoilBalance SOILBAL_SACSMA MULTIPLE MULTIPLE + :OpenWaterEvaporation OPEN_WATER_RIPARIAN SURFACE_WATER ATMOSPHERE +:EndHydrologicProcesses + +# + +", + "blended"=" +:StartDate 2000-01-01 00:00:00 +:Duration 365 +:TimeStep 1.0 +:Method ORDERED_SERIES +:Interpolation INTERP_NEAREST_NEIGHBOR + +:PotentialMeltMethod POTMELT_HMETS +:RainSnowFraction RAINSNOW_HBV +:SWRadiationMethod SW_RAD_NONE # no radiation is faster +:Evaporation PET_DATA :CatchmentRoute ROUTE_DUMP :Routing ROUTE_NONE -:SoilModel SOIL_MULTILAYER 3 +:SoilModel SOIL_MULTILAYER 2 :Alias DELAYED_RUNOFF CONVOLUTION[1] @@ -504,13 +535,13 @@ rvn_rvi_write_template <- function(template_name="UBCWM", filename=NULL, :Infiltration INF_HMETS PONDED_WATER MULTIPLE :Infiltration INF_VIC_ARNO PONDED_WATER MULTIPLE :Infiltration INF_HBV PONDED_WATER MULTIPLE - :EndProcessGroup CALCULATE_WTS 0.55556 0.5 + :EndProcessGroup CALCULATE_WTS 0.556 0.5 :Overflow OVERFLOW_RAVEN SOIL[0] DELAYED_RUNOFF :ProcessGroup #quickflow group :Baseflow BASE_LINEAR_ANALYTIC SOIL[0] SURFACE_WATER # interflow, really :Baseflow BASE_VIC SOIL[0] SURFACE_WATER :Baseflow BASE_TOPMODEL SOIL[0] SURFACE_WATER - :EndProcessGroup CALCULATE_WTS 0.55556 0.5 + :EndProcessGroup CALCULATE_WTS 0.556 0.5 :Percolation PERC_LINEAR SOIL[0] SOIL[1] # recharge :Overflow OVERFLOW_RAVEN SOIL[1] DELAYED_RUNOFF :Percolation PERC_LINEAR SOIL[1] SOIL[2] # loss to deep gw @@ -528,8 +559,66 @@ rvn_rvi_write_template <- function(template_name="UBCWM", filename=NULL, :SnowBalance SNOBAL_HMETS MULTIPLE MULTIPLE :SnowBalance SNOBAL_SIMPLE_MELT SNOW PONDED_WATER :SnowBalance SNOBAL_HBV MULTIPLE MULTIPLE - :EndProcessGroup CALCULATE_WTS 0.55556 0.5 + :EndProcessGroup CALCULATE_WTS 0.556 0.5 :EndHydrologicProcesses + +# + +", + "blended_v2"=" +:StartDate 2000-01-01 00:00:00 +:Duration 365 +:TimeStep 1.0 +:Method ORDERED_SERIES + +:SoilModel SOIL_MULTILAYER 3 + +:Evaporation PET_BLENDED +:BlendedPETWeights PET_GRANGERGRAY 0.556 PET_HAMON 0.5 PET_PENMAN_MONTEITH + +:PotentialMeltMethod POTMELT_BLENDED +:BlendedPotMeltWeights POTMELT_HMETS 0.5 POTMELT_RESTRICTED + +:RainSnowFraction RAINSNOW_HBV # RAINSNOW_DATA +:PrecipIceptFract PRECIP_ICEPT_USER +:CatchmentRoute ROUTE_DUMP +:Routing ROUTE_NONE + +:Alias DELAYED_RUNOFF CONVOLUTION[1] + +:HydrologicProcesses + :Precipitation RAVEN_DEFAULT ATMOS_PRECIP MULTIPLE + :CanopyDrip CANDRIP_RUTTER CANOPY PONDED_WATER + :Abstraction ABST_PERCENTAGE PONDED_WATER DEPRESSION + :OpenWaterEvaporation OPEN_WATER_EVAP DEPRESSION ATMOSPHERE + :CanopyEvaporation CANEVP_MAXIMUM CANOPY ATMOSPHERE + :CanopySnowEvap CANEVP_MAXIMUM CANOPY_SNOW ATMOSPHERE + :Seepage SEEP_LINEAR DEPRESSION SOIL[1] + :Infiltration INF_HMETS PONDED_WATER MULTIPLE + :Overflow OVERFLOW_RAVEN SOIL[0] DELAYED_RUNOFF + :ProcessGroup #quickflow/interflow group + :Baseflow BASE_POWER_LAW SOIL[0] SURFACE_WATER + :Baseflow BASE_THRESH_POWER SOIL[0] SURFACE_WATER + :EndProcessGroup CALCULATE_WTS 0.5 + :Percolation PERC_LINEAR SOIL[0] SOIL[1] # recharge + :CapillaryRise CRISE_HBV SOIL[1] SOIL[0] + :Overflow OVERFLOW_RAVEN SOIL[1] DELAYED_RUNOFF + :Percolation PERC_LINEAR SOIL[1] SOIL[2] # loss to deep gw + :CapillaryRise CRISE_HBV SOIL[2] SOIL[1] + :ProcessGroup #evaporation group + :SoilEvaporation SOILEVAP_ALL SOIL[0] ATMOSPHERE # AET + :SoilEvaporation SOILEVAP_ROOT SOIL[0] ATMOSPHERE # AET + :SoilEvaporation SOILEVAP_SEQUEN SOIL[0] ATMOSPHERE # AET + :EndProcessGroup CALCULATE_WTS 0.556 0.5 + :Convolve CONVOL_GAMMA CONVOLUTION[0] SURFACE_WATER # 'surface runoff' + :Convolve CONVOL_GAMMA_2 DELAYED_RUNOFF SURFACE_WATER # 'delayed runoff' + :ProcessGroup #baseflow group + :Baseflow BASE_POWER_LAW SOIL[1] SURFACE_WATER + :Baseflow BASE_THRESH_POWER SOIL[1] SURFACE_WATER + :EndProcessGroup CALCULATE_WTS 0.5 + :SnowBalance SNOBAL_HBV MULTIPLE MULTIPLE +:EndHydrologicProcesses + # " diff --git a/R/rvn_rvt_write_met.R b/R/rvn_rvt_write_met.R index f1b5355..216de91 100644 --- a/R/rvn_rvt_write_met.R +++ b/R/rvn_rvt_write_met.R @@ -293,19 +293,9 @@ rvn_rvt_write_met <- function(metdata, rvt_met_mapping=NULL, filenames=NULL, me writeLines(sprintf(" :Latitude %.6f", md$LAT[k]),fc) writeLines(sprintf(" :Longitude %.6f", md$LON[k]),fc) writeLines(sprintf(" :Elevation %.2f", md$ELEV[k]),fc) - writeLines(sprintf(":RedirectToFile %s", md$rvt.name[k]),fc) + writeLines(sprintf(" :RedirectToFile %s", md$rvt.name[k]),fc) writeLines(":EndGauge\n",fc) } - - ## Write Redirect commands in stndata file - # if(write_redirect) { - # # writeLines("\n",fc) - # # fc.redirect = file(rd_file, open = "a+") - # for(k in 1:nrow(md)){ - # writeLines(sprintf(":RedirectToFile %s", md$rvt.name[k]),fc) - # } - # } - close(fc) message(sprintf("rvn_rvt_write_met: Done writing station data to %s", filename_stndata)) } diff --git a/R/rvn_utilities.R b/R/rvn_utilities.R index fe99dac..cda0c1f 100644 --- a/R/rvn_utilities.R +++ b/R/rvn_utilities.R @@ -546,7 +546,6 @@ rvn_fortify_xts <- function(x) return(y) } - #' @title Provide known options for Raven rvi options #' #' @description @@ -732,11 +731,19 @@ get_rvt_data_type_mapping <- function() { "RESERVOIR_NETINFLOW"=list( "units"="m3/s" ), + "WATER_LEVEL"=list( + "units"="m" + ), + "STREAM_TEMPERATURE"=list( + "units"="dC" + ), + "STREAM_CONCENTRATION"=list( + "units"="mg/L" + ), "SNOW"=list( "units"="mm" ) ) - return(rvt_data_type_mapping) } @@ -798,6 +805,7 @@ get_rvt_met_mapping_weathercan <- function() { "TOTAL_SNOW"=list("SNOWFALL"), "MAX_TEMP"=list("TEMP_MAX"), "MIN_TEMP"=list("TEMP_MIN"), + "MEAN_TEMP"=list("TEMP_AVE"), "WIND_SPD"=list("WIND_VEL"), # warning on unit conversion "REL_HUM"=list("REL_HUMIDITY"), "PRECIP_AMT"=list("PRECIP"), # add warning on unit conversion diff --git a/inst/extdata/RavenAlgParams.dat b/inst/extdata/RavenAlgParams.dat index ce7ca5a..029fba8 100644 --- a/inst/extdata/RavenAlgParams.dat +++ b/inst/extdata/RavenAlgParams.dat @@ -37,6 +37,11 @@ SOILEVAP_HYPR SoilEvaporation PET_CORRECTION SOIL SOILEVAP_HYPR SoilEvaporation MAX_DEP_AREA_FRAC LULT SOILEVAP_HYPR SoilEvaporation PONDED_EXP LULT SOILEVAP_HYPR SoilEvaporation DEP_MAX LULT +SOILEVAP_HYMOD2 SoilEvaporation HYMOD2_G LULT +SOILEVAP_HYMOD2 SoilEvaporation HYMOD2_Kmax LULT +SOILEVAP_HYMOD2 SoilEvaporation HYMOD2_exp LULT +SOILEVAP_HYMOD2 SoilEvaporation PDM_B LULT +SOILEVAP_PDM SoilEvaporation PDM_B LULT LAKE_EVAP_BASIC LakeEvaporation LAKE_PET_CORR LULT OPEN_WATER_EVAP OpenWaterEvaporation OW_PET_CORR LULT @@ -152,16 +157,17 @@ ABST_SCS Abstraction SCS_CN LULT ABST_SCS Abstraction SCS_IA_FRACTION LULT ABST_PDMROF Abstraction PDMROF_B LULT ABST_PDMROF Abstraction DEP_MAX LULT -DFLOW_THRESHPOW DepressionOverflow DEP_THRESHHOLD LULT +DFLOW_THRESHPOW DepressionOverflow DEP_THRESHOLD LULT DFLOW_THRESHPOW DepressionOverflow DEP_N LULT DFLOW_THRESHPOW DepressionOverflow DEP_MAX_FLOW LULT DFLOW_THRESHPOW DepressionOverflow DEP_MAX LULT -DFLOW_LINEAR DepressionOverflow DEP_THRESHHOLD LULT +DFLOW_LINEAR DepressionOverflow DEP_THRESHOLD LULT DFLOW_LINEAR DepressionOverflow DEP_K LULT -DFLOW_WEIR DepressionOverflow DEP_THRESHHOLD LULT +DFLOW_WEIR DepressionOverflow DEP_THRESHOLD LULT DFLOW_WEIR DepressionOverflow DEP_CRESTRATIO LULT SEEPAGE_LINEAR Seepage DEP_SEEP_K LULT + # JRC: missing GR4J, HMETS, MOHYSE, CONVOLUTION... ROUTE_DIFFUSIVE_WAVE RoutingMethod MANNINGS_N SUBBASIN diff --git a/inst/extdata/RavenParameters.dat b/inst/extdata/RavenParameters.dat index 8449b38..396ef81 100644 --- a/inst/extdata/RavenParameters.dat +++ b/inst/extdata/RavenParameters.dat @@ -1,6 +1,6 @@ #RavenParameters.dat -#parameter name, class type, units, autogeneratable, reasonable default, minimum, maximum -#xxx provided as a missing value placeholder +#parameter name, class type, units, autogeneratable, reasonable default, (reasonable) minimum, (reasonable) maximum +#xxx or -9999 provided as a missing value placeholder - Disclaimer: all parameter ranges should be checked when applied in practice! FOREST_COVERAGE LULT [0..1] False 0 0 1 FOREST_COV LULT [0..1] False 0 0 1 @@ -23,7 +23,7 @@ HBV_GLACIER_KMIN LULT [-] False 0.05 -9999 -9999 GLAC_STORAGE_COEFF LULT [1/d] False 0.1 0 1 HBV_GLACIER_AG LULT [-] False 0.05 -9999 -9999 ABST_PERCENT LULT [0..1] False 0.1 0 1 -DEP_MAX LULT [mm] False 6.29 0 20 +DEP_MAX LULT [mm] False 50 0 200 SCS_CN LULT [-] False 50 -9999 -9999 SCS_IA_FRACTION LULT [0..1] False 0.2 0 1 PDMROF_B LULT [-] False 4.0 0.05 10 @@ -33,6 +33,11 @@ DEP_MAX_FLOW LULT [mm/d] False 0.1 0.0 -9999 DEP_K LULT [-] False 0.1 0.0 -9999 DEP_CRESTRATIO LULT [m/m] False 0.0 10 -9999 DEP_SEEP_K LULT [-] False 0.1 0.0 -9999 +PET_VAP_COEFF LULT [mm/d/kPa] False 1.5 1.0 3.0 +PET_LIN_COEFF LULT [mm/d/K] False -9999 0.0 -9999 +WINDVEL_CORR LULT [-] True 1.0 0.0 4.0 +RELHUM_CORR LULT [-] True 1.0 0.5 1.5 +LAKESNOW_BUFFER_HT LULT [-] False 10 0 1000 POROSITY SOIL [0..1] True 0.4 0.0 1.0 VIC_ALPHA SOIL [-] False -9999 -9999 -9999 @@ -121,8 +126,8 @@ MANNINGS_N SUBBASIN [-] False -9999 -9999 9999 SLOPE SUBBASIN [-] False 0.01 0.0 10 RAIN_CORR SUBBASIN [1] True 1.0 0.5 2.0 SNOW_CORR SUBBASIN [1] True 1.0 0.5 2.0 -GAMMA_SHAPE SUBBASIN [-] False 1.0 0.1 10 -GAMMA_SCALE SUBBASIN [1/d] False 3.0 0.1 20 +GAMMA_SHAPE SUBBASIN [-] False 3.0 0.1 10 +GAMMA_SCALE SUBBASIN [1/d] False 1.0 0.1 20 #Newly Added #soil_struct @@ -192,6 +197,8 @@ DRIP_PROPORTION VEG [1/d] False 0.2 0 1 MAX_INTERCEPT_RATE VEG [mm/d] False 10 0 9999 CHU_MATURITY VEG [-] False 2800 0 9999 UPTAKE_MODERATOR VEG [-] True 1 0 1 +CAP_LAI_RATIO VEG [-] True 0.15 0.05 2 +SNOCAP_LAI_RATIO VEG [-] True 0.6 0.2 8 #veg_var_struct LAI VEG [m2/m2] False 4.0 0.0 7 @@ -276,4 +283,10 @@ ASSIMILATION_FACT GLOBAL [0..1] True 1 0 1 ASSIM_UPSTREAM_DECAY GLOBAL [1/km] True 0.01 0 1 ASSIM_TIME_DECAY GLOBAL [1/d] True 0.2 0 1 RESERVOIR_DEMOND_MULT GLOBAL [0..1] False 0 0 1 +HBVEC_LAPSE_UPPER GLOBAL [mm/d/km] True 0 0 0.1 +HBVEC_LAPSE_RATE GLOBAL [mm/d/km] True 0.08 0 0.1 +HBVEC_LAPSE_ELEV GLOBAL [masl] True 5000 3000 7000 +TIME_TO_PEAK_MULTIPLIER GLOBAL [-] True 1 0 5 +GAMMA_SHAPE_MULTIPLIER GLOBAL [-] True 1 0 5 +GAMMA_SCALE_MULTIPLIER GLOBAL [-] True 1 0 5 diff --git a/inst/extdata/RavenProcessConnections.dat b/inst/extdata/RavenProcessConnections.dat index c3d0c5d..e73cd2b 100644 --- a/inst/extdata/RavenProcessConnections.dat +++ b/inst/extdata/RavenProcessConnections.dat @@ -109,6 +109,8 @@ SOILEVAP_UBC SoilEvaporation SOIL[0] ATMOSPHERE SOILEVAP_GR4J SoilEvaporation SOIL[0] ATMOSPHERE SOILEVAP_LINEAR SoilEvaporation SOIL[0] ATMOSPHERE SOILEVAP_ALL SoilEvaporation SOIL[0] ATMOSPHERE +SOLIEVAP_PDM SoilEvaporation SOIL[0] ATMOSPHERE +SOILEVAP_HYMOD2 SoilEvaporation SOIL[0] ATMOSPHERE RAVEN_DEFAULT Recharge ATMOS_PRECIP SOIL #------------------------------------------------- # SNOW PROCESSES @@ -212,6 +214,9 @@ ABST_FILL Abstraction PONDED_WATER DEPRESSION ABST_SCS Abstraction PONDED_WATER DEPRESSION ABST_PDMROF Abstraction PONDED_WATER DEPRESSION ABST_PDMROF Abstraction PONDED_WATER SURFACE_WATER +ABST_UWFS Abstraction PONDED_WATER DEPRESSION +ABST_UWFS Abstraction PONDED_WATER SURFACE_WATER +ABST_UWFS Abstraction MIN_DEP_DEFICIT MIN_DEP_DEFICIT DFLOW_THRESHPOW DepressionOverflow DEPRESSION SURFACE_WATER DFLOW_LINEAR DepressionOverflow DEPRESSION SURFACE_WATER DFLOW_WEIR DepressionOverflow DEPRESSION SURFACE_WATER diff --git a/man/RavenR-package.Rd b/man/RavenR-package.Rd index ce438cb..15bec60 100644 --- a/man/RavenR-package.Rd +++ b/man/RavenR-package.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/RavenR-package.R \docType{package} \name{RavenR-package} +\alias{RavenR} \alias{RavenR-package} \title{RavenR} \description{ @@ -24,3 +25,17 @@ See also \href{http://www.civil.uwaterloo.ca/jrcraig/}{James R. Craig's research page} for software downloads, including the \href{http://raven.uwaterloo.ca/}{Raven webpage}. } +\author{ +\strong{Maintainer}: Robert Chlumsky \email{rchlumsk@uwaterloo.ca} (\href{https://orcid.org/0000-0002-1303-5064}{ORCID}) + +Authors: +\itemize{ + \item James Craig \email{jrcraig@uwaterloo.ca} (\href{https://orcid.org/0000-0003-2715-7166}{ORCID}) [contributor] + \item Leland Scantlebury \email{lscantlebury@uwaterloo.ca} [contributor] + \item Simon Lin \email{simon.lin@uwaterloo.ca} [contributor] + \item Sarah Grass \email{sgrass@nhcweb.com} [contributor] + \item Genevieve Brown \email{genevieve.wbrown@gmail.com} [contributor] + \item Rezgar Arabzadeh \email{rarabzad@uwaterloo.ca} [contributor] +} + +} diff --git a/man/rvn_csv_read.Rd b/man/rvn_csv_read.Rd new file mode 100644 index 0000000..a703e08 --- /dev/null +++ b/man/rvn_csv_read.Rd @@ -0,0 +1,41 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rvn_csv_read.R +\name{rvn_csv_read} +\alias{rvn_csv_read} +\title{Read in generic Raven output csv files} +\usage{ +rvn_csv_read(ff = NA, tzone = "UTC", xtsformat = TRUE) +} +\arguments{ +\item{ff}{full file path to the csv file} + +\item{tzone}{string indicating the timezone of the data in ff} + +\item{xtsformat}{boolean whether to return in xts format (if date and/or hour found)} +} +\value{ +\item{data frame (as xts if set with \code{xtsformat}) read from the file} +} +\description{ +Reads in output csv files produced by Raven. +} +\details{ +Expects a full file path to the Raven output file. + +The timezone is provided by the tzone argument as "UTC" by default, and should be adjusted by +the user to the local time zone as needed, based on the model run. +} +\examples{ +# create full file path +ff <- system.file("extdata","ReservoirStages.csv", package="RavenR") + +# read in the Reservoir file with the generic call +myres <- rvn_csv_read(ff) + +# view contents +head(myres) + +} +\seealso{ +\code{\link{rvn_hyd_read}} for reading Hydrographs output files +} diff --git a/man/rvn_download.Rd b/man/rvn_download.Rd index bc0a857..0d6168a 100644 --- a/man/rvn_download.Rd +++ b/man/rvn_download.Rd @@ -19,10 +19,10 @@ rvn_download(version = NA, NetCDF = FALSE, check = FALSE, copy_path = NULL) Returns \code{TRUE} if executed successfully } \description{ -Downloads Raven executable from the \href{http://raven.uwaterloo.ca/Downloads.html}{Raven webpage}. +Downloads Raven executable from the \href{https://raven.uwaterloo.ca/Downloads.html}{Raven webpage}. } \details{ -Files are downloaded from the Raven webpage (\url{http://raven.uwaterloo.ca/Downloads.html}) and placed +Files are downloaded from the Raven webpage (\url{https://raven.uwaterloo.ca/Downloads.html}) and placed in a temporary directory while the executable is extracted. This helps prevent any unwanted files being saved on your system outside of temporary directories if the function is interrupted. The executable is placed in the RavenR/extdata directory, wherever RavenR is installed on your system. diff --git a/man/rvn_rvh_write.Rd b/man/rvn_rvh_write.Rd index 1b64a70..93b6b7f 100644 --- a/man/rvn_rvh_write.Rd +++ b/man/rvn_rvh_write.Rd @@ -54,9 +54,9 @@ separate the SubBasins and HRUs in different files. } \section{Functions}{ \itemize{ -\item \code{rvn_rvh_overwrite}: Overwrite contents of original .rvh file -}} +\item \code{rvn_rvh_overwrite()}: Overwrite contents of original .rvh file +}} \examples{ ## Example: write a blank rvh file ## create some blank tables diff --git a/man/rvn_rvi_write_template.Rd b/man/rvn_rvi_write_template.Rd index ffb8a71..9e396eb 100644 --- a/man/rvn_rvi_write_template.Rd +++ b/man/rvn_rvi_write_template.Rd @@ -23,7 +23,7 @@ rvn_rvi_write_template( \item{writeheader}{boolean whether to write a header to the rvi file (default \code{TRUE})} -\item{filetype}{File extension, Encoding, Raven version (e.g. "rvp ASCII Raven 2.9.1") (optional)} +\item{filetype}{File extension, Encoding, Raven version (e.g. "rvp ASCII Raven v3.8") (optional)} \item{author}{Name of file author (optional)} @@ -41,7 +41,7 @@ novel model configurations are provided which may be helpful to the user. These for ease of getting started with a model using Raven. The template_name parameter should be one of "UBCWM", "HBV-EC", "HBV-Light", "GR4J", - "CdnShield", "MOHYSE", "HMETS", "HYPR", "HYMOD", or "blended_v1". + "CdnShield", "MOHYSE", "HMETS", "HYPR", "HYMOD", "SAC-SMA", "blended", or "blended_v2". This function uses the same model template files that are provided in the Raven User's manual, Appendix D. diff --git a/vignettes/Introduction_to_RavenR.Rmd b/vignettes/Introduction_to_RavenR.Rmd index 2a659d8..a498d8f 100644 --- a/vignettes/Introduction_to_RavenR.Rmd +++ b/vignettes/Introduction_to_RavenR.Rmd @@ -221,7 +221,8 @@ The Raven User's Manual (Appendix D) provides a number of model templates that c We can call this command to create a template rvi file for one of these models as per below. ```{r RVI write template example} -tf <- file.path(tempdir(), "mymodel.rvi") +td <- tempdir() # temporary directory to write model files to +tf <- file.path(td,"mymodel.rvi") rvn_rvi_write_template(template_name="HMETS", filename=tf, @@ -264,6 +265,8 @@ An rvp template file could be generated by running Raven with the `:CreateRVPTem ```{r Create RVP template file, eval=FALSE} rvn_run(fileprefix = "mymodel", + indir=td, # temporary directory created earlier + outdir=td, # write to same temporary directory rvi_options=":CreateRVPTemplate", showoutput = TRUE) ```