Commit d73792cc authored by Dorchies David's avatar Dorchies David
Browse files

feat(CreateInputsCrit): add default a priori celerity parameter

Refs #58
parent 71a0f1dd
Pipeline #27637 passed with stage
in 5 minutes and 54 seconds
......@@ -85,11 +85,12 @@ getInputsCrit_Lavenne <- function(id, OutputsModel, InputsCrit) {
stop("'InputsCrit[[id]]' must be of class InputsCritLavenneFunction")
}
AprioriId <- attr(InputsCrit[[id]], "AprioriId")
AprCelerity <- attr(InputsCrit[[id]], "AprCelerity")
Lavenne_FUN <- attr(InputsCrit[[id]], "Lavenne_FUN")
AprParamR <- OutputsModel[[AprioriId]]$Param
if(!inherits(OutputsModel[[AprioriId]], "SD")) {
# Add neutral velocity parameter for upstream catchment
AprParamR <- c(NA, AprParamR)
# Add default velocity parameter for a priori upstream catchment
AprParamR <- c(AprCelerity, AprParamR)
}
AprCrit <- ErrorCrit(InputsCrit[[AprioriId]], OutputsModel[[AprioriId]])$CritValue
return(Lavenne_FUN(AprParamR, AprCrit))
......
......@@ -6,6 +6,7 @@ CreateInputsCrit.GRiwrmInputsModel <- function(InputsModel,
Obs,
AprioriIds = NULL,
k = 0.15,
AprCelerity = 1,
...) {
# Parameter checks
......@@ -80,6 +81,7 @@ CreateInputsCrit.GRiwrmInputsModel <- function(InputsModel,
...
)
attr(InputsCrit[[IM$id]], "AprioriId") <- AprioriIds[IM$id]
attr(InputsCrit[[IM$id]], "AprCelerity") <- AprCelerity
class(InputsCrit[[IM$id]]) <- c("InputsCritLavenneFunction", class(InputsCrit[[IM$id]]))
}
}
......
......@@ -8,6 +8,7 @@
#' @param Obs [numeric], [matrix] or [data.frame] series of observed flows, see details
#' @param AprioriIds (optional) named [list] or named [vector] of [character] used for the parameter regularisation (see details)
#' @param k (optional) [numeric] weight coefficient used in the parameter regularisation (See [airGR::CreateInputsCrit_Lavenne])
#' @param AprCelerity (optional) [numeric] Default celerity used as a priori parameter for upstream catchments
#' @param ... arguments passed to [airGR::CreateInputsCrit], see details
#'
#' @details See [airGR::CreateInputsCrit] documentation for a complete list of arguments.
......@@ -17,8 +18,8 @@
#'
#' With a \emph{GRiwrmInputsModel} object, all arguments are applied on each sub-catchments of the network.
#'
#' Parameter regularisation consists of defining a priori parameters which are used in a composed criterion based on the formula proposed by de Lavenne et al. (2019) (See [airGR::CreateInputsCrit_Lavenne]).
#' The parameter `AprioriIds` allows to define which upstream sub-catchment is used for providing a priori parameters. Its format is as follows: `AprioriIds <- c("Downstream sub-catchment 1" = "A priori upstream sub-catchment 1", ...)` where the quoted strings are the ids of the sub-catchments. See vignettes for more details.
#' Parameter regularisation consists of defining a priori parameters which are used in a composed criterion based on the formula proposed by Lavenne et al. (2019) (See [airGR::CreateInputsCrit_Lavenne]).
#' The parameter `AprioriIds` allows to define which upstream sub-catchment is used for providing a priori parameters. Its format is as follows: `AprioriIds <- c("Downstream sub-catchment 1" = "A priori upstream sub-catchment 1", ...)` where the quoted strings are the ids of the sub-catchments. See vignettes for more details. The parameter `AprCelerity` is a default value used as a priori for the parameter 'Celerity' in case of an upstream catchment (without celerity parameter) is used as a priori catchment.
#'
#' @return Depending on the class of `InputsModel` argument (respectively `InputsModel` and `GRiwrmInputsModel` object), the returned value is respectively:
#' - a `InputsCrit` object (See [airGR::CreateInputsCrit])
......
......@@ -14,6 +14,7 @@
Obs,
AprioriIds = NULL,
k = 0.15,
AprCelerity = 1,
...
)
......@@ -34,6 +35,8 @@ CreateInputsCrit(InputsModel, ...)
\item{k}{(optional) \link{numeric} weight coefficient used in the parameter regularisation (See \link[airGR:CreateInputsCrit_Lavenne]{airGR::CreateInputsCrit_Lavenne})}
\item{AprCelerity}{(optional) \link{numeric} Default celerity used as a priori parameter for upstream catchments}
\item{...}{arguments passed to \link[airGR:CreateInputsCrit]{airGR::CreateInputsCrit}, see details}
}
\value{
......@@ -54,8 +57,8 @@ Then, each column of the \link{matrix} or \link{data.frame} represents the obser
With a \emph{GRiwrmInputsModel} object, all arguments are applied on each sub-catchments of the network.
Parameter regularisation consists of defining a priori parameters which are used in a composed criterion based on the formula proposed by de Lavenne et al. (2019) (See \link[airGR:CreateInputsCrit_Lavenne]{airGR::CreateInputsCrit_Lavenne}).
The parameter \code{AprioriIds} allows to define which upstream sub-catchment is used for providing a priori parameters. Its format is as follows: \code{AprioriIds <- c("Downstream sub-catchment 1" = "A priori upstream sub-catchment 1", ...)} where the quoted strings are the ids of the sub-catchments. See vignettes for more details.
Parameter regularisation consists of defining a priori parameters which are used in a composed criterion based on the formula proposed by Lavenne et al. (2019) (See \link[airGR:CreateInputsCrit_Lavenne]{airGR::CreateInputsCrit_Lavenne}).
The parameter \code{AprioriIds} allows to define which upstream sub-catchment is used for providing a priori parameters. Its format is as follows: \code{AprioriIds <- c("Downstream sub-catchment 1" = "A priori upstream sub-catchment 1", ...)} where the quoted strings are the ids of the sub-catchments. See vignettes for more details. The parameter \code{AprCelerity} is a default value used as a priori for the parameter 'Celerity' in case of an upstream catchment (without celerity parameter) is used as a priori catchment.
}
\references{
De Lavenne, A., Andréassian, V., Thirel, G., Ramos, M.-H., Perrin, C., 2019. A Regularization Approach to Improve the Sequential Calibration of a Semidistributed Hydrological Model. Water Resources Research 55, 8821–8839. \doi{10.1029/2018WR024266}
......
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