Commit 77f28f73 authored by unknown's avatar unknown
Browse files

v1.0.5.7 plot.OutputsModel stop when CemaNeige is used and the which argument...

v1.0.5.7 plot.OutputsModel stop when CemaNeige is used and the which argument only = "Temp" or "SnowPack"
Showing with 20 additions and 6 deletions
+20 -6
...@@ -2,7 +2,10 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = ...@@ -2,7 +2,10 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
OutputsModel <- x OutputsModel <- x
if(!inherits(OutputsModel, "GR") & !inherits(OutputsModel, "CemaNeige")){ stop(paste("OutputsModel not in the correct format for default plotting \n", sep = "")); return(NULL); } if(!inherits(OutputsModel, "GR") & !inherits(OutputsModel, "CemaNeige")){
stop(paste("OutputsModel not in the correct format for default plotting \n", sep = ""))
return(NULL)
}
BOOL_Dates <- FALSE; BOOL_Dates <- FALSE;
if("DatesR" %in% names(OutputsModel)){ BOOL_Dates <- TRUE; } if("DatesR" %in% names(OutputsModel)){ BOOL_Dates <- TRUE; }
...@@ -21,11 +24,22 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = ...@@ -21,11 +24,22 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
if( is.null( which)){ stop("which must be a vector of character \n"); return(NULL); } if( is.null( which)){ stop("which must be a vector of character \n"); return(NULL); }
if(!is.vector( which)){ stop("which must be a vector of character \n"); return(NULL); } if(!is.vector( which)){ stop("which must be a vector of character \n"); return(NULL); }
if(!is.character(which)){ stop("which must be a vector of character \n"); return(NULL); } if(!is.character(which)){ stop("which must be a vector of character \n"); return(NULL); }
if(sum(which %in% c("all", "Precip", 'Temp', "SnowPack", "Flows", "Regime", "CumFreq", "CorQQ") == FALSE) != 0){ if (any(!which %in% c("all", "Precip", 'Temp', "SnowPack", "Flows", "Regime", "CumFreq", "CorQQ"))) {
cat("Incorrect element found in which \n"); stop("Incorrect element found in argument which:\nit can only contain 'all', 'Precip', 'Temp', 'SnowPack', 'Flows', 'Regime', 'CumFreq' or 'CorQQ'")
stop("which can only contain 'all', 'Precip', 'Temp', 'SnowPack', 'Flows', 'Regime', 'CumFreq' or 'CorQQ') \n"); return(NULL)
return(NULL); } }
if("all" %in% which){ which <- c("Precip", "Temp", "SnowPack", "Flows", "Regime", "CumFreq", "CorQQ"); } if (all(which %in% c("Temp", "SnowPack")) & !inherits(OutputsModel, "CemaNeige")) {
stop("Incorrect element found in argument which:\nwithout CemaNeige it can only contain 'all', 'Precip', 'Flows', 'Regime', 'CumFreq' or 'CorQQ'")
return(NULL)
}
if (length(unique(which %in% c("Temp", "SnowPack"))) == 2 & !inherits(OutputsModel, "CemaNeige")) {
warning("Incorrect element found in argument which:\nit can only contain 'all', 'Precip', 'Flows', 'Regime', 'CumFreq' or 'CorQQ'\nwithout CemaNeige 'Temp' and 'SnowPack' are not available")
}
if ("all" %in% which) {
which <- c("Precip", "Temp", "SnowPack", "Flows", "Regime", "CumFreq", "CorQQ")
}
if(!BOOL_Dates){ if(!BOOL_Dates){
stop(paste("OutputsModel must contain at least DatesR to allow plotting \n", sep = "")); return(NULL); } stop(paste("OutputsModel must contain at least DatesR to allow plotting \n", sep = "")); return(NULL); }
......
Supports Markdown
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