-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from tamnva/joss_manuscript
feat: add more vignettes and update help
- Loading branch information
Showing
16 changed files
with
872 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
|
||
<p>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)</p> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
|
||
<p>When you click this button, all settings are saved to the file 'RSWATObject.rds' in the working directory folder. The parameter sets are generated and SWAT are run in parallel. Running can take time, R is busy while calling SWAT on the background therefore, it might not response to any anything. Don't turn of R. You can check the current simulation status in the file ./Output/CurrentSimulationReport.log You still go to step 4 and click the 'Open file CurrentSimulationReport.log'. When all simulations are finished, you will see a table appear</p> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.