From 6f7636b16922c33a105a56a3d548a3076de94368 Mon Sep 17 00:00:00 2001 From: unknown <olivier.delaigue@ANPI1430.antony.irstea.priv> Date: Wed, 21 Jun 2017 18:18:17 +0200 Subject: [PATCH] v1.0.8.5 RunModel functions check if Param is numeric and new warning message when X2 < 1e-2 in RunModel _GR2M --- DESCRIPTION | 2 +- R/RunModel_CemaNeige.R | 2 +- R/RunModel_CemaNeigeGR4J.R | 2 +- R/RunModel_CemaNeigeGR5J.R | 2 +- R/RunModel_CemaNeigeGR6J.R | 2 +- R/RunModel_GR1A.R | 2 +- R/RunModel_GR2M.R | 14 +++++++++----- R/RunModel_GR4H.R | 2 +- R/RunModel_GR4J.R | 2 +- R/RunModel_GR5J.R | 2 +- R/RunModel_GR6J.R | 2 +- 11 files changed, 19 insertions(+), 15 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 588d1f05..b769dd27 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.0.8.4 +Version: 1.0.8.5 Date: 2017-06-21 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl")), diff --git a/R/RunModel_CemaNeige.R b/R/RunModel_CemaNeige.R index 24245d9f..fa4e637e 100644 --- a/R/RunModel_CemaNeige.R +++ b/R/RunModel_CemaNeige.R @@ -9,7 +9,7 @@ RunModel_CemaNeige <- function(InputsModel,RunOptions,Param){ if(inherits(InputsModel,"CemaNeige" )==FALSE){ stop("InputsModel must be of class 'CemaNeige' \n"); return(NULL); } if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' \n"); return(NULL); } if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("RunOptions must be of class 'CemaNeige' \n"); return(NULL); } - if(!is.vector(Param)){ stop("Param must be a vector \n"); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector \n"); return(NULL); } if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA \n",sep="")); return(NULL); } Param <- as.double(Param); diff --git a/R/RunModel_CemaNeigeGR4J.R b/R/RunModel_CemaNeigeGR4J.R index 01f1ecfb..85ed537e 100644 --- a/R/RunModel_CemaNeigeGR4J.R +++ b/R/RunModel_CemaNeigeGR4J.R @@ -13,7 +13,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' \n"); return(NULL); } if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' \n"); return(NULL); } if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("RunOptions must be of class 'CemaNeige' \n"); return(NULL); } - if(!is.vector(Param)){ stop("Param must be a vector \n"); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector \n"); return(NULL); } if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA \n",sep="")); return(NULL); } Param <- as.double(Param); diff --git a/R/RunModel_CemaNeigeGR5J.R b/R/RunModel_CemaNeigeGR5J.R index 9e9816d1..b0c9206d 100644 --- a/R/RunModel_CemaNeigeGR5J.R +++ b/R/RunModel_CemaNeigeGR5J.R @@ -13,7 +13,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){ if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' \n"); return(NULL); } if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' \n"); return(NULL); } if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("RunOptions must be of class 'CemaNeige' \n"); return(NULL); } - if(!is.vector(Param)){ stop("Param must be a vector \n"); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector \n"); return(NULL); } if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA \n",sep="")); return(NULL); } Param <- as.double(Param); diff --git a/R/RunModel_CemaNeigeGR6J.R b/R/RunModel_CemaNeigeGR6J.R index 50d87cf7..b8365fce 100644 --- a/R/RunModel_CemaNeigeGR6J.R +++ b/R/RunModel_CemaNeigeGR6J.R @@ -13,7 +13,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){ if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' \n"); return(NULL); } if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' \n"); return(NULL); } if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("RunOptions must be of class 'CemaNeige' \n"); return(NULL); } - if(!is.vector(Param)){ stop("Param must be a vector \n"); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector \n"); return(NULL); } if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA \n",sep="")); return(NULL); } Param <- as.double(Param); diff --git a/R/RunModel_GR1A.R b/R/RunModel_GR1A.R index 5c400d92..07be9d0b 100644 --- a/R/RunModel_GR1A.R +++ b/R/RunModel_GR1A.R @@ -9,7 +9,7 @@ RunModel_GR1A <- function(InputsModel,RunOptions,Param){ if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' \n"); return(NULL); } if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' \n"); return(NULL); } if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' \n"); return(NULL); } - if(!is.vector(Param)){ stop("Param must be a vector \n"); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector \n"); return(NULL); } if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA \n",sep="")); return(NULL); } Param <- as.double(Param); diff --git a/R/RunModel_GR2M.R b/R/RunModel_GR2M.R index d6e029a5..74b8ab3a 100644 --- a/R/RunModel_GR2M.R +++ b/R/RunModel_GR2M.R @@ -9,14 +9,18 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param){ if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' \n"); return(NULL); } if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' \n"); return(NULL); } if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' \n"); return(NULL); } - if(!is.vector(Param)){ stop("Param must be a vector \n"); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector \n"); return(NULL); } if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA \n",sep="")); return(NULL); } Param <- as.double(Param); - Param_X1_threshold <- 1e-2 - if (Param[1L] < Param_X1_threshold) { - warning(sprintf("Param[1] (X1: production store capacity [mm]) < %.2f\n X1 set to %.2f", Param_X1_threshold, Param_X1_threshold)) - Param[1L] <- Param_X1_threshold + Param_X1X2_threshold <- 1e-2 + if (Param[1L] < Param_X1X2_threshold) { + warning(sprintf("Param[1] (X1: production store capacity [mm]) < %.2f\n X1 set to %.2f", Param_X1X2_threshold, Param_X1X2_threshold)) + Param[1L] <- Param_X1X2_threshold + } + if (Param[2L] < Param_X1X2_threshold) { + warning(sprintf("Param[2] (X2: routing store capacity [mm]) < %.2f\n X2 set to %.2f", Param_X1X2_threshold, Param_X1X2_threshold)) + Param[2L] <- Param_X1X2_threshold } ##Input_data_preparation diff --git a/R/RunModel_GR4H.R b/R/RunModel_GR4H.R index 0333c972..eab3cc3a 100644 --- a/R/RunModel_GR4H.R +++ b/R/RunModel_GR4H.R @@ -9,7 +9,7 @@ RunModel_GR4H <- function(InputsModel,RunOptions,Param){ if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' \n"); return(NULL); } if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' \n"); return(NULL); } if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' \n"); return(NULL); } - if(!is.vector(Param)){ stop("Param must be a vector \n"); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector \n"); return(NULL); } if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA \n",sep="")); return(NULL); } Param <- as.double(Param); diff --git a/R/RunModel_GR4J.R b/R/RunModel_GR4J.R index 2e522ffe..151032ad 100644 --- a/R/RunModel_GR4J.R +++ b/R/RunModel_GR4J.R @@ -10,7 +10,7 @@ RunModel_GR4J <- function(InputsModel,RunOptions,Param){ if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' \n"); return(NULL); } if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' \n"); return(NULL); } if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' \n"); return(NULL); } - if(!is.vector(Param)){ stop("Param must be a vector \n"); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector \n"); return(NULL); } if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA \n",sep="")); return(NULL); } Param <- as.double(Param); diff --git a/R/RunModel_GR5J.R b/R/RunModel_GR5J.R index 489f3410..ac5b26b5 100644 --- a/R/RunModel_GR5J.R +++ b/R/RunModel_GR5J.R @@ -10,7 +10,7 @@ RunModel_GR5J <- function(InputsModel,RunOptions,Param){ if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' \n"); return(NULL); } if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' \n"); return(NULL); } if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' \n"); return(NULL); } - if(!is.vector(Param)){ stop("Param must be a vector \n"); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector \n"); return(NULL); } if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA \n",sep="")); return(NULL); } Param <- as.double(Param); diff --git a/R/RunModel_GR6J.R b/R/RunModel_GR6J.R index c2ca3b38..6e936306 100644 --- a/R/RunModel_GR6J.R +++ b/R/RunModel_GR6J.R @@ -10,7 +10,7 @@ RunModel_GR6J <- function(InputsModel,RunOptions,Param){ if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' \n"); return(NULL); } if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' \n"); return(NULL); } if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' \n"); return(NULL); } - if(!is.vector(Param)){ stop("Param must be a vector \n"); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector \n"); return(NULL); } if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA \n",sep="")); return(NULL); } Param <- as.double(Param); -- GitLab