diff --git a/R/Calibration.R b/R/Calibration.R index 2bfceaf482145a80b51a80953787323c133f1c3c..a66c78154e42b49ab80a61db832a6327da4dd962 100644 --- a/R/Calibration.R +++ b/R/Calibration.R @@ -1,13 +1,14 @@ -Calibration <- function(InputsModel, - RunOptions, - InputsCrit, +Calibration <- function(InputsModel, + RunOptions, + InputsCrit, CalibOptions, - FUN_MOD, + FUN_MOD, FUN_CRIT, # deprecated - FUN_CALIB = Calibration_Michel, + FUN_CALIB = Calibration_Michel, FUN_TRANSFO = NULL, - verbose = TRUE) { - + verbose = TRUE, + ...) { + FUN_MOD <- match.fun(FUN_MOD) if (!missing(FUN_CRIT)) { FUN_CRIT <- match.fun(FUN_CRIT) @@ -16,10 +17,10 @@ Calibration <- function(InputsModel, if (!is.null(FUN_TRANSFO)) { FUN_TRANSFO <- match.fun(FUN_TRANSFO) } - + return(FUN_CALIB(InputsModel = InputsModel, RunOptions = RunOptions, InputsCrit = InputsCrit, CalibOptions = CalibOptions, FUN_MOD = FUN_MOD, FUN_TRANSFO = FUN_TRANSFO, - verbose = verbose)) + verbose = verbose, ...)) } diff --git a/man/Calibration.Rd b/man/Calibration.Rd index c4779f0bd4ffa5478cdaaf36a3fc4a1783e5a04a..7368556f2202b4d24ecfbc9badb85d888fd3fd3c 100644 --- a/man/Calibration.Rd +++ b/man/Calibration.Rd @@ -16,7 +16,7 @@ Calibration algorithm that optimises the error criterion selected as objective f \usage{ Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions, FUN_MOD, FUN_CRIT, FUN_CALIB = Calibration_Michel, - FUN_TRANSFO = NULL, verbose = TRUE) + FUN_TRANSFO = NULL, verbose = TRUE, ...) } @@ -38,6 +38,8 @@ Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions, \item{FUN_TRANSFO}{(optional) [function] model parameters transformation function, if the \code{FUN_MOD} used is native in the package \code{FUN_TRANSFO} is automatically defined} \item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = \code{TRUE}} + +\item{...}{Further arguments to pass to \code{\link{RunModel}}} } @@ -53,11 +55,11 @@ library(airGR) data(L0123001) ## preparation of InputsModel object -InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR, +InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR, Precip = BasinObs$P, PotEvap = BasinObs$E) ## calibration period selection -Ind_Run <- seq(which(format(BasinObs$DatesR, format = "\%Y-\%m-\%d")=="1990-01-01"), +Ind_Run <- seq(which(format(BasinObs$DatesR, format = "\%Y-\%m-\%d")=="1990-01-01"), which(format(BasinObs$DatesR, format = "\%Y-\%m-\%d")=="1999-12-31")) ## preparation of RunOptions object @@ -65,7 +67,7 @@ RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J, InputsModel = InputsModel, IndPeriod_Run = Ind_Run) ## calibration criterion: preparation of the InputsCrit object -InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel, +InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel, RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run]) ## preparation of CalibOptions object @@ -74,24 +76,24 @@ CalibOptions <- CreateCalibOptions(FUN_MOD = RunModel_GR4J, FUN_CALIB = Calibrat ## calibration OutputsCalib <- Calibration(InputsModel = InputsModel, RunOptions = RunOptions, InputsCrit = InputsCrit, CalibOptions = CalibOptions, - FUN_MOD = RunModel_GR4J, + FUN_MOD = RunModel_GR4J, FUN_CALIB = Calibration_Michel) ## simulation Param <- OutputsCalib$ParamFinalR -OutputsModel <- RunModel(InputsModel = InputsModel, RunOptions = RunOptions, +OutputsModel <- RunModel(InputsModel = InputsModel, RunOptions = RunOptions, Param = Param, FUN = RunModel_GR4J) ## results preview plot(OutputsModel, Qobs = BasinObs$Qmm[Ind_Run]) ## efficiency criterion: Nash-Sutcliffe Efficiency -InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel, +InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel, RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run]) OutputsCrit <- ErrorCrit_NSE(InputsCrit = InputsCrit, OutputsModel = OutputsModel) ## efficiency criterion: Kling-Gupta Efficiency -InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_KGE, InputsModel = InputsModel, +InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_KGE, InputsModel = InputsModel, RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run]) OutputsCrit <- ErrorCrit_KGE(InputsCrit = InputsCrit, OutputsModel = OutputsModel) } @@ -105,7 +107,7 @@ Laurent Coron, Olivier Delaigue \seealso{ \code{\link{Calibration_Michel}}, \code{\link{ErrorCrit}}, \code{\link{TransfoParam}}, -\code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}, +\code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}, \code{\link{CreateInputsCrit}}, \code{\link{CreateCalibOptions}}. } diff --git a/man/Calibration_Michel.Rd b/man/Calibration_Michel.Rd index 60439df643b4e82a52b8e7a59051b3fdfaa66d9b..33e3b999fd3e1850661cd25904f3b3cf06683e3c 100644 --- a/man/Calibration_Michel.Rd +++ b/man/Calibration_Michel.Rd @@ -19,7 +19,7 @@ Then a steepest descent local search algorithm is performed, starting from the r \usage{ Calibration_Michel(InputsModel, RunOptions, InputsCrit, CalibOptions, - FUN_MOD, FUN_CRIT, FUN_TRANSFO = NULL, verbose = TRUE) + FUN_MOD, FUN_CRIT, FUN_TRANSFO = NULL, verbose = TRUE, ...) } @@ -39,6 +39,8 @@ Calibration_Michel(InputsModel, RunOptions, InputsCrit, CalibOptions, \item{FUN_TRANSFO}{(optional) [function] model parameters transformation function, if the \code{FUN_MOD} used is native in the package \code{FUN_TRANSFO} is automatically defined} \item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = \code{TRUE}} + +\item{...}{Further arguments to pass to \code{\link{RunModel}}} } diff --git a/man/RunModel.Rd b/man/RunModel.Rd index 2e76d41d065a140ff0440005ab6635eff63de620..ff14d04de0147455ebba1639b5faf237f5895ee5 100644 --- a/man/RunModel.Rd +++ b/man/RunModel.Rd @@ -15,7 +15,7 @@ Function which performs a single model run with the provided function over the s \usage{ -RunModel(InputsModel, RunOptions, Param, FUN_MOD) +RunModel(InputsModel, RunOptions, Param, FUN_MOD, ...) % %\method{[}{OutputsModel}(x, i) } @@ -33,6 +33,7 @@ RunModel(InputsModel, RunOptions, Param, FUN_MOD) %\item{x}{[InputsModel] object of class InputsModel} % %\item{i}{[integer] of the indices to subset a time series or [character] names of the elements to extract} +\item{...}{Further arguments to pass to the hydrological model function. See \code{\link{RunModel_Lag}} for example} }