Commit 955afb44 authored by Dorchies David's avatar Dorchies David
Browse files

fix(RunModel): documentation of argument "..." in RunModel and Calibration

Fix #108
Showing with 26 additions and 20 deletions
+26 -20
Calibration <- function(InputsModel, Calibration <- function(InputsModel,
RunOptions, RunOptions,
InputsCrit, InputsCrit,
CalibOptions, CalibOptions,
FUN_MOD, FUN_MOD,
FUN_CRIT, # deprecated FUN_CRIT, # deprecated
FUN_CALIB = Calibration_Michel, FUN_CALIB = Calibration_Michel,
FUN_TRANSFO = NULL, FUN_TRANSFO = NULL,
verbose = TRUE) { verbose = TRUE,
...) {
FUN_MOD <- match.fun(FUN_MOD) FUN_MOD <- match.fun(FUN_MOD)
if (!missing(FUN_CRIT)) { if (!missing(FUN_CRIT)) {
FUN_CRIT <- match.fun(FUN_CRIT) FUN_CRIT <- match.fun(FUN_CRIT)
...@@ -16,10 +17,10 @@ Calibration <- function(InputsModel, ...@@ -16,10 +17,10 @@ Calibration <- function(InputsModel,
if (!is.null(FUN_TRANSFO)) { if (!is.null(FUN_TRANSFO)) {
FUN_TRANSFO <- match.fun(FUN_TRANSFO) FUN_TRANSFO <- match.fun(FUN_TRANSFO)
} }
return(FUN_CALIB(InputsModel = InputsModel, RunOptions = RunOptions, InputsCrit = InputsCrit, return(FUN_CALIB(InputsModel = InputsModel, RunOptions = RunOptions, InputsCrit = InputsCrit,
CalibOptions = CalibOptions, CalibOptions = CalibOptions,
FUN_MOD = FUN_MOD, FUN_TRANSFO = FUN_TRANSFO, FUN_MOD = FUN_MOD, FUN_TRANSFO = FUN_TRANSFO,
verbose = verbose)) verbose = verbose, ...))
} }
...@@ -16,7 +16,7 @@ Calibration algorithm that optimises the error criterion selected as objective f ...@@ -16,7 +16,7 @@ Calibration algorithm that optimises the error criterion selected as objective f
\usage{ \usage{
Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions, Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions,
FUN_MOD, FUN_CRIT, FUN_CALIB = Calibration_Michel, 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, ...@@ -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{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{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) ...@@ -53,11 +55,11 @@ library(airGR)
data(L0123001) data(L0123001)
## preparation of InputsModel object ## 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) Precip = BasinObs$P, PotEvap = BasinObs$E)
## calibration period selection ## 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")) which(format(BasinObs$DatesR, format = "\%Y-\%m-\%d")=="1999-12-31"))
## preparation of RunOptions object ## preparation of RunOptions object
...@@ -65,7 +67,7 @@ RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J, ...@@ -65,7 +67,7 @@ RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J,
InputsModel = InputsModel, IndPeriod_Run = Ind_Run) InputsModel = InputsModel, IndPeriod_Run = Ind_Run)
## calibration criterion: preparation of the InputsCrit object ## 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]) RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run])
## preparation of CalibOptions object ## preparation of CalibOptions object
...@@ -74,24 +76,24 @@ CalibOptions <- CreateCalibOptions(FUN_MOD = RunModel_GR4J, FUN_CALIB = Calibrat ...@@ -74,24 +76,24 @@ CalibOptions <- CreateCalibOptions(FUN_MOD = RunModel_GR4J, FUN_CALIB = Calibrat
## calibration ## calibration
OutputsCalib <- Calibration(InputsModel = InputsModel, RunOptions = RunOptions, OutputsCalib <- Calibration(InputsModel = InputsModel, RunOptions = RunOptions,
InputsCrit = InputsCrit, CalibOptions = CalibOptions, InputsCrit = InputsCrit, CalibOptions = CalibOptions,
FUN_MOD = RunModel_GR4J, FUN_MOD = RunModel_GR4J,
FUN_CALIB = Calibration_Michel) FUN_CALIB = Calibration_Michel)
## simulation ## simulation
Param <- OutputsCalib$ParamFinalR Param <- OutputsCalib$ParamFinalR
OutputsModel <- RunModel(InputsModel = InputsModel, RunOptions = RunOptions, OutputsModel <- RunModel(InputsModel = InputsModel, RunOptions = RunOptions,
Param = Param, FUN = RunModel_GR4J) Param = Param, FUN = RunModel_GR4J)
## results preview ## results preview
plot(OutputsModel, Qobs = BasinObs$Qmm[Ind_Run]) plot(OutputsModel, Qobs = BasinObs$Qmm[Ind_Run])
## efficiency criterion: Nash-Sutcliffe Efficiency ## 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]) RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run])
OutputsCrit <- ErrorCrit_NSE(InputsCrit = InputsCrit, OutputsModel = OutputsModel) OutputsCrit <- ErrorCrit_NSE(InputsCrit = InputsCrit, OutputsModel = OutputsModel)
## efficiency criterion: Kling-Gupta Efficiency ## 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]) RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run])
OutputsCrit <- ErrorCrit_KGE(InputsCrit = InputsCrit, OutputsModel = OutputsModel) OutputsCrit <- ErrorCrit_KGE(InputsCrit = InputsCrit, OutputsModel = OutputsModel)
} }
...@@ -105,7 +107,7 @@ Laurent Coron, Olivier Delaigue ...@@ -105,7 +107,7 @@ Laurent Coron, Olivier Delaigue
\seealso{ \seealso{
\code{\link{Calibration_Michel}}, \code{\link{Calibration_Michel}},
\code{\link{ErrorCrit}}, \code{\link{TransfoParam}}, \code{\link{ErrorCrit}}, \code{\link{TransfoParam}},
\code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}, \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}},
\code{\link{CreateInputsCrit}}, \code{\link{CreateCalibOptions}}. \code{\link{CreateInputsCrit}}, \code{\link{CreateCalibOptions}}.
} }
...@@ -19,7 +19,7 @@ Then a steepest descent local search algorithm is performed, starting from the r ...@@ -19,7 +19,7 @@ Then a steepest descent local search algorithm is performed, starting from the r
\usage{ \usage{
Calibration_Michel(InputsModel, RunOptions, InputsCrit, CalibOptions, 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, ...@@ -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{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{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}}}
} }
......
...@@ -15,7 +15,7 @@ Function which performs a single model run with the provided function over the s ...@@ -15,7 +15,7 @@ Function which performs a single model run with the provided function over the s
\usage{ \usage{
RunModel(InputsModel, RunOptions, Param, FUN_MOD) RunModel(InputsModel, RunOptions, Param, FUN_MOD, ...)
% %
%\method{[}{OutputsModel}(x, i) %\method{[}{OutputsModel}(x, i)
} }
...@@ -33,6 +33,7 @@ RunModel(InputsModel, RunOptions, Param, FUN_MOD) ...@@ -33,6 +33,7 @@ RunModel(InputsModel, RunOptions, Param, FUN_MOD)
%\item{x}{[InputsModel] object of class InputsModel} %\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{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}
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment