Commit 8838c840 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.1.2.32 CLEAN: minor typo revisions in CreateRunOptions

parent 544a6a46
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.1.2.31
Version: 1.1.2.32
Date: 2019-01-18
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -13,7 +13,7 @@ output:
### 1.1.2.31 Release Notes (2019-01-18)
### 1.1.2.32 Release Notes (2019-01-18)
......
......@@ -5,7 +5,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
warnings = TRUE, verbose = TRUE) {
if (!missing(RunSnowModule)) {
warning("argument RunSnowModule is deprecated; please adapt FUN_MOD instead.", call. = FALSE)
warning("argument 'RunSnowModule' is deprecated; please adapt 'FUN_MOD' instead.", call. = FALSE)
}
ObjectClass <- NULL
......@@ -37,60 +37,60 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
BOOL <- TRUE
}
if (!BOOL) {
stop("incorrect FUN_MOD for use in CreateRunOptions \n")
stop("incorrect 'FUN_MOD' for use in 'CreateRunOptions' \n")
return(NULL)
}
##check_InputsModel
if (!inherits(InputsModel, "InputsModel")) {
stop("InputsModel must be of class 'InputsModel' \n")
stop("'InputsModel' must be of class 'InputsModel' \n")
return(NULL)
}
if ("GR" %in% ObjectClass & !inherits(InputsModel, "GR")) {
stop("InputsModel must be of class 'GR' \n")
stop("'InputsModel' must be of class 'GR' \n")
return(NULL)
}
if ("CemaNeige" %in% ObjectClass &
!inherits(InputsModel, "CemaNeige")) {
stop("InputsModel must be of class 'CemaNeige' \n")
stop("'InputsModel' must be of class 'CemaNeige' \n")
return(NULL)
}
if ("hourly" %in% ObjectClass &
!inherits(InputsModel, "hourly")) {
stop("InputsModel must be of class 'hourly' \n")
stop("'InputsModel' must be of class 'hourly' \n")
return(NULL)
}
if ("daily" %in% ObjectClass & !inherits(InputsModel, "daily")) {
stop("InputsModel must be of class 'daily' \n")
stop("'InputsModel' must be of class 'daily' \n")
return(NULL)
}
if ("monthly" %in% ObjectClass &
!inherits(InputsModel, "monthly")) {
stop("InputsModel must be of class 'monthly' \n")
stop("'InputsModel' must be of class 'monthly' \n")
return(NULL)
}
if ("yearly" %in% ObjectClass &
!inherits(InputsModel, "yearly")) {
stop("InputsModel must be of class 'yearly' \n")
stop("'InputsModel' must be of class 'yearly' \n")
return(NULL)
}
##check_IndPeriod_Run
if (!is.vector(IndPeriod_Run)) {
stop("IndPeriod_Run must be a vector of numeric values \n")
stop("'IndPeriod_Run' must be a vector of numeric values \n")
return(NULL)
}
if (!is.numeric(IndPeriod_Run)) {
stop("IndPeriod_Run must be a vector of numeric values \n")
stop("'IndPeriod_Run' must be a vector of numeric values \n")
return(NULL)
}
if (identical(as.integer(IndPeriod_Run), as.integer(seq(from = IndPeriod_Run[1], to = tail(IndPeriod_Run, 1), by = 1))) == FALSE) {
stop("IndPeriod_Run must be a continuous sequence of integers \n")
stop("'IndPeriod_Run' must be a continuous sequence of integers \n")
return(NULL)
}
if (storage.mode(IndPeriod_Run) != "integer") {
stop("IndPeriod_Run should be of type integer \n")
stop("'IndPeriod_Run' should be of type integer \n")
return(NULL)
}
......@@ -162,7 +162,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
if ("GR" %in% ObjectClass & ("monthly" %in% ObjectClass | "daily" %in% ObjectClass | "hourly" %in% ObjectClass)) {
if (!is.null(IniResLevels)) {
if (!is.vector(IniResLevels) | !is.numeric(IniResLevels) | any(is.na(IniResLevels))) {
stop("IniResLevels must be a vector of numeric values \n")
stop("'IniResLevels' must be a vector of numeric values \n")
return(NULL)
}
if ((identical(FUN_MOD, RunModel_GR4H) |
......@@ -170,12 +170,12 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
identical(FUN_MOD, RunModel_GR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J) |
identical(FUN_MOD, RunModel_GR2M)) &
length(IniResLevels) != 2) {
stop("The length of IniResLevels must be 2 for the chosen FUN_MOD \n")
stop("The length of 'IniResLevels' must be 2 for the chosen 'FUN_MOD' \n")
return(NULL)
}
if ((identical(FUN_MOD,RunModel_GR6J) | identical(FUN_MOD,RunModel_CemaNeigeGR6J)) &
length(IniResLevels) != 3) {
stop("The length of IniResLevels must be 3 for the chosen FUN_MOD \n")
stop("The length of 'IniResLevels' must be 3 for the chosen 'FUN_MOD' \n")
return(NULL)
}
} else if (is.null(IniStates)) {
......@@ -187,7 +187,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
}
} else {
if (!is.null(IniResLevels)) {
stop("IniResLevels can only be used with monthly or daily or hourly GR models \n")
stop("'IniResLevels' can only be used with monthly or daily or hourly GR models \n")
}
}
## check IniStates
......@@ -195,7 +195,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
warning("\t Model states initialisation not defined -> default configuration used \n")
}
if (!is.null(IniStates) & !is.null(IniResLevels) & warnings) {
warning("\t IniStates and IniResLevels are both defined -> Store levels are taken from IniResLevels \n")
warning("\t 'IniStates' and 'IniResLevels' are both defined -> Store levels are taken from 'IniResLevels' \n")
}
if ("CemaNeige" %in% ObjectClass) {
NLayers <- length(InputsModel$LayerPrecip)
......@@ -220,27 +220,27 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
if (!is.null(IniStates)) {
if (!inherits(IniStates, "IniStates")) {
stop("IniStates must be an object of class IniStates\n")
stop("'IniStates' must be an object of class 'IniStates'\n")
return(NULL)
}
if (sum(ObjectClass %in% class(IniStates)) < 2) {
stop(paste0("Non convenient IniStates for this FUN_MOD\n"))
stop(paste0("Non convenient 'IniStates' for this 'FUN_MOD'\n"))
return(NULL)
}
if (identical(FUN_MOD, RunModel_GR1A) & !is.null(IniStates)) { ## GR1A
stop(paste0("IniStates is not available for this FUN_MOD\n"))
stop(paste0("'IniStates' is not available for this 'FUN_MOD'\n"))
return(NULL)
}
if ((identical(FUN_MOD, RunModel_GR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J)) & !all(is.na(IniStates$UH$UH1))) { ## GR5J
stop(paste0("Non convenient IniStates for this FUN_MOD. In IniStates, UH1 has to be a vector of NA for GR5J \n"))
stop(paste0("Non convenient IniStates for this 'FUN_MOD.' In 'IniStates', UH1 has to be a vector of NA for GR5J \n"))
return(NULL)
}
if ((identical(FUN_MOD, RunModel_GR6J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J)) & is.na(IniStates$Store$Exp)) { ## GR6J
stop(paste0("Non convenient IniStates for this FUN_MOD. GR6J needs an exponential store value in IniStates \n"))
stop(paste0("Non convenient IniStates for this 'FUN_MOD.' GR6J needs an exponential store value in 'IniStates' \n"))
return(NULL)
}
if (!(identical(FUN_MOD, RunModel_GR6J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J)) & !is.na(IniStates$Store$Exp)) { ## except GR6J
stop(paste0("Non convenient IniStates for this FUN_MOD. No exponential store value needed in IniStates \n"))
stop(paste0("Non convenient IniStates for this 'FUN_MOD.' No exponential store value needed in 'IniStates' \n"))
return(NULL)
}
# if (length(na.omit(unlist(IniStates))) != NState) {
......@@ -269,7 +269,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
##Outputs_all
Outputs_all <- NULL
if (identical(FUN_MOD,RunModel_GR4H)) {
Outputs_all <- c(Outputs_all,"PotEvap","Precip","Prod","AE","Perc","PR","Q9","Q1","Rout","Exch","AExch","QR","QD","Qsim")
Outputs_all <- c(Outputs_all,"PotEvap", "Precip", "Prod", "AE", "Perc", "PR", "Q9", "Q1", "Rout", "Exch", "AExch", "QR", "QD", "Qsim")
}
if (identical(FUN_MOD,RunModel_GR4J) | identical(FUN_MOD,RunModel_CemaNeigeGR4J)) {
Outputs_all <- c(Outputs_all,"PotEvap", "Precip", "Prod", "Pn", "Ps", "AE", "Perc", "PR", "Q9", "Q1", "Rout", "Exch",
......@@ -287,10 +287,10 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
Outputs_all <- c(Outputs_all,"PotEvap", "Precip", "AE", "Pn", "Perc", "PR", "Exch", "Prod", "Rout", "Qsim")
}
if (identical(FUN_MOD,RunModel_GR1A)) {
Outputs_all <- c(Outputs_all,"PotEvap","Precip","Qsim")
Outputs_all <- c(Outputs_all,"PotEvap", "Precip", "Qsim")
}
if ("CemaNeige" %in% ObjectClass) {
Outputs_all <- c(Outputs_all,"Pliq","Psol","SnowPack","ThermalState","Gratio","PotMelt","Melt","PliqAndMelt", "Temp")
Outputs_all <- c(Outputs_all,"Pliq", "Psol", "SnowPack", "ThermalState", "Gratio", "PotMelt", "Melt", "PliqAndMelt", "Temp")
}
##check_Outputs_Sim
......@@ -311,7 +311,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
}
Test <- which(Outputs_Sim %in% c("DatesR", Outputs_all, "StateEnd") == FALSE)
if (length(Test) != 0) {
stop(paste0( "Outputs_Sim is incorrectly defined: ",
stop(paste0( "'Outputs_Sim' is incorrectly defined: ",
paste(Outputs_Sim[Test], collapse = ", "), " not found \n"))
return(NULL)
......@@ -333,15 +333,15 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
}
} else {
if (!is.vector(Outputs_Cal)) {
stop("Outputs_Cal must be a vector of characters \n")
stop("'Outputs_Cal' must be a vector of characters \n")
return(NULL)
}
if (!is.character(Outputs_Cal)) {
stop("Outputs_Cal must be a vector of characters \n")
stop("'Outputs_Cal' must be a vector of characters \n")
return(NULL)
}
if (sum(is.na(Outputs_Cal)) != 0) {
stop("Outputs_Cal must not contain NA \n")
stop("'Outputs_Cal' must not contain NA \n")
return(NULL)
}
}
......@@ -352,7 +352,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
Test <-
which(Outputs_Cal %in% c("DatesR", Outputs_all, "StateEnd") == FALSE)
if (length(Test) != 0) {
stop(paste0("Outputs_Cal is incorrectly defined: ",
stop(paste0("'Outputs_Cal' is incorrectly defined: ",
paste(Outputs_Cal[Test], collapse = ", "), " not found \n"))
return(NULL)
......@@ -388,7 +388,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
Factor <- 1
}
if (is.null(Factor)) {
stop("InputsModel must be of class 'hourly', 'daily', 'monthly' or 'yearly' \n")
stop("'InputsModel' must be of class 'hourly', 'daily', 'monthly' or 'yearly' \n")
return(NULL)
}
MeanAnSolidPrecip <- rep(mean(SolidPrecip) * Factor, NLayers)
......@@ -401,15 +401,15 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
}
if ("CemaNeige" %in% ObjectClass & !is.null(MeanAnSolidPrecip)) {
if (!is.vector(MeanAnSolidPrecip)) {
stop(paste0("MeanAnSolidPrecip must be a vector of numeric values \n"))
stop(paste0("'MeanAnSolidPrecip' must be a vector of numeric values \n"))
return(NULL)
}
if (!is.numeric(MeanAnSolidPrecip)) {
stop(paste0("MeanAnSolidPrecip must be a vector of numeric values \n"))
stop(paste0("'MeanAnSolidPrecip' must be a vector of numeric values \n"))
return(NULL)
}
if (length(MeanAnSolidPrecip) != NLayers) {
stop(paste0("MeanAnSolidPrecip must be a numeric vector of length ", NLayers, " \n"))
stop(paste0("'MeanAnSolidPrecip' must be a numeric vector of length ", NLayers, " \n"))
return(NULL)
}
}
......@@ -419,7 +419,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
if ("GR" %in% ObjectClass & "CemaNeige" %in% ObjectClass) {
if ("PliqAndMelt" %in% Outputs_Cal == FALSE & "all" %in% Outputs_Cal == FALSE) {
WTxt <- NULL
WTxt <- paste0(WTxt, "\t PliqAndMelt was not defined in Outputs_Cal but is needed to feed the hydrological model with the snow modele outputs \n")
WTxt <- paste0(WTxt, "\t 'PliqAndMelt' was not defined in 'Outputs_Cal' but is needed to feed the hydrological model with the snow modele outputs \n")
WTxt <- paste0(WTxt, "\t -> it was automatically added \n")
if (!is.null(WTxt) & warnings) {
warning(WTxt)
......@@ -428,7 +428,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP
}
if ("PliqAndMelt" %in% Outputs_Sim == FALSE & "all" %in% Outputs_Sim == FALSE) {
WTxt <- NULL
WTxt <- paste0(WTxt, "\t PliqAndMelt was not defined in Outputs_Sim but is needed to feed the hydrological model with the snow modele outputs \n")
WTxt <- paste0(WTxt, "\t 'PliqAndMelt' was not defined in 'Outputs_Sim' but is needed to feed the hydrological model with the snow modele outputs \n")
WTxt <- paste0(WTxt, "\t -> it was automatically added \n")
if (!is.null(WTxt) & warnings) {
warning(WTxt)
......
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