diff --git a/DESCRIPTION b/DESCRIPTION index 3be854470ec7bf71f7c537968f30c8a53fc03291..15d19719c9e42d17f77d62bf28d980e7380fd2ea 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.2.7.1 -Date: 2019-02-28 +Version: 1.2.7.2 +Date: 2019-03-01 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), person("Charles", "Perrin", role = c("aut", "ths"), comment = c(ORCID = "0000-0001-8552-1881")), diff --git a/NEWS.rmd b/NEWS.rmd index 0fc45a5f7a9cbe6ad0938d18516036bb118c9ed6..187aaee251afd8d8cf410094aadfb1d648d09264 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -13,7 +13,7 @@ output: -### 1.2.7.1 Release Notes (2019-02-28) +### 1.2.7.2 Release Notes (2019-03-01) diff --git a/R/Calibration_Michel.R b/R/Calibration_Michel.R index b21367c0538ba8a3c6835c32ab43ecc3d96e0483..5db59c9835b5c6c81acdf7e90461d95f8829beb6 100644 --- a/R/Calibration_Michel.R +++ b/R/Calibration_Michel.R @@ -4,27 +4,27 @@ Calibration_Michel <- function(InputsModel, RunOptions, InputsCrit, CalibOptions ##_____Arguments_check_____________________________________________________________________ if (!inherits(InputsModel, "InputsModel")) { - stop("InputsModel must be of class 'InputsModel' \n") + stop("InputsModel must be of class 'InputsModel'") return(NULL) } if (!inherits(RunOptions, "RunOptions")) { - stop("RunOptions must be of class 'RunOptions' \n") + stop("RunOptions must be of class 'RunOptions'") return(NULL) } if (!inherits(InputsCrit, "InputsCrit")) { - stop("InputsCrit must be of class 'InputsCrit' \n") + stop("InputsCrit must be of class 'InputsCrit'") return(NULL) } if (inherits(InputsCrit, "Multi")) { - stop("InputsCrit must be of class 'Single' or 'Compo' \n") + stop("InputsCrit must be of class 'Single' or 'Compo'") return(NULL) } if (!inherits(CalibOptions, "CalibOptions")) { - stop("CalibOptions must be of class 'CalibOptions' \n") + stop("CalibOptions must be of class 'CalibOptions'") return(NULL) } if (!inherits(CalibOptions, "HBAN")) { - stop("CalibOptions must be of class 'HBAN' if Calibration_Michel is used \n") + stop("CalibOptions must be of class 'HBAN' if Calibration_Michel is used") return(NULL) } if (!missing(FUN_CRIT)) { @@ -91,7 +91,7 @@ Calibration_Michel <- function(InputsModel, RunOptions, InputsCrit, CalibOptions } } if (is.null(FUN_TRANSFO)) { - stop("FUN_TRANSFO was not found (in Calibration function) \n") + stop("FUN_TRANSFO was not found (in Calibration function)") return(NULL) } } @@ -114,7 +114,7 @@ Calibration_Michel <- function(InputsModel, RunOptions, InputsCrit, CalibOptions NParam <- ncol(CalibOptions$StartParamDistrib) } if (NParam > 20) { - stop("Calibration_Michel can handle a maximum of 20 parameters \n") + stop("Calibration_Michel can handle a maximum of 20 parameters") return(NULL) } HistParamR <- matrix(NA, nrow = 500 * NParam, ncol = NParam) @@ -237,11 +237,11 @@ Calibration_Michel <- function(InputsModel, RunOptions, InputsCrit, CalibOptions ProposeCandidatesLoc <- function(NewParamOptimT, OldParamOptimT, RangesT, OptimParam,Pace) { ##Format_checking if (nrow(NewParamOptimT) != 1 | nrow(OldParamOptimT) != 1) { - stop("each input set must be a matrix of one single line \n") + stop("each input set must be a matrix of one single line") return(NULL) } if (ncol(NewParamOptimT)!=ncol(OldParamOptimT) | ncol(NewParamOptimT) != length(OptimParam)) { - stop("each input set must have the same number of values \n") + stop("each input set must have the same number of values") return(NULL) } ##Proposal_of_new_parameter_sets ###(local search providing 2 * NParam-1 new sets) diff --git a/R/CreateCalibOptions.R b/R/CreateCalibOptions.R index 1035b2344c3da1e36701157ac98101adc6422b8d..aecc687b5456b2f2dd9c8eb194dc45a27bd1dfff 100644 --- a/R/CreateCalibOptions.R +++ b/R/CreateCalibOptions.R @@ -54,7 +54,7 @@ CreateCalibOptions <- BOOL <- TRUE } if (!BOOL) { - stop("incorrect FUN_MOD for use in CreateCalibOptions \n") + stop("incorrect FUN_MOD for use in CreateCalibOptions") return(NULL) } @@ -66,7 +66,7 @@ CreateCalibOptions <- BOOL <- TRUE } if (!BOOL) { - stop("incorrect FUN_CALIB for use in CreateCalibOptions \n") + stop("incorrect FUN_CALIB for use in CreateCalibOptions") return(NULL) } @@ -99,7 +99,7 @@ CreateCalibOptions <- FUN1 <- TransfoParam_CemaNeige } if (is.null(FUN1)) { - stop("FUN1 was not found \n") + stop("FUN1 was not found") return(NULL) } ##_set_FUN2 @@ -130,7 +130,7 @@ CreateCalibOptions <- } } if (is.null(FUN_TRANSFO)) { - stop("FUN_TRANSFO was not found \n") + stop("FUN_TRANSFO was not found") return(NULL) } @@ -171,19 +171,19 @@ CreateCalibOptions <- FixedParam <- rep(NA, NParam) } else { if (!is.vector(FixedParam)) { - stop("FixedParam must be a vector \n") + stop("FixedParam must be a vector") return(NULL) } if (length(FixedParam) != NParam) { - stop("Incompatibility between FixedParam length and FUN_MOD \n") + stop("Incompatibility between FixedParam length and FUN_MOD") return(NULL) } if (all(!is.na(FixedParam))) { - stop("At least one parameter must be not set (NA) \n") + stop("At least one parameter must be not set (NA)") return(NULL) } if (all(is.na(FixedParam))) { - warning("You have not set any parameter in \"FixedParam\" \n") + warning("You have not set any parameter in \"FixedParam\"") } } @@ -196,23 +196,23 @@ CreateCalibOptions <- } else { if (!is.matrix(SearchRanges)) { - stop("SearchRanges must be a matrix \n") + stop("SearchRanges must be a matrix") return(NULL) } if (!is.numeric(SearchRanges)) { - stop("SearchRanges must be a matrix of numeric values \n") + stop("SearchRanges must be a matrix of numeric values") return(NULL) } if (sum(is.na(SearchRanges)) != 0) { - stop("SearchRanges must not include NA values \n") + stop("SearchRanges must not include NA values") return(NULL) } if (nrow(SearchRanges) != 2) { - stop("SearchRanges must have 2 rows \n") + stop("SearchRanges must have 2 rows") return(NULL) } if (ncol(SearchRanges) != NParam) { - stop("Incompatibility between SearchRanges ncol and FUN_MOD \n") + stop("Incompatibility between SearchRanges ncol and FUN_MOD") return(NULL) } } @@ -279,37 +279,37 @@ CreateCalibOptions <- ##check_StartParamList_and_StartParamDistrib__format if ("HBAN" %in% ObjectClass & !is.null(StartParamList)) { if (!is.matrix(StartParamList)) { - stop("StartParamList must be a matrix \n") + stop("StartParamList must be a matrix") return(NULL) } if (!is.numeric(StartParamList)) { - stop("StartParamList must be a matrix of numeric values \n") + stop("StartParamList must be a matrix of numeric values") return(NULL) } if (sum(is.na(StartParamList)) != 0) { - stop("StartParamList must not include NA values \n") + stop("StartParamList must not include NA values") return(NULL) } if (ncol(StartParamList) != NParam) { - stop("Incompatibility between StartParamList ncol and FUN_MOD \n") + stop("Incompatibility between StartParamList ncol and FUN_MOD") return(NULL) } } if ("HBAN" %in% ObjectClass & !is.null(StartParamDistrib)) { if (!is.matrix(StartParamDistrib)) { - stop("StartParamDistrib must be a matrix \n") + stop("StartParamDistrib must be a matrix") return(NULL) } if (!is.numeric(StartParamDistrib[1, ])) { - stop("StartParamDistrib must be a matrix of numeric values \n") + stop("StartParamDistrib must be a matrix of numeric values") return(NULL) } if (sum(is.na(StartParamDistrib[1, ])) != 0) { - stop("StartParamDistrib must not include NA values on the first line \n") + stop("StartParamDistrib must not include NA values on the first line") return(NULL) } if (ncol(StartParamDistrib) != NParam) { - stop("Incompatibility between StartParamDistrib ncol and FUN_MOD \n") + stop("Incompatibility between StartParamDistrib ncol and FUN_MOD") return(NULL) } } diff --git a/R/CreateInputsCrit.R b/R/CreateInputsCrit.R index 15ef5c538ac29a6928c14de3a305c3d5c9df79eb..7c1e861dd68ebc23d512867cd5795f5cc3ef2ad6 100644 --- a/R/CreateInputsCrit.R +++ b/R/CreateInputsCrit.R @@ -39,7 +39,7 @@ CreateInputsCrit <- function(FUN_CRIT, ## check 'InputsModel' if (!inherits(InputsModel, "InputsModel")) { - stop("'InputsModel' must be of class 'InputsModel' \n") + stop("'InputsModel' must be of class 'InputsModel'") return(NULL) } @@ -51,7 +51,7 @@ CreateInputsCrit <- function(FUN_CRIT, ## check 'obs' vecObs <- unlist(obs) if (length(vecObs) %% LLL != 0 | !is.numeric(vecObs)) { - stop(sprintf("'obs' must be a (list of) vector(s) of numeric values of length %i \n", LLL), call. = FALSE) + stop(sprintf("'obs' must be a (list of) vector(s) of numeric values of length %i", LLL), call. = FALSE) } if (!is.list(obs)) { obs <- list(obs) @@ -108,14 +108,14 @@ CreateInputsCrit <- function(FUN_CRIT, ## check 'RunOptions' if (!inherits(RunOptions , "RunOptions")) { - stop("'RunOptions' must be of class 'RunOptions' \n") + stop("'RunOptions' must be of class 'RunOptions'") return(NULL) } ## check 'weights' if (length(listArgs$weights) > 1 & sum(unlist(listArgs$weights)) == 0 & !any(sapply(listArgs$weights, is.null))) { - stop("sum of 'weights' cannot be equal to zero \n") + stop("sum of 'weights' cannot be equal to zero") } @@ -125,10 +125,10 @@ CreateInputsCrit <- function(FUN_CRIT, ## preparation of warning messages inVarObs <- c("Q", "SCA", "SWE", "SD") - msgVarObs <- "'varObs' must be a (list of) character vector(s) and one of %s \n" + msgVarObs <- "'varObs' must be a (list of) character vector(s) and one of %s" msgVarObs <- sprintf(msgVarObs, paste(sapply(inVarObs, shQuote), collapse = ", ")) inTransfo <- c("", "sqrt", "log", "inv", "sort") - msgTransfo <- "'transfo' must be a (list of) character vector(s) and one of %s \n" + msgTransfo <- "'transfo' must be a (list of) character vector(s) and one of %s" msgTransfo <- sprintf(msgTransfo, paste(sapply(inTransfo, shQuote), collapse = ", ")) @@ -139,17 +139,17 @@ CreateInputsCrit <- function(FUN_CRIT, ## check 'FUN_CRIT' if (!(identical(iListArgs2$FUN_CRIT, ErrorCrit_NSE ) | identical(iListArgs2$FUN_CRIT, ErrorCrit_KGE ) | identical(iListArgs2$FUN_CRIT, ErrorCrit_KGE2) | identical(iListArgs2$FUN_CRIT, ErrorCrit_RMSE))) { - stop("incorrect 'FUN_CRIT' for use in 'CreateInputsCrit' \n", call. = FALSE) + stop("incorrect 'FUN_CRIT' for use in 'CreateInputsCrit'", call. = FALSE) return(NULL) } if (identical(iListArgs2$FUN_CRIT, ErrorCrit_RMSE) & length(listArgs$weights) > 1 & all(!is.null(unlist(listArgs$weights)))) { - stop("calculating a composite criterion with the RMSE is not allowed since RMSE is not an adimensional measure \n", call. = FALSE) + stop("calculating a composite criterion with the RMSE is not allowed since RMSE is not an adimensional measure", call. = FALSE) return(NULL) } ## check 'obs' if (!is.vector(iListArgs2$obs) | length(iListArgs2$obs) != LLL | !is.numeric(iListArgs2$obs)) { - stop(sprintf("'obs' must be a (list of) vector(s) of numeric values of length %i \n", LLL), call. = FALSE) + stop(sprintf("'obs' must be a (list of) vector(s) of numeric values of length %i", LLL), call. = FALSE) return(NULL) } @@ -158,11 +158,11 @@ CreateInputsCrit <- function(FUN_CRIT, iListArgs2$BoolCrit <- rep(TRUE, length(iListArgs2$obs)) } if (!is.logical(iListArgs2$BoolCrit)) { - stop("'BoolCrit' must be a (list of) vector(s) of boolean \n", call. = FALSE) + stop("'BoolCrit' must be a (list of) vector(s) of boolean", call. = FALSE) return(NULL) } if (length(iListArgs2$BoolCrit) != LLL) { - stop("'BoolCrit' and 'InputsModel' series must have the same length \n", call. = FALSE) + stop("'BoolCrit' and 'InputsModel' series must have the same length", call. = FALSE) return(NULL) } @@ -199,7 +199,7 @@ CreateInputsCrit <- function(FUN_CRIT, ## check 'weights' if (!is.null(iListArgs2$weights)) { if (!is.vector(iListArgs2$weights) | length(iListArgs2$weights) != 1 | !is.numeric(iListArgs2$weights) | any(iListArgs2$weights < 0)) { - stop("'weights' must be a single (list of) positive or equal to zero value(s) \n", call. = FALSE) + stop("'weights' must be a single (list of) positive or equal to zero value(s)", call. = FALSE) return(NULL) } } @@ -207,7 +207,7 @@ CreateInputsCrit <- function(FUN_CRIT, ## check 'epsilon' if (!is.null(iListArgs2$epsilon)) { if (!is.vector(iListArgs2$epsilon) | length(iListArgs2$epsilon) != 1 | !is.numeric(iListArgs2$epsilon) | any(iListArgs2$epsilon <= 0)) { - stop("'epsilon' must be a single (list of) positive value(s) \n", call. = FALSE) + stop("'epsilon' must be a single (list of) positive value(s)", call. = FALSE) return(NULL) } } else if (iListArgs2$transfo %in% c("log", "inv") & any(iListArgs2$obs %in% 0) & warnings) { diff --git a/R/CreateInputsModel.R b/R/CreateInputsModel.R index c090e7bd657cac8f2a5c2aeafc9aae48c96060b5..fa659709c30c93a9d38675fddaf92857d64a3703 100644 --- a/R/CreateInputsModel.R +++ b/R/CreateInputsModel.R @@ -58,18 +58,18 @@ CreateInputsModel <- function(FUN_MOD, BOOL <- TRUE } if (!BOOL) { - stop("Incorrect FUN_MOD for use in CreateInputsModel \n") + stop("Incorrect FUN_MOD for use in CreateInputsModel") return(NULL) } ##check_arguments if ("GR" %in% ObjectClass | "CemaNeige" %in% ObjectClass) { if (is.null(DatesR)) { - stop("DatesR is missing \n") + stop("DatesR is missing") return(NULL) } if ("POSIXlt" %in% class(DatesR) == FALSE & "POSIXct" %in% class(DatesR) == FALSE) { - stop("DatesR must be defined as POSIXlt or POSIXct \n") + stop("DatesR must be defined as POSIXlt or POSIXct") return(NULL) } if ("POSIXlt" %in% class(DatesR) == FALSE) { @@ -81,103 +81,103 @@ CreateInputsModel <- function(FUN_MOD, return(NULL) } if (any(duplicated(DatesR))) { - stop("DatesR must not include duplicated values \n") + stop("DatesR must not include duplicated values") return(NULL) } LLL <- length(DatesR) } if ("GR" %in% ObjectClass) { if (is.null(Precip)) { - stop("Precip is missing \n") + stop("Precip is missing") return(NULL) } if (is.null(PotEvap)) { - stop("PotEvap is missing \n") + stop("PotEvap is missing") return(NULL) } if (!is.vector(Precip) | !is.vector(PotEvap)) { - stop("Precip and PotEvap must be vectors of numeric values \n") + stop("Precip and PotEvap must be vectors of numeric values") return(NULL) } if (!is.numeric(Precip) | !is.numeric(PotEvap)) { - stop("Precip and PotEvap must be vectors of numeric values \n") + stop("Precip and PotEvap must be vectors of numeric values") return(NULL) } if (length(Precip) != LLL | length(PotEvap) != LLL) { - stop("Precip, PotEvap and DatesR must have the same length \n") + stop("Precip, PotEvap and DatesR must have the same length") return(NULL) } } if ("CemaNeige" %in% ObjectClass) { if (is.null(Precip)) { - stop("Precip is missing \n") + stop("Precip is missing") return(NULL) } if (is.null(TempMean)) { - stop("TempMean is missing \n") + stop("TempMean is missing") return(NULL) } if (!is.vector(Precip) | !is.vector(TempMean)) { - stop("Precip and TempMean must be vectors of numeric values \n") + stop("Precip and TempMean must be vectors of numeric values") return(NULL) } if (!is.numeric(Precip) | !is.numeric(TempMean)) { - stop("Precip and TempMean must be vectors of numeric values \n") + stop("Precip and TempMean must be vectors of numeric values") return(NULL) } if (length(Precip) != LLL | length(TempMean) != LLL) { - stop("Precip, TempMean and DatesR must have the same length \n") + stop("Precip, TempMean and DatesR must have the same length") return(NULL) } if (is.null(TempMin) != is.null(TempMax)) { - stop("TempMin and TempMax must be both defined if not null \n") + stop("TempMin and TempMax must be both defined if not null") return(NULL) } if (!is.null(TempMin) & !is.null(TempMax)) { if (!is.vector(TempMin) | !is.vector(TempMax)) { - stop("TempMin and TempMax must be vectors of numeric values \n") + stop("TempMin and TempMax must be vectors of numeric values") return(NULL) } if (!is.numeric(TempMin) | !is.numeric(TempMax)) { - stop("TempMin and TempMax must be vectors of numeric values \n") + stop("TempMin and TempMax must be vectors of numeric values") return(NULL) } if (length(TempMin) != LLL | length(TempMax) != LLL) { - stop("TempMin, TempMax and DatesR must have the same length \n") + stop("TempMin, TempMax and DatesR must have the same length") return(NULL) } } if (!is.null(HypsoData)) { if (!is.vector(HypsoData)) { - stop("HypsoData must be a vector of numeric values if not null \n") + stop("HypsoData must be a vector of numeric values if not null") return(NULL) } if (!is.numeric(HypsoData)) { - stop("HypsoData must be a vector of numeric values if not null \n") + stop("HypsoData must be a vector of numeric values if not null") return(NULL) } if (length(HypsoData) != 101) { - stop("HypsoData must be of length 101 if not null \n") + stop("HypsoData must be of length 101 if not null") return(NULL) } if (sum(is.na(HypsoData)) != 0 & sum(is.na(HypsoData)) != 101) { - stop("HypsoData must not contain any NA if not null \n") + stop("HypsoData must not contain any NA if not null") return(NULL) } } if (!is.null(ZInputs)) { if (length(ZInputs) != 1) { - stop("\t ZInputs must be a single numeric value if not null \n") + stop("\t ZInputs must be a single numeric value if not null") return(NULL) } if (is.na(ZInputs) | !is.numeric(ZInputs)) { - stop("\t ZInputs must be a single numeric value if not null \n") + stop("\t ZInputs must be a single numeric value if not null") return(NULL) } } if (is.null(HypsoData)) { if (verbose) { - warning("\t HypsoData is missing => a single layer is used and no extrapolation is made \n") + warning("\t HypsoData is missing => a single layer is used and no extrapolation is made") } HypsoData <- as.numeric(rep(NA, 101)) ZInputs <- as.numeric(NA) @@ -186,12 +186,12 @@ CreateInputsModel <- function(FUN_MOD, } if (is.null(ZInputs)) { if (verbose & !identical(HypsoData, as.numeric(rep(NA, 101)))) { - warning("\t ZInputs is missing => HypsoData[51] is used \n") + warning("\t ZInputs is missing => HypsoData[51] is used") } ZInputs <- HypsoData[51L] } if (NLayers <= 0) { - stop("NLayers must be a positive integer value \n") + stop("NLayers must be a positive integer value") return(NULL) } if (NLayers != as.integer(NLayers)) { @@ -209,14 +209,14 @@ CreateInputsModel <- function(FUN_MOD, if (sum(BOOL_NA_TMP) != 0) { BOOL_NA <- BOOL_NA | BOOL_NA_TMP if (verbose) { - warning("\t Values < 0 or NA values detected in Precip series \n") + warning("\t Values < 0 or NA values detected in Precip series") } } BOOL_NA_TMP <- (PotEvap < 0) | is.na(PotEvap) if (sum(BOOL_NA_TMP) != 0) { BOOL_NA <- BOOL_NA | BOOL_NA_TMP if (verbose) { - warning("\t Values < 0 or NA values detected in PotEvap series \n") + warning("\t Values < 0 or NA values detected in PotEvap series") } } } @@ -225,14 +225,14 @@ CreateInputsModel <- function(FUN_MOD, if (sum(BOOL_NA_TMP) != 0) { BOOL_NA <- BOOL_NA | BOOL_NA_TMP if (verbose) { - warning("\t Values < 0 or NA values detected in Precip series \n") + warning("\t Values < 0 or NA values detected in Precip series") } } BOOL_NA_TMP <- (TempMean < (-150)) | is.na(TempMean) if (sum(BOOL_NA_TMP) != 0) { BOOL_NA <- BOOL_NA | BOOL_NA_TMP if (verbose) { - warning("\t Values < -150) or NA values detected in TempMean series \n") + warning("\t Values < -150) or NA values detected in TempMean series") } } if (!is.null(TempMin) & !is.null(TempMax)) { @@ -240,21 +240,21 @@ CreateInputsModel <- function(FUN_MOD, if (sum(BOOL_NA_TMP) != 0) { BOOL_NA <- BOOL_NA | BOOL_NA_TMP if (verbose) { - warning("\t Values < -150) or NA values detected in TempMin series \n") + warning("\t Values < -150) or NA values detected in TempMin series") } } BOOL_NA_TMP <- (TempMax < (-150)) | is.na(TempMax) if (sum(BOOL_NA_TMP) != 0) { BOOL_NA <- BOOL_NA | BOOL_NA_TMP if (verbose) { - warning("\t Values < -150) or NA values detected in TempMax series \n") + warning("\t Values < -150) or NA values detected in TempMax series") } } } } if (sum(BOOL_NA) != 0) { WTxt <- NULL - WTxt <- paste(WTxt, "\t Missing values are not allowed in InputsModel \n", sep = "") + WTxt <- paste(WTxt, "\t Missing values are not allowed in InputsModel", sep = "") Select <- (max(which(BOOL_NA)) + 1):length(BOOL_NA) @@ -277,8 +277,8 @@ CreateInputsModel <- function(FUN_MOD, DatesR <- DatesR[Select] - WTxt <- paste(WTxt, "\t -> Data were trunced to keep the most recent available time-steps \n", sep = "") - WTxt <- paste(WTxt, "\t -> ", length(Select), " time-steps were kept \n", sep = "") + WTxt <- paste(WTxt, "\t -> Data were trunced to keep the most recent available time-steps", sep = "") + WTxt <- paste(WTxt, "\t -> ", length(Select), " time-steps were kept", sep = "") if (!is.null(WTxt) & verbose) { warning(WTxt) diff --git a/R/CreateRunOptions.R b/R/CreateRunOptions.R index e11071681c0fca51cfff9df650e5b1170fcd2fe3..df16668b06db1afeb79e4c65ccd77f4265fd8ede 100644 --- a/R/CreateRunOptions.R +++ b/R/CreateRunOptions.R @@ -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'") return(NULL) } ##check_InputsModel if (!inherits(InputsModel, "InputsModel")) { - stop("'InputsModel' must be of class 'InputsModel' \n") + stop("'InputsModel' must be of class 'InputsModel'") return(NULL) } if ("GR" %in% ObjectClass & !inherits(InputsModel, "GR")) { - stop("'InputsModel' must be of class 'GR' \n") + stop("'InputsModel' must be of class 'GR'") return(NULL) } if ("CemaNeige" %in% ObjectClass & !inherits(InputsModel, "CemaNeige")) { - stop("'InputsModel' must be of class 'CemaNeige' \n") + stop("'InputsModel' must be of class 'CemaNeige'") return(NULL) } if ("hourly" %in% ObjectClass & !inherits(InputsModel, "hourly")) { - stop("'InputsModel' must be of class 'hourly' \n") + stop("'InputsModel' must be of class 'hourly'") return(NULL) } if ("daily" %in% ObjectClass & !inherits(InputsModel, "daily")) { - stop("'InputsModel' must be of class 'daily' \n") + stop("'InputsModel' must be of class 'daily'") return(NULL) } if ("monthly" %in% ObjectClass & !inherits(InputsModel, "monthly")) { - stop("'InputsModel' must be of class 'monthly' \n") + stop("'InputsModel' must be of class 'monthly'") return(NULL) } if ("yearly" %in% ObjectClass & !inherits(InputsModel, "yearly")) { - stop("'InputsModel' must be of class 'yearly' \n") + stop("'InputsModel' must be of class 'yearly'") 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") 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") 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") 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") return(NULL) } @@ -98,11 +98,11 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP ##check_IndPeriod_WarmUp WTxt <- NULL if (is.null(IndPeriod_WarmUp)) { - WTxt <- paste0(WTxt,"\t Model warm up period not defined -> default configuration used \n") + WTxt <- paste0(WTxt,"\t Model warm up period not defined -> default configuration used") ##If_the_run_period_starts_at_the_very_beginning_of_the_time_series if (IndPeriod_Run[1] == as.integer(1)) { IndPeriod_WarmUp <- as.integer(0) - WTxt <- paste0(WTxt,"\t No data were found for model warm up! \n") + WTxt <- paste0(WTxt,"\t No data were found for model warm up!") ##We_look_for_the_longest_period_preceeding_the_run_period_with_a_maximum_of_one_year } else { TmpDateR0 <- InputsModel$DatesR[IndPeriod_Run[1]] @@ -135,15 +135,15 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP } if (!is.null(IndPeriod_WarmUp)) { if (!is.vector(IndPeriod_WarmUp)) { - stop("'IndPeriod_WarmUp' must be a vector of numeric values \n") + stop("'IndPeriod_WarmUp' must be a vector of numeric values") return(NULL) } if (!is.numeric(IndPeriod_WarmUp)) { - stop("'IndPeriod_WarmUp' must be a vector of numeric values \n") + stop("'IndPeriod_WarmUp' must be a vector of numeric values") return(NULL) } if (storage.mode(IndPeriod_WarmUp) != "integer") { - stop("'IndPeriod_WarmUp' should be of type integer \n") + stop("'IndPeriod_WarmUp' should be of type integer") return(NULL) } if (identical(IndPeriod_WarmUp, as.integer(0)) & verbose) { @@ -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") 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'") 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'") return(NULL) } } else if (is.null(IniStates)) { @@ -187,15 +187,15 @@ 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") } } ## check IniStates if (is.null(IniStates) & is.null(IniResLevels) & warnings) { - warning("\t Model states initialisation not defined -> default configuration used \n") + warning("\t Model states initialisation not defined -> default configuration used") } 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'") } if ("CemaNeige" %in% ObjectClass) { NLayers <- length(InputsModel$LayerPrecip) @@ -232,19 +232,19 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP 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")) 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'")) 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'")) return(NULL) } # if (length(na.omit(unlist(IniStates))) != NState) { - # stop(paste0("The length of IniStates must be ", NState, " for the chosen FUN_MOD \n")) + # stop(paste0("The length of IniStates must be ", NState, " for the chosen FUN_MOD")) # return(NULL) # } if (!"CemaNeige" %in% ObjectClass & any(is.na(IniStates$CemaNeigeLayers$G ))) { @@ -292,15 +292,15 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP ##check_Outputs_Sim if (!is.vector(Outputs_Sim)) { - stop("Outputs_Sim must be a vector of characters \n") + stop("Outputs_Sim must be a vector of characters") return(NULL) } if (!is.character(Outputs_Sim)) { - stop("Outputs_Sim must be a vector of characters \n") + stop("Outputs_Sim must be a vector of characters") return(NULL) } if (sum(is.na(Outputs_Sim)) != 0) { - stop("Outputs_Sim must not contain NA \n") + stop("Outputs_Sim must not contain NA") return(NULL) } if ("all" %in% Outputs_Sim) { @@ -309,7 +309,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: ", - paste(Outputs_Sim[Test], collapse = ", "), " not found \n")) + paste(Outputs_Sim[Test], collapse = ", "), " not found")) return(NULL) } @@ -330,15 +330,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") 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") return(NULL) } if (sum(is.na(Outputs_Cal)) != 0) { - stop("'Outputs_Cal' must not contain NA \n") + stop("'Outputs_Cal' must not contain NA") return(NULL) } } @@ -350,7 +350,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP which(Outputs_Cal %in% c("DatesR", Outputs_all, "StateEnd") == FALSE) if (length(Test) != 0) { stop(paste0("'Outputs_Cal' is incorrectly defined: ", - paste(Outputs_Cal[Test], collapse = ", "), " not found \n")) + paste(Outputs_Cal[Test], collapse = ", "), " not found")) return(NULL) } @@ -387,7 +387,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'") return(NULL) } MeanAnSolidPrecip <- rep(mean(SolidPrecip) * Factor, NLayers) @@ -400,15 +400,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")) 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")) 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, "")) return(NULL) } } diff --git a/R/ErrorCrit.R b/R/ErrorCrit.R index feef2360688ab5408477ef8c680e5d7f0f88ff09..b57ef82f2ff4b1c103b411ebf8719bb19a6f4272 100644 --- a/R/ErrorCrit.R +++ b/R/ErrorCrit.R @@ -3,11 +3,11 @@ ErrorCrit <- function(InputsCrit, OutputsModel, FUN_CRIT, warnings = TRUE, verbo ## ---------- Arguments check if (!inherits(InputsCrit, "InputsCrit")) { - stop("InputsCrit must be of class 'InputsCrit' \n") + stop("InputsCrit must be of class 'InputsCrit'") return(NULL) } if (!inherits(OutputsModel, "OutputsModel")) { - stop("OutputsModel must be of class 'OutputsModel' \n") + stop("OutputsModel must be of class 'OutputsModel'") return(NULL) } if (!missing(FUN_CRIT)) { diff --git a/R/RunModel_CemaNeigeGR4J.R b/R/RunModel_CemaNeigeGR4J.R index 6a8533c728aaac53faeab1a0930faff38561378e..4afe165a8cb717a2d6bcb39c06e2d169e0ff4056 100644 --- a/R/RunModel_CemaNeigeGR4J.R +++ b/R/RunModel_CemaNeigeGR4J.R @@ -13,15 +13,15 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param, IsHyst = FALSE) ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' \n"); return(NULL); } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' \n"); return(NULL); } - 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,"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) | !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); } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'"); return(NULL); } + if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' "); return(NULL); } + if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' "); return(NULL); } + if(inherits(InputsModel,"CemaNeige" )==FALSE){ stop("InputsModel must be of class 'CemaNeige' "); return(NULL); } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' "); return(NULL); } + if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' "); return(NULL); } + if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("RunOptions must be of class 'CemaNeige' "); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector"); return(NULL); } + if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")); return(NULL); } Param <- as.double(Param); Param_X1X3_threshold <- 1e-2 diff --git a/R/RunModel_CemaNeigeGR5J.R b/R/RunModel_CemaNeigeGR5J.R index de0cc94a46ec36e07f33c6e1d5cb04934a019a3c..fe5321ce26041f3a76cfb0e3ea338a1176d5b3d1 100644 --- a/R/RunModel_CemaNeigeGR5J.R +++ b/R/RunModel_CemaNeigeGR5J.R @@ -12,15 +12,15 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param, IsHyst = FALSE) FortranOutputs <- .FortranOutputs(GR = "GR5J", isCN = TRUE) ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' \n"); return(NULL); } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' \n"); return(NULL); } - 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,"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) | !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); } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'"); return(NULL); } + if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' "); return(NULL); } + if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' "); return(NULL); } + if(inherits(InputsModel,"CemaNeige" )==FALSE){ stop("InputsModel must be of class 'CemaNeige' "); return(NULL); } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' "); return(NULL); } + if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' "); return(NULL); } + if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("RunOptions must be of class 'CemaNeige' "); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector"); return(NULL); } + if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")); return(NULL); } Param <- as.double(Param); Param_X1X3_threshold <- 1e-2 diff --git a/R/RunModel_CemaNeigeGR6J.R b/R/RunModel_CemaNeigeGR6J.R index 006ef0faa7768e1498ede5d0fdf0c5d6326e5d0f..afdad047bbc401e3b629cb05a50086cb01b3e5cb 100644 --- a/R/RunModel_CemaNeigeGR6J.R +++ b/R/RunModel_CemaNeigeGR6J.R @@ -12,15 +12,15 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param, IsHyst = FALSE) FortranOutputs <- .FortranOutputs(GR = "GR6J", isCN = TRUE) ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' \n"); return(NULL); } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' \n"); return(NULL); } - 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,"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) | !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); } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'"); return(NULL); } + if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' "); return(NULL); } + if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' "); return(NULL); } + if(inherits(InputsModel,"CemaNeige" )==FALSE){ stop("InputsModel must be of class 'CemaNeige' "); return(NULL); } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' "); return(NULL); } + if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' "); return(NULL); } + if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("RunOptions must be of class 'CemaNeige' "); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector"); return(NULL); } + if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")); return(NULL); } Param <- as.double(Param); Param_X1X3X6_threshold <- 1e-2 diff --git a/R/RunModel_GR1A.R b/R/RunModel_GR1A.R index b05757b650ec2c999f960a573f35410202b14b7c..882cacd1b3e64c080b6238207a54e200f2ed6c36 100644 --- a/R/RunModel_GR1A.R +++ b/R/RunModel_GR1A.R @@ -4,13 +4,13 @@ RunModel_GR1A <- function(InputsModel,RunOptions,Param){ FortranOutputs <- .FortranOutputs(GR = "GR1A")$GR ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); } - if(inherits(InputsModel,"yearly" )==FALSE){ stop("InputsModel must be of class 'yearly' \n"); return(NULL); } - 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) | !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); } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'"); return(NULL); } + if(inherits(InputsModel,"yearly" )==FALSE){ stop("InputsModel must be of class 'yearly' "); return(NULL); } + if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' "); return(NULL); } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' "); return(NULL); } + if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' "); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector"); return(NULL); } + if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")); return(NULL); } Param <- as.double(Param); ##Input_data_preparation diff --git a/R/RunModel_GR2M.R b/R/RunModel_GR2M.R index 0dcb2ddfbf7cebc28a222eadefa6d0e0af19f38d..fec37264b8aaf1c5276909611ac1c8dbd078e6f9 100644 --- a/R/RunModel_GR2M.R +++ b/R/RunModel_GR2M.R @@ -4,13 +4,13 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param){ FortranOutputs <- .FortranOutputs(GR = "GR2M")$GR ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); } - if(inherits(InputsModel,"monthly" )==FALSE){ stop("InputsModel must be of class 'monthly' \n"); return(NULL); } - 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) | !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); } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'"); return(NULL); } + if(inherits(InputsModel,"monthly" )==FALSE){ stop("InputsModel must be of class 'monthly' "); return(NULL); } + if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' "); return(NULL); } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' "); return(NULL); } + if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' "); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector"); return(NULL); } + if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")); return(NULL); } Param <- as.double(Param); Param_X1X2_threshold <- 1e-2 diff --git a/R/RunModel_GR4H.R b/R/RunModel_GR4H.R index 46cfdc6249f9394c85195e77c84eb92eb23f452a..c23ecb51191681d5aebabc0671a94bc4a450b7ce 100644 --- a/R/RunModel_GR4H.R +++ b/R/RunModel_GR4H.R @@ -4,13 +4,13 @@ RunModel_GR4H <- function(InputsModel,RunOptions,Param){ FortranOutputs <- .FortranOutputs(GR = "GR4H")$GR ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); } - if(inherits(InputsModel,"hourly" )==FALSE){ stop("InputsModel must be of class 'hourly' \n"); return(NULL); } - 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) | !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); } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'"); return(NULL); } + if(inherits(InputsModel,"hourly" )==FALSE){ stop("InputsModel must be of class 'hourly' "); return(NULL); } + if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' "); return(NULL); } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' "); return(NULL); } + if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' "); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector"); return(NULL); } + if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")); return(NULL); } Param <- as.double(Param); Param_X1X3_threshold <- 1e-2 diff --git a/R/RunModel_GR4J.R b/R/RunModel_GR4J.R index 8934fa9d415400b60a8f23a0625db575a523a2cf..0dc9cce3ccc21713073eb9bc2edcb30066509b96 100644 --- a/R/RunModel_GR4J.R +++ b/R/RunModel_GR4J.R @@ -4,13 +4,13 @@ RunModel_GR4J <- function(InputsModel,RunOptions,Param){ FortranOutputs <- .FortranOutputs(GR = "GR4J")$GR ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' \n"); return(NULL); } - 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) | !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); } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'"); return(NULL); } + if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' "); return(NULL); } + if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' "); return(NULL); } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' "); return(NULL); } + if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' "); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector"); return(NULL); } + if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")); return(NULL); } Param <- as.double(Param); Param_X1X3_threshold <- 1e-2 diff --git a/R/RunModel_GR5J.R b/R/RunModel_GR5J.R index 275d9d7e32506b4541ecf40e656df1c6f6d47758..f71a4046fcab2ca2eba5bf72e68e2362e26c604a 100644 --- a/R/RunModel_GR5J.R +++ b/R/RunModel_GR5J.R @@ -4,13 +4,13 @@ RunModel_GR5J <- function(InputsModel,RunOptions,Param){ FortranOutputs <- .FortranOutputs(GR = "GR5J")$GR ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' \n"); return(NULL); } - 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) | !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); } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'"); return(NULL); } + if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' "); return(NULL); } + if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' "); return(NULL); } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' "); return(NULL); } + if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' "); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector"); return(NULL); } + if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")); return(NULL); } Param <- as.double(Param); Param_X1X3_threshold <- 1e-2 diff --git a/R/RunModel_GR6J.R b/R/RunModel_GR6J.R index 644ab273dd2cc5cec44168403820c2b8b6b5539b..5a36a49606feacb6b40dae8b272ac571c6184cb1 100644 --- a/R/RunModel_GR6J.R +++ b/R/RunModel_GR6J.R @@ -4,13 +4,13 @@ RunModel_GR6J <- function(InputsModel,RunOptions,Param){ FortranOutputs <- .FortranOutputs(GR = "GR6J")$GR ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel' \n"); return(NULL); } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' \n"); return(NULL); } - 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) | !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); } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'"); return(NULL); } + if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' "); return(NULL); } + if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' "); return(NULL); } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' "); return(NULL); } + if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' "); return(NULL); } + if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector"); return(NULL); } + if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")); return(NULL); } Param <- as.double(Param); Param_X1X3X6_threshold <- 1e-2 diff --git a/R/SeriesAggreg.R b/R/SeriesAggreg.R index 17080f312f69bf53a86439f8d2a00280d8124f21..bf70767d646d5f5178f4e5b9e37a724d1cd3a5d1 100644 --- a/R/SeriesAggreg.R +++ b/R/SeriesAggreg.R @@ -9,20 +9,20 @@ SeriesAggreg <- function(TabSeries, ##check_TabSeries if (is.null(TabSeries) ) { - stop("TabSeries must be a dataframe containing the dates and data to be converted \n") + stop("TabSeries must be a dataframe containing the dates and data to be converted") return(NULL) } if (!is.data.frame(TabSeries)) { - stop("TabSeries must be a dataframe containing the dates and data to be converted \n") + stop("TabSeries must be a dataframe containing the dates and data to be converted") return(NULL) } if (ncol(TabSeries) < 2) { - stop("TabSeries must contain at least two columns (including the coulmn of dates \n") + stop("TabSeries must contain at least two columns (including the coulmn of dates") return(NULL) } ##check_TimeFormat if (!any(class(TabSeries[, 1]) %in% "POSIXt")) { - stop("TabSeries first column must be a vector of class POSIXlt or POSIXct \n") + stop("TabSeries first column must be a vector of class POSIXlt or POSIXct") return(NULL) } if (any(class(TabSeries[, 1]) %in% "POSIXlt")) { @@ -30,96 +30,96 @@ SeriesAggreg <- function(TabSeries, } for (iCol in 2:ncol(TabSeries)) { if (!is.numeric(TabSeries[,iCol])) { - stop("TabSeries columns (other than the first one) be of numeric class \n") + stop("TabSeries columns (other than the first one) be of numeric class") return(NULL) } } if (is.null(TimeFormat)) { - stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n") + stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") return(NULL) } if (!is.vector(TimeFormat)) { - stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n") + stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") return(NULL) } if (!is.character(TimeFormat)) { - stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n") + stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") return(NULL) } if (length(TimeFormat) != 1) { - stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n") + stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") return(NULL) } if (! TimeFormat %in% c("hourly", "daily", "monthly", "yearly")) { - stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n") + stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") return(NULL) } ##check_NewTimeFormat if (is.null(NewTimeFormat)) { - stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n") + stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") return(NULL) } if (!is.vector(NewTimeFormat)) { - stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n") + stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") return(NULL) } if (!is.character(NewTimeFormat)) { - stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n") + stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") return(NULL) } if (length(NewTimeFormat) != 1) { - stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n") + stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") return(NULL) } if (! NewTimeFormat %in% c("hourly", "daily", "monthly", "yearly")) { - stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n") + stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") return(NULL) } ##check_ConvertFun if (is.null(ConvertFun)) { - stop("ConvertFun must be a vector of character \n") + stop("ConvertFun must be a vector of character") return(NULL) } if (!is.vector(ConvertFun)) { - stop("ConvertFun must be a vector of character \n") + stop("ConvertFun must be a vector of character") return(NULL) } if (!is.character(ConvertFun)) { - stop("ConvertFun must be a vector of character \n") + stop("ConvertFun must be a vector of character") return(NULL) } if (length(ConvertFun) != (ncol(TabSeries) - 1)) { stop( - paste("ConvertFun must be of length", ncol(TabSeries) - 1, "(length=ncol(TabSeries)-1) \n") + paste("ConvertFun must be of length", ncol(TabSeries) - 1, "(length=ncol(TabSeries)-1)") ) return(NULL) } if (sum(ConvertFun %in% c("sum", "mean") == FALSE) != 0) { - stop("ConvertFun elements must be either 'sum' or 'mean' \n") + stop("ConvertFun elements must be either 'sum' or 'mean'") return(NULL) } ##check_YearFirstMonth if (is.null(YearFirstMonth)) { - stop("YearFirstMonth must be an integer between 1 and 12 \n") + stop("YearFirstMonth must be an integer between 1 and 12") return(NULL) } if (!is.vector(YearFirstMonth)) { - stop("YearFirstMonth must be an integer between 1 and 12 \n") + stop("YearFirstMonth must be an integer between 1 and 12") return(NULL) } if (!is.numeric(YearFirstMonth)) { - stop("YearFirstMonth must be an integer between 1 and 12 \n") + stop("YearFirstMonth must be an integer between 1 and 12") return(NULL) } YearFirstMonth <- as.integer(YearFirstMonth) if (length(YearFirstMonth) != 1) { - stop("YearFirstMonth must be only one integer between 1 and 12 \n") + stop("YearFirstMonth must be only one integer between 1 and 12") return(NULL) } if (YearFirstMonth %in% (1:12) == FALSE) { - stop("YearFirstMonth must be only one integer between 1 and 12 \n") + stop("YearFirstMonth must be only one integer between 1 and 12") return(NULL) } ##check_DatesR_integrity @@ -137,14 +137,14 @@ SeriesAggreg <- function(TabSeries, } TmpDatesR <- seq(from = TabSeries[1, 1], to = tail(TabSeries[, 1], 1), by = by) if (!identical(TabSeries[, 1], TmpDatesR)) { - stop("Some dates might not be ordered or are missing in TabSeries \n") + stop("Some dates might not be ordered or are missing in TabSeries") return(NULL) } ##check_conversion_direction if ((TimeFormat == "daily" & NewTimeFormat %in% c("hourly") ) | (TimeFormat == "monthly" & NewTimeFormat %in% c("hourly","daily") ) | (TimeFormat == "yearly" & NewTimeFormat %in% c("hourly","daily","monthly"))) { - stop("Only time aggregation can be performed \n") + stop("Only time aggregation can be performed") return(NULL) } ##check_if_conversion_not_needed @@ -153,7 +153,7 @@ SeriesAggreg <- function(TabSeries, (TimeFormat == "monthly" & NewTimeFormat == "monthly") | (TimeFormat == "yearly" & NewTimeFormat == "yearly" )) { if (verbose) { - warning("\t The old and new format are identical \n\t -> no time-step conversion was performed \n") + warning("\t The old and new format are identical \n\t -> no time-step conversion was performed") return(TabSeries) } } diff --git a/R/TransfoParam_GR1A.R b/R/TransfoParam_GR1A.R index afd0c53ce1f54c5f08553a893fc4c1e74fff191a..cb3b197cc1efc74097dccee84eeda1e7fa225c7b 100644 --- a/R/TransfoParam_GR1A.R +++ b/R/TransfoParam_GR1A.R @@ -8,7 +8,7 @@ TransfoParam_GR1A <- function(ParamIn, Direction) { } if (ncol(ParamIn) != NParam) { - stop(paste("the GR1A model requires ", NParam, " parameters \n", sep = "")) + stop(paste("the GR1A model requires ", NParam, " parameters", sep = "")) return(NULL) } diff --git a/R/TransfoParam_GR2M.R b/R/TransfoParam_GR2M.R index 75e5c36473556a3fcd88cbcac0ede6f1959b867b..a875c44d8bb22c71247b0c60e8de4a3214e4bb07 100644 --- a/R/TransfoParam_GR2M.R +++ b/R/TransfoParam_GR2M.R @@ -7,7 +7,7 @@ TransfoParam_GR2M <- function(ParamIn, Direction) { ParamIn <- rbind(ParamIn) } if (ncol(ParamIn) != NParam) { - stop(paste("the GR2M model requires ", NParam, " parameters \n", sep = "")) + stop(paste("the GR2M model requires ", NParam, " parameters", sep = "")) return(NULL) } diff --git a/R/TransfoParam_GR4H.R b/R/TransfoParam_GR4H.R index 651d4da7c473abc412cb319180b5cafae9656f99..f2dbdf37b2ffe6197ddb4c2bd9dab9c2bf5b00a2 100644 --- a/R/TransfoParam_GR4H.R +++ b/R/TransfoParam_GR4H.R @@ -3,7 +3,7 @@ TransfoParam_GR4H <- function(ParamIn,Direction){ NParam <- 4; Bool <- is.matrix(ParamIn); if(Bool==FALSE){ ParamIn <- rbind(ParamIn); } - if(ncol(ParamIn)!=NParam){ stop(paste("the GR4H model requires ",NParam," parameters \n",sep="")); return(NULL); } + if(ncol(ParamIn)!=NParam){ stop(paste("the GR4H model requires ",NParam," parameters",sep="")); return(NULL); } if(Direction=="TR"){ ParamOut <- ParamIn; diff --git a/R/TransfoParam_GR4J.R b/R/TransfoParam_GR4J.R index 6f7f5a1395348884831234b379f0649d0712a0b4..6d59afef6e9275404cae951fd681737e55f0e268 100644 --- a/R/TransfoParam_GR4J.R +++ b/R/TransfoParam_GR4J.R @@ -3,7 +3,7 @@ TransfoParam_GR4J <- function(ParamIn,Direction){ NParam <- 4; Bool <- is.matrix(ParamIn); if(Bool==FALSE){ ParamIn <- rbind(ParamIn); } - if(ncol(ParamIn)!=NParam){ stop(paste("the GR4J model requires ",NParam," parameters \n",sep="")); return(NULL); } + if(ncol(ParamIn)!=NParam){ stop(paste("the GR4J model requires ",NParam," parameters",sep="")); return(NULL); } if(Direction=="TR"){ ParamOut <- ParamIn; diff --git a/R/TransfoParam_GR5J.R b/R/TransfoParam_GR5J.R index 0492c1471464d86a479de150c3deb02967215205..b006d86fb7b22e28abb5dc27e5bcf1dc037fc769 100644 --- a/R/TransfoParam_GR5J.R +++ b/R/TransfoParam_GR5J.R @@ -3,7 +3,7 @@ TransfoParam_GR5J <- function(ParamIn,Direction){ NParam <- 5; Bool <- is.matrix(ParamIn); if(Bool==FALSE){ ParamIn <- rbind(ParamIn); } - if(ncol(ParamIn)!=NParam){ stop(paste("the GR5J model requires ",NParam," parameters \n",sep="")); return(NULL); } + if(ncol(ParamIn)!=NParam){ stop(paste("the GR5J model requires ",NParam," parameters",sep="")); return(NULL); } if(Direction=="TR"){ ParamOut <- ParamIn; diff --git a/R/TransfoParam_GR6J.R b/R/TransfoParam_GR6J.R index 08947d17ba8d090e1146699cb3411b91cd18c486..9cdda8eefea0cba35c6e4729f7528c63f1ef7ed0 100644 --- a/R/TransfoParam_GR6J.R +++ b/R/TransfoParam_GR6J.R @@ -3,7 +3,7 @@ TransfoParam_GR6J <- function(ParamIn,Direction){ NParam <- 6; Bool <- is.matrix(ParamIn); if(Bool==FALSE){ ParamIn <- rbind(ParamIn); } - if(ncol(ParamIn)!=NParam){ stop(paste("the GR6J model requires ",NParam," parameters \n",sep="")); return(NULL); } + if(ncol(ParamIn)!=NParam){ stop(paste("the GR6J model requires ",NParam," parameters",sep="")); return(NULL); } if(Direction=="TR"){ ParamOut <- ParamIn; diff --git a/R/plot.OutputsModel.R b/R/plot.OutputsModel.R index a3ef15ff31764ec4285259debccb0a239e1f0ac7..9c369272987523eb9d8d46ad0159c1d470a3403b 100644 --- a/R/plot.OutputsModel.R +++ b/R/plot.OutputsModel.R @@ -4,7 +4,7 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = OutputsModel <- x if (!inherits(OutputsModel, "GR") & !inherits(OutputsModel, "CemaNeige")) { - stop(paste("OutputsModel not in the correct format for default plotting \n", sep = "")) + stop(paste("OutputsModel not in the correct format for default plotting", sep = "")) return(NULL) } @@ -29,9 +29,9 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = if ("CemaNeigeLayers" %in% names(OutputsModel)) { if ("Psol" %in% names(OutputsModel$CemaNeigeLayers[[1]])) { BOOL_Psol <- TRUE; } } - 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.character(which)) { stop("which must be a vector of character \n"); return(NULL); } + if ( is.null( which)) { stop("which must be a vector of character"); return(NULL); } + if (!is.vector( which)) { stop("which must be a vector of character"); return(NULL); } + if (!is.character(which)) { stop("which must be a vector of character"); return(NULL); } if (any(!which %in% c("all", "Precip", 'Temp', "SnowPack", "Flows", "Regime", "CumFreq", "CorQQ"))) { stop("Incorrect element found in argument which:\nit can only contain 'all', 'Precip', 'Temp', 'SnowPack', 'Flows', 'Regime', 'CumFreq' or 'CorQQ'") return(NULL) @@ -50,9 +50,9 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = 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", sep = "")); return(NULL); } if (inherits(OutputsModel, "GR") & !BOOL_Qsim) { - stop(paste("OutputsModel must contain at least Qsim to allow plotting \n", sep = "")); return(NULL); } + stop(paste("OutputsModel must contain at least Qsim to allow plotting", sep = "")); return(NULL); } if (BOOL_Dates) { MyRollMean1 <- function(x, n) { @@ -68,7 +68,7 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = if (inherits(OutputsModel, "daily" ) & TimeStep %in% ( 24*60*60)) { BOOL_TS <- TRUE; NameTS <- "day" ; plotunit <- "[mm/d]"; formatAxis <- "%m/%Y"; } if (inherits(OutputsModel, "monthly") & TimeStep %in% (c(28, 29, 30, 31)*24*60*60)) { BOOL_TS <- TRUE; NameTS <- "month"; plotunit <- "[mm/month]"; formatAxis <- "%m/%Y"; } if (inherits(OutputsModel, "yearly" ) & TimeStep %in% ( c(365, 366)*24*60*60)) { BOOL_TS <- TRUE; NameTS <- "year" ; plotunit <- "[mm/y]"; formatAxis <- "%Y" ; } - if (!BOOL_TS) { stop(paste("the time step of the model inputs could not be found \n", sep = "")); return(NULL); } + if (!BOOL_TS) { stop(paste("the time step of the model inputs could not be found", sep = "")); return(NULL); } } if (length(IndPeriod_Plot) == 0) { IndPeriod_Plot <- 1:length(OutputsModel$DatesR); } if (inherits(OutputsModel, "CemaNeige")) { NLayers <- length(OutputsModel$CemaNeigeLayers); } @@ -78,8 +78,8 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = } else { PsolLayerMean <- PsolLayerMean + OutputsModel$CemaNeigeLayers[[iLayer]]$Psol/NLayers; } } } BOOL_QobsZero <- FALSE; if (BOOL_Qobs) { SelectQobsNotZero <- (round(Qobs[IndPeriod_Plot] , 4) != 0); BOOL_QobsZero <- sum(!SelectQobsNotZero, na.rm = TRUE)>0; } BOOL_QsimZero <- FALSE; if (BOOL_Qsim) { SelectQsimNotZero <- (round(OutputsModel$Qsim[IndPeriod_Plot], 4) != 0); BOOL_QsimZero <- sum(!SelectQsimNotZero, na.rm = TRUE)>0; } - if (BOOL_QobsZero & verbose) { warning("\t zeroes detected in Qobs: some plots in the log space will not be created using all time-steps \n"); } - if (BOOL_QsimZero & verbose) { warning("\t zeroes detected in Qsim: some plots in the log space will not be created using all time-steps \n"); } + if (BOOL_QobsZero & verbose) { warning("\t zeroes detected in Qobs: some plots in the log space will not be created using all time-steps"); } + if (BOOL_QsimZero & verbose) { warning("\t zeroes detected in Qsim: some plots in the log space will not be created using all time-steps"); } BOOL_FilterZero <- TRUE; ## Plots_choices @@ -391,7 +391,7 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = MyRollMean3(DataDailyInterAn$Qobs , NDaysWindow), MyRollMean3(DataDailyInterAn$Qsim, NDaysWindow))); colnames(DataDailyInterAn) <- c("Dates", "Precip", "Psol", "Qobs", "Qsim"); ## Scale_conversion_to_make_them_become_a_monthly_regime - if (plotunitregime != "[mm/month]") { stop(paste("incorrect unit for regime plot \n", sep = "")); return(NULL); } + if (plotunitregime != "[mm/month]") { stop(paste("incorrect unit for regime plot", sep = "")); return(NULL); } DataDailyInterAn <- as.data.frame(cbind(DataDailyInterAn[1], DataDailyInterAn[2:5]*30)); } ## Plot_preparation