Commit 5951ebb9 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.2.13.0 NEW: add ISHyst argument in CreateIniStates

parent dd1361d7
Package: airGR Package: airGR
Type: Package Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.2.12.34 Version: 1.2.13.0
Date: 2019-04-01 Date: 2019-04-01
Authors@R: c( Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
...@@ -13,7 +13,7 @@ output: ...@@ -13,7 +13,7 @@ output:
### 1.2.12.34 Release Notes (2019-04-01) ### 1.2.13.0 Release Notes (2019-04-01)
...@@ -41,7 +41,7 @@ output: ...@@ -41,7 +41,7 @@ output:
- <code>CreateInputsCrit()</code> now returns a <code>idLayer</code> element to indicate which layer to use for SCA or SWE aggregation. - <code>CreateInputsCrit()</code> now returns a <code>idLayer</code> element to indicate which layer to use for SCA or SWE aggregation.
- <code>CreateRunOptions()</code> now presents a <code>IsHyst</code> argument to give the possibility to use the hysteresis with CemaNeige. - <code>CreateRunOptions()</code>, <code>CreateIniStates()</code> and <code>CreateCalibOptions()</code> now present a <code>IsHyst</code> argument to give the possibility to use the hysteresis with CemaNeige.
- <code>CreateRunOptions()</code> now presents a <code>warnings</code> argument to replace the verbose action (the <code>verbose</code> argument is kept to print messages). - <code>CreateRunOptions()</code> now presents a <code>warnings</code> argument to replace the verbose action (the <code>verbose</code> argument is kept to print messages).
......
CreateIniStates <- function(FUN_MOD, InputsModel, CreateIniStates <- function(FUN_MOD, InputsModel, IsHyst = FALSE,
ProdStore = 350, RoutStore = 90, ExpStore = NULL, ProdStore = 350, RoutStore = 90, ExpStore = NULL,
UH1 = NULL, UH2 = NULL, UH1 = NULL, UH2 = NULL,
GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL, GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL,
...@@ -44,7 +44,10 @@ CreateIniStates <- function(FUN_MOD, InputsModel, ...@@ -44,7 +44,10 @@ CreateIniStates <- function(FUN_MOD, InputsModel,
BOOL <- TRUE BOOL <- TRUE
} }
if (!BOOL) { if (!BOOL) {
stop("Incorrect 'FUN_MOD' for use in 'CreateIniStates'") stop("incorrect 'FUN_MOD' for use in 'CreateIniStates'")
}
if (!"CemaNeige" %in% ObjectClass & IsHyst) {
stop("'IsHyst' cannot be TRUE if CemaNeige is not used in 'FUN_MOD'")
} }
## check InputsModel ## check InputsModel
...@@ -130,17 +133,32 @@ CreateIniStates <- function(FUN_MOD, InputsModel, ...@@ -130,17 +133,32 @@ CreateIniStates <- function(FUN_MOD, InputsModel,
} }
UH2 <- rep(Inf, UH2n) UH2 <- rep(Inf, UH2n)
} }
if("CemaNeige" %in% ObjectClass & if("CemaNeige" %in% ObjectClass & !IsHyst &
(is.null(GCemaNeigeLayers) | is.null(eTGCemaNeigeLayers))) { (is.null(GCemaNeigeLayers) | is.null(eTGCemaNeigeLayers))) {
stop(sprintf("'%s' need values for 'GCemaNeigeLayers' and 'GCemaNeigeLayers'", nameFUN_MOD)) stop(sprintf("'%s' need values for 'GCemaNeigeLayers' and 'GCemaNeigeLayers'", nameFUN_MOD))
}
if("CemaNeige" %in% ObjectClass & IsHyst &
(is.null(GCemaNeigeLayers) | is.null(eTGCemaNeigeLayers) |
is.null(GthrCemaNeigeLayers) | is.null(GlocmaxCemaNeigeLayers))) {
stop(sprintf("'%s' need values for 'GCemaNeigeLayers', 'GCemaNeigeLayers', 'GthrCemaNeigeLayers' and 'GlocmaxCemaNeigeLayers'", nameFUN_MOD))
}
if("CemaNeige" %in% ObjectClass & !IsHyst &
(!is.null(GthrCemaNeigeLayers) | !is.null(GlocmaxCemaNeigeLayers))) {
if (verbose) {
warning(sprintf("'%s' does not require 'GthrCemaNeigeLayers' and 'GlocmaxCemaNeigeLayers'. Values set to NA", nameFUN_MOD))
}
GthrCemaNeigeLayers <- Inf
GlocmaxCemaNeigeLayers <- Inf
} }
if(!"CemaNeige" %in% ObjectClass & if(!"CemaNeige" %in% ObjectClass &
(!is.null(GCemaNeigeLayers) | !is.null(eTGCemaNeigeLayers))) { (!is.null(GCemaNeigeLayers) | !is.null(eTGCemaNeigeLayers) | !is.null(GthrCemaNeigeLayers) | !is.null(GlocmaxCemaNeigeLayers))) {
if (verbose) { if (verbose) {
warning(sprintf("'%s' does not require 'GCemaNeigeLayers' and 'GCemaNeigeLayers'. Values set to NA", nameFUN_MOD)) warning(sprintf("'%s' does not require 'GCemaNeigeLayers' 'GCemaNeigeLayers', 'GthrCemaNeigeLayers' and 'GlocmaxCemaNeigeLayers'. Values set to NA", nameFUN_MOD))
} }
GCemaNeigeLayers <- Inf GCemaNeigeLayers <- Inf
eTGCemaNeigeLayers <- Inf eTGCemaNeigeLayers <- Inf
GthrCemaNeigeLayers <- Inf
GlocmaxCemaNeigeLayers <- Inf
} }
...@@ -222,6 +240,14 @@ CreateIniStates <- function(FUN_MOD, InputsModel, ...@@ -222,6 +240,14 @@ CreateIniStates <- function(FUN_MOD, InputsModel,
if (!is.numeric(eTGCemaNeigeLayers) || length(eTGCemaNeigeLayers) != NLayers) { if (!is.numeric(eTGCemaNeigeLayers) || length(eTGCemaNeigeLayers) != NLayers) {
stop(sprintf("'eTGCemaNeigeLayers' must be numeric of length %i", NLayers)) stop(sprintf("'eTGCemaNeigeLayers' must be numeric of length %i", NLayers))
} }
if (IsHyst) {
if (!is.numeric(GthrCemaNeigeLayers) || length(GthrCemaNeigeLayers) != NLayers) {
stop(sprintf("'eTGCemaNeigeLayers' must be numeric of length %i", NLayers))
}
if (!is.numeric(GlocmaxCemaNeigeLayers) || length(GlocmaxCemaNeigeLayers) != NLayers) {
stop(sprintf("'eTGCemaNeigeLayers' must be numeric of length %i", NLayers))
}
}
## format output ## format output
...@@ -234,6 +260,10 @@ CreateIniStates <- function(FUN_MOD, InputsModel, ...@@ -234,6 +260,10 @@ CreateIniStates <- function(FUN_MOD, InputsModel,
IniStatesNA <- relist(IniStatesNA, skeleton = IniStates) IniStatesNA <- relist(IniStatesNA, skeleton = IniStates)
class(IniStatesNA) <- c("IniStates", ObjectClass) class(IniStatesNA) <- c("IniStates", ObjectClass)
if(IsHyst) {
class(IniStatesNA) <- c(class(IniStatesNA), "hysteresis")
}
return(IniStatesNA) return(IniStatesNA)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
\usage{ \usage{
CreateIniStates(FUN_MOD, InputsModel, CreateIniStates(FUN_MOD, InputsModel, IsHyst = FALSE,
ProdStore = 350, RoutStore = 90, ExpStore = NULL, ProdStore = 350, RoutStore = 90, ExpStore = NULL,
UH1 = NULL, UH2 = NULL, UH1 = NULL, UH2 = NULL,
GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL, GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL,
...@@ -23,6 +23,8 @@ CreateIniStates(FUN_MOD, InputsModel, ...@@ -23,6 +23,8 @@ CreateIniStates(FUN_MOD, InputsModel,
\item{InputsModel}{[object of class \code{InputsModel}] see \code{\link{CreateInputsModel}} for details} \item{InputsModel}{[object of class \code{InputsModel}] see \code{\link{CreateInputsModel}} for details}
\item{IsHyst}{[boolean] boolean indicating if the hysteresis version of CemaNeige is used. See details}
\item{ProdStore}{[numeric] production store level [mm]} \item{ProdStore}{[numeric] production store level [mm]}
\item{RoutStore}{[numeric] routing store level [mm]} \item{RoutStore}{[numeric] routing store level [mm]}
......
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