Commit 38a46716 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

Retrait de l'algorithme de calibration "optim"

parent 83a4b5eb
......@@ -21,7 +21,6 @@ CreateCalibOptions <- function(FUN_MOD,FUN_CALIB=Calibration_Michel,FUN_TRANSFO=
##check_FUN_CALIB
BOOL <- FALSE;
if(identical(FUN_CALIB,Calibration_Michel)){ ObjectClass <- c(ObjectClass,"HBAN" ); BOOL <- TRUE; }
if(identical(FUN_CALIB,Calibration_optim )){ ObjectClass <- c(ObjectClass,"optim" ); BOOL <- TRUE; }
if(!BOOL){ stop("incorrect FUN_CALIB for use in CreateCalibOptions \n"); return(NULL); }
##check_FUN_TRANSFO
......@@ -102,8 +101,7 @@ CreateCalibOptions <- function(FUN_MOD,FUN_CALIB=Calibration_Michel,FUN_TRANSFO=
}
##check_StartParamList_and_StartParamDistrib__default_values
if( ("HBAN" %in% ObjectClass & is.null(StartParamList) & is.null(StartParamDistrib)) |
("optim" %in% ObjectClass & is.null(StartParam)) ){
if( ("HBAN" %in% ObjectClass & is.null(StartParamList) & is.null(StartParamDistrib)) ){
if("GR4H"%in% ObjectClass){
ParamT <- matrix( c( +5.12, -1.18, +4.34, -9.69,
......@@ -164,12 +162,6 @@ CreateCalibOptions <- function(FUN_MOD,FUN_CALIB=Calibration_Michel,FUN_TRANSFO=
if(sum(is.na(StartParamDistrib[1,]))!=0){ stop("StartParamDistrib must not include NA values on the first line \n"); return(NULL); }
if(ncol(StartParamDistrib)!=NParam ){ stop("Incompatibility between StartParamDistrib ncol and FUN_MOD \n"); return(NULL); }
}
if("optim" %in% ObjectClass & !is.null(StartParam)){
if(!is.vector( StartParam) ){ stop("StartParam must be a vector \n"); return(NULL); }
if(!is.numeric(StartParam) ){ stop("StartParam must be a vector of numeric values \n"); return(NULL); }
if(sum(is.na(StartParam))!=0 ){ stop("StartParam must not include NA values \n"); return(NULL); }
if(length(StartParam)!=NParam ){ stop("Incompatibility between StartParam length and FUN_MOD \n"); return(NULL); }
}
##Create_CalibOptions
......
......@@ -22,14 +22,14 @@ Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions, FUN_MOD,
\item{FUN_CRIT}{[function] error criterion function (e.g. ErrorCrit_RMSE, ErrorCrit_NSE)}
\item{FUN_CALIB}{(optional) [function] calibration algorithm function (e.g. Calibration_Michel, Calibration_optim), default=Calibration_Michel}
\item{FUN_CALIB}{(optional) [function] calibration algorithm function (e.g. Calibration_Michel), default=Calibration_Michel}
\item{FUN_TRANSFO}{(optional) [function] model parameters transformation function, if the FUN_MOD used is native in the package FUN_TRANSFO is automatically defined}
\item{quiet}{(optional) [boolean] boolean indicating if the function is run in quiet mode or not, default=FALSE}
}
\value{
[list] see \code{\link{Calibration_Michel}} or \code{\link{Calibration_optim}}
[list] see \code{\link{Calibration_Michel}}
}
\description{
Calibration algorithm which optimises the error criterion selected as objective function using the provided functions. \cr
......@@ -92,8 +92,8 @@ cat(paste(" Crit ", OutputsCrit$CritName, " ",
Laurent Coron (June 2014)
}
\seealso{
\code{\link{Calibration_Michel}}, \code{\link{Calibration_optim}},
\code{\link{RunModel}}, \code{\link{ErrorCrit}}, \code{\link{TransfoParam}},
\code{\link{Calibration_Michel}},
\code{\link{ErrorCrit}}, \code{\link{TransfoParam}},
\code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}},
\code{\link{CreateInputsCrit}}, \code{\link{CreateCalibOptions}}.
}
......
......@@ -122,7 +122,7 @@ Michel, C. (1991),
Hydrologie appliquée aux petits bassins ruraux, Hydrology handbook (in French), Cemagref, Antony, France.
}
\seealso{
\code{\link{Calibration}}, \code{\link{Calibration_optim}},
\code{\link{Calibration}},
\code{\link{RunModel_GR4J}}, \code{\link{TransfoParam_GR4J}}, \code{\link{ErrorCrit_RMSE}},
\code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}},
\code{\link{CreateInputsCrit}}, \code{\link{CreateCalibOptions}}.
......
......@@ -3,7 +3,7 @@
\encoding{UTF-8}
\name{CreateCalibOptions}
\alias{CreateCalibOptions}
\title{Creation of the CalibOptions object required bu the Calibration functions}
\title{Creation of the CalibOptions object required but the Calibration functions}
\usage{
CreateCalibOptions(FUN_MOD, FUN_CALIB = Calibration_Michel,
FUN_TRANSFO = NULL, OptimParam = NULL, FixedParam = NULL,
......@@ -13,7 +13,7 @@ CreateCalibOptions(FUN_MOD, FUN_CALIB = Calibration_Michel,
\arguments{
\item{FUN_MOD}{[function] hydrological model function (e.g. RunModel_GR4J, RunModel_CemaNeigeGR4J)}
\item{FUN_CALIB}{(optional) [function] calibration algorithm function (e.g. Calibration_Michel, Calibration_optim), default=Calibration_Michel}
\item{FUN_CALIB}{(optional) [function] calibration algorithm function (e.g. Calibration_Michel), default=Calibration_Michel}
\item{FUN_TRANSFO}{(optional) [function] model parameters transformation function, if the FUN_MOD used is native in the package, FUN_TRANSFO is automatically defined}
......@@ -29,7 +29,7 @@ CreateCalibOptions(FUN_MOD, FUN_CALIB = Calibration_Michel,
[2,] \tab 3000 \tab +1 \tab 100 \tab ... \tab 3.0 \cr
}}
\item{StartParam}{(optional) [numeric] vector of parameter values used to start global search calibration procedure (e.g. Calibration_optim)
\item{StartParam}{(optional) [numeric] vector of parameter values used to start global search calibration procedure
\cr Example:
\tabular{llllll}{
\tab [X1] \tab [X2] \tab [X3] \tab [...] \tab [Xi] \cr
......
## load of catchment data
require(airGR)
data(L0123001)
## preparation of InputsModel object
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="%d/%m/%Y %H:%M")=="01/01/1990 00:00"),
which(format(BasinObs$DatesR,format="%d/%m/%Y %H:%M")=="31/12/1999 00:00"))
## preparation of RunOptions object
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,
RunOptions=RunOptions,Qobs=BasinObs$Qmm[Ind_Run])
## preparation of CalibOptions object
CalibOptions <- CreateCalibOptions(FUN_MOD=RunModel_GR4J,FUN_CALIB=Calibration_optim)
## calibration
OutputsCalib <- Calibration_optim(InputsModel=InputsModel,RunOptions=RunOptions,
InputsCrit=InputsCrit,CalibOptions=CalibOptions,
FUN_MOD=RunModel_GR4J,FUN_CRIT=ErrorCrit_NSE)
## simulation
Param <- OutputsCalib$ParamFinalR
OutputsModel <- RunModel_GR4J(InputsModel=InputsModel,RunOptions=RunOptions,Param=Param)
## results preview
plot_OutputsModel(OutputsModel=OutputsModel,Qobs=BasinObs$Qmm[Ind_Run])
## efficiency criterion: Nash-Sutcliffe Efficiency
InputsCrit <- CreateInputsCrit(FUN_CRIT=ErrorCrit_NSE,InputsModel=InputsModel,
RunOptions=RunOptions,Qobs=BasinObs$Qmm[Ind_Run])
OutputsCrit <- ErrorCrit_NSE(InputsCrit=InputsCrit,OutputsModel=OutputsModel)
cat(paste(" Crit ",OutputsCrit$CritName," ",round(OutputsCrit$CritValue,4),"\n",sep=""))
## efficiency criterion: Kling-Gupta Efficiency
InputsCrit <- CreateInputsCrit(FUN_CRIT=ErrorCrit_KGE,InputsModel=InputsModel,
RunOptions=RunOptions,Qobs=BasinObs$Qmm[Ind_Run])
OutputsCrit <- ErrorCrit_KGE(InputsCrit=InputsCrit,OutputsModel=OutputsModel)
cat(paste(" Crit ",OutputsCrit$CritName," ",round(OutputsCrit$CritValue,4),"\n",sep=""))
Markdown is supported
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