diff --git a/NAMESPACE b/NAMESPACE index 64384aa..e6bd129 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -33,6 +33,8 @@ export(updateCalibrationFile) export(updateMultiFile) export(updateSingleFile) export(updatedFileContent) +export(userObjFunction) +export(userReadSwatOutput) export(yearlyOutputLoc) importFrom(doParallel,registerDoParallel) importFrom(foreach,"%dopar%") diff --git a/R/userObjFunction.R b/R/userObjFunction.R new file mode 100644 index 0000000..f99cab7 --- /dev/null +++ b/R/userObjFunction.R @@ -0,0 +1,58 @@ + +#' User-defined objective function +#' +#' @description +#' This is a dummy function. There are countless number of objective functions, +#' which RSWAT cannot include all of them in here. Instead, RSWAT only +#' provides some of the most commonly used objective functions, such as the NSE, +#' KGE, aBIAS, R2. User can implement their own objective function and replace +#' this function. For more detail see RSWAT vignettes (user_objective_function). +#' +#' @examples +#' \donttest{ +#' # Create example data of observed and simulated +#' obs <- list() +#' obs[[1]] <- runif(100) +#' obs[[2]] <- runif(100) +#' +#' # Simulated data +#' sim <- list() +#' sim[[1]] <- runif(100) +#' sim[[2]] <- runif(100) +#' +#' # Lets say now our objective function is the correlation R2 and the weight +#' # for the first variable (obs[[1]]) is 1 and for the second variable is 2 +#' +#' # Create a custom objective function for this task +#' updatedUserObjFunction <- function(obs, sim){ +#' +#' # Define output variable +#' output <- list() +#' output$perCriteria <- list() +#' +#' # R2 of the first variable +#' output$perCriteria[[1]] <- cor(obs[[1]], sim[[1]])**2 +#' +#' # R2 of the second variable +#' output$perCriteria[[2]] <- cor(obs[[2]], sim[[2]])**2 +#' +#' # Final objective function value (with different weights), must be with the name "output" +#' output$overalPerCriteria <- (1 * output$perCriteria[[1]] + 2 * output$perCriteria[[2]])/3 +#' +#' for (i in 1:length(output$perCriteria)){ +#' output$perCriteria[[i]] <- data.frame(userObjFunc = output$perCriteria[[i]]) +#' } +#' +#' return(output) +#' } +#' +#' # Overwrite the userObjFunction with our updatedUserObjFunction +#' environment(updatedUserObjFunction) <- asNamespace('RSWAT') +#' assignInNamespace("userObjFunction", updatedUserObjFunction, ns = "RSWAT") +#' } +#' +#' @export + +userObjFunction <- function(obs, sim){ + output <- NA +} diff --git a/R/userReadSwatOutput.R b/R/userReadSwatOutput.R new file mode 100644 index 0000000..a993740 --- /dev/null +++ b/R/userReadSwatOutput.R @@ -0,0 +1,18 @@ + +#' User-defined output extraction +#' +#' @description +#' This is a dummy function. As SWAT/SWAT+ have many outputs, RSWAT only provides +#' some standard output extraction. Users want to extract other model outputs can +#' implement their own function and replace this function. For more detail see +#' RSWAT vignettes (userReadSwatOutput). +#' +#' @examples +#' +#' # Please see RSWAT vignettes for an example +#' +#' @export + +userReadSwatOutput <- function(){ + output <- NA + } diff --git a/inst/R-SWAT/HTML/helpCheckCurrentSimulation.html b/inst/R-SWAT/HTML/helpCheckCurrentSimulation.html new file mode 100644 index 0000000..af32a34 --- /dev/null +++ b/inst/R-SWAT/HTML/helpCheckCurrentSimulation.html @@ -0,0 +1,10 @@ + + +
+ + + +You can only open this files when all SWAT simulations are finished. If SWAT is running on background, you can manually go to the working folder ./Output/CurrentSimulationReport.log and open it with any text editor (e.g., notepad)
+ + + diff --git a/inst/R-SWAT/HTML/helpOutputExtraction.html b/inst/R-SWAT/HTML/helpOutputExtraction.html index 6bd6f2a..4e9e5c8 100644 --- a/inst/R-SWAT/HTML/helpOutputExtraction.html +++ b/inst/R-SWAT/HTML/helpOutputExtraction.html @@ -15,16 +15,15 @@