diff --git a/DESCRIPTION b/DESCRIPTION index 3c3646fca78a723a2e83e89262ab77f958c869bb..fcb40f849ad1938e943871534037cb837abba2e3 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.12.11 -Date: 2019-03-29 +Version: 1.2.12.12 +Date: 2019-04-01 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), person("Olivier", "Delaigue", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7668-8468"), email = "airGR@irstea.fr"), diff --git a/NEWS.rmd b/NEWS.rmd index ab97f78f4f961e9fc3483f75bf434d1cc0109143..c97f2be0d0bd9a2d9c780b142223b2a7484aba23 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -13,7 +13,7 @@ output: -### 1.2.12.11 Release Notes (2019-03-28) +### 1.2.12.12 Release Notes (2019-04-01) @@ -31,8 +31,6 @@ output: #### New features -- Added <code>TransfoParam_CemaNeigeHyst()</code> function in order to take into account transformation of the parameters of the CemaNeige module when the hysteresis is used. - - <code>CreateInputsCrit()</code> now can prepare an <code>InputsCrit</code> object in order to compute a single criterion (<code>Single</code> class), multiple criteria (<code>Multi</code> class) with the <code>ErrorCrit()</code> function. So it is now possible to set the following arguments as atomic (as before) or as list: <code>FUN_CRIT</code>, <code>obs</code>, <code>BoolCrit</code>, <code>transfo</code>, <code>weights</code>. If the list format is chosen, all the lists must have the same length. - <code>CreateInputsCrit()</code> now presents a <code>varObs</code> argument in order to allow to prepare an <code>InputsCrit</code> object in order run a criterion on other variable than observed discharges with the <code>ErrorCrit()</code> function (e.g. SCA, SWE). @@ -49,6 +47,8 @@ output: - <code>CreateCalibOptions()</code> now presents a <code>IsHyst</code> argument to give the possibility to use the hysteresis with CemaNeige. +- Added <code>TransfoParam_CemaNeigeHyst()</code> function in order to take into account transformation of the parameters of the CemaNeige module when the hysteresis is used. + - Added the <code>X0310010</code> dataset to run the examples using the hysteresis with CemaNeige. - Added the cemaneige_hysteresis vignette to explain how to manage the use of the hysteresis with CemaNeige. diff --git a/R/Calibration_Michel.R b/R/Calibration_Michel.R index f053d110b9362bbd5bc7cbc6a8698ee004d7bdf8..b19b05de5e8fa72a6efa73bc7f670a0996e2329c 100644 --- a/R/Calibration_Michel.R +++ b/R/Calibration_Michel.R @@ -19,16 +19,16 @@ Calibration_Michel <- function(InputsModel, ##_____Arguments_check_____________________________________________________________________ if (!inherits(InputsModel, "InputsModel")) { - stop("InputsModel must be of class 'InputsModel'") + stop("'InputsModel' must be of class 'InputsModel'") } if (!inherits(RunOptions, "RunOptions")) { - stop("RunOptions must be of class 'RunOptions'") + stop("'RunOptions' must be of class 'RunOptions'") } if (!inherits(InputsCrit, "InputsCrit")) { - stop("InputsCrit must be of class 'InputsCrit'") + stop("'InputsCrit' must be of class 'InputsCrit'") } if (inherits(InputsCrit, "Multi")) { - stop("InputsCrit must be of class 'Single' or 'Compo'") + stop("'InputsCrit' must be of class 'Single' or 'Compo'") } if (inherits(InputsCrit, "Single")) { listVarObs <- InputsCrit$varObs @@ -45,10 +45,10 @@ Calibration_Michel <- function(InputsModel, RunOptions$Outputs_Cal <- c(RunOptions$Outputs_Cal, "SnowPack") } if (!inherits(CalibOptions, "CalibOptions")) { - stop("CalibOptions must be of class 'CalibOptions'") + stop("'CalibOptions' must be of class 'CalibOptions'") } if (!inherits(CalibOptions, "HBAN")) { - stop("CalibOptions must be of class 'HBAN' if Calibration_Michel is used") + stop("'CalibOptions' must be of class 'HBAN' if 'Calibration_Michel' is used") } if (!missing(FUN_CRIT)) { warning("argument 'FUN_CRIT' is deprecated. The error criterion function is now automatically get from the 'InputsCrit' object") @@ -131,7 +131,7 @@ Calibration_Michel <- function(InputsModel, } if (is.null(FUN_TRANSFO)) { - stop("FUN_TRANSFO was not found (in Calibration function)") + stop("'FUN_TRANSFO' was not found (in 'Calibration' function)") } } @@ -512,7 +512,3 @@ Calibration_Michel <- function(InputsModel, } - - - - diff --git a/R/CreateCalibOptions.R b/R/CreateCalibOptions.R index f0535101e19d74f6218693f330b85849ce7d146b..4df83ea2590ac239148b4527fb040ab184e08bb1 100644 --- a/R/CreateCalibOptions.R +++ b/R/CreateCalibOptions.R @@ -15,7 +15,7 @@ CreateCalibOptions <- function(FUN_MOD, FUN_TRANSFO <- match.fun(FUN_TRANSFO) } if (!is.logical(IsHyst) | length(IsHyst) != 1L) { - stop("'IsHyst' must be a 'logical' of length 1") + stop("'IsHyst' must be a logical of length 1") } ##check_FUN_MOD BOOL <- FALSE @@ -64,7 +64,7 @@ CreateCalibOptions <- function(FUN_MOD, ObjectClass <- c(ObjectClass, "hysteresis") } if (!BOOL) { - stop("incorrect FUN_MOD for use in CreateCalibOptions") + stop("incorrect 'FUN_MOD' for use in 'CreateCalibOptions'") return(NULL) } @@ -76,7 +76,7 @@ CreateCalibOptions <- function(FUN_MOD, BOOL <- TRUE } if (!BOOL) { - stop("incorrect FUN_CALIB for use in CreateCalibOptions") + stop("incorrect 'FUN_CALIB' for use in 'CreateCalibOptions'") return(NULL) } @@ -113,7 +113,7 @@ CreateCalibOptions <- function(FUN_MOD, } } if (is.null(FUN1)) { - stop("FUN1 was not found") + stop("'FUN1' was not found") return(NULL) } ##_set_FUN2 @@ -164,7 +164,7 @@ CreateCalibOptions <- function(FUN_MOD, } } if (is.null(FUN_TRANSFO)) { - stop("FUN_TRANSFO was not found") + stop("'FUN_TRANSFO' was not found") return(NULL) } @@ -211,13 +211,13 @@ CreateCalibOptions <- function(FUN_MOD, stop("FixedParam must be a vector") } if (length(FixedParam) != NParam) { - stop("Incompatibility between FixedParam length and FUN_MOD") + stop("Incompatibility between 'FixedParam' length and 'FUN_MOD'") } if (all(!is.na(FixedParam))) { stop("At least one parameter must be not set (NA)") } if (all(is.na(FixedParam))) { - warning("You have not set any parameter in \"FixedParam\"") + warning("You have not set any parameter in 'FixedParam'") } } @@ -229,19 +229,19 @@ CreateCalibOptions <- function(FUN_MOD, } else { if (!is.matrix(SearchRanges)) { - stop("SearchRanges must be a matrix") + stop("'SearchRanges' must be a matrix") } if (!is.numeric(SearchRanges)) { - stop("SearchRanges must be a matrix of numeric values") + stop("'SearchRanges' must be a matrix of numeric values") } if (sum(is.na(SearchRanges)) != 0) { - stop("SearchRanges must not include NA values") + stop("'SearchRanges' must not include NA values") } if (nrow(SearchRanges) != 2) { - stop("SearchRanges must have 2 rows") + stop("'SearchRanges' must have 2 rows") } if (ncol(SearchRanges) != NParam) { - stop("Incompatibility between SearchRanges ncol and FUN_MOD") + stop("Incompatibility between 'SearchRanges' ncol and 'FUN_MOD'") } } @@ -336,30 +336,30 @@ CreateCalibOptions <- function(FUN_MOD, ##check_StartParamList_and_StartParamDistrib__format if ("HBAN" %in% ObjectClass & !is.null(StartParamList)) { if (!is.matrix(StartParamList)) { - stop("StartParamList must be a matrix") + stop("'StartParamList' must be a matrix") } if (!is.numeric(StartParamList)) { - stop("StartParamList must be a matrix of numeric values") + stop("'StartParamList' must be a matrix of numeric values") } if (sum(is.na(StartParamList)) != 0) { - stop("StartParamList must not include NA values") + stop("'StartParamList' must not include NA values") } if (ncol(StartParamList) != NParam) { - stop("Incompatibility between StartParamList ncol and FUN_MOD") + stop("Incompatibility between 'StartParamList' ncol and 'FUN_MOD'") } } if ("HBAN" %in% ObjectClass & !is.null(StartParamDistrib)) { if (!is.matrix(StartParamDistrib)) { - stop("StartParamDistrib must be a matrix") + stop("'StartParamDistrib' must be a matrix") } if (!is.numeric(StartParamDistrib[1, ])) { - stop("StartParamDistrib must be a matrix of numeric values") + stop("'StartParamDistrib' must be a matrix of numeric values") } if (sum(is.na(StartParamDistrib[1, ])) != 0) { - stop("StartParamDistrib must not include NA values on the first line") + stop("'StartParamDistrib' must not include NA values on the first line") } if (ncol(StartParamDistrib) != NParam) { - stop("Incompatibility between StartParamDistrib ncol and FUN_MOD") + stop("Incompatibility between 'StartParamDistrib' ncol and 'FUN_MOD'") } } diff --git a/R/CreateInputsCrit.R b/R/CreateInputsCrit.R index 5ebd24376c86af2ec8fc2fd5b2a2797da95e687e..8caf75307dab728548d3da7cd33a3268709b825e 100644 --- a/R/CreateInputsCrit.R +++ b/R/CreateInputsCrit.R @@ -30,10 +30,10 @@ CreateInputsCrit <- function(FUN_CRIT, } } if (!missing(Ind_zeroes) & warnings) { - warning("Deprecated 'Ind_zeroes' argument") + warning("deprecated 'Ind_zeroes' argument") } if (!missing(verbose)) { - warning("Deprecated 'verbose' argument. Use 'warnings', instead") + warning("deprecated 'verbose' argument. Use 'warnings', instead") } @@ -329,7 +329,7 @@ CreateInputsCrit <- function(FUN_CRIT, apply(combInputsCrit, MARGIN = 2, function(i) { equalInputsCrit <- identical(InputsCrit[[i[1]]], InputsCrit[[i[2]]]) if(equalInputsCrit) { - warning(sprintf("Elements %i and %i of the criteria list are identical. This might not be necessary", i[1], i[2]), call. = FALSE) + warning(sprintf("elements %i and %i of the criteria list are identical. This might not be necessary", i[1], i[2]), call. = FALSE) } }) } diff --git a/R/CreateInputsModel.R b/R/CreateInputsModel.R index f3175d8855aa30aecf245383cf2e937a303623ed..0b8c456d4b5a3869c566c559a5260c5d1bfd06c3 100644 --- a/R/CreateInputsModel.R +++ b/R/CreateInputsModel.R @@ -60,26 +60,26 @@ CreateInputsModel <- function(FUN_MOD, BOOL <- TRUE } if (!BOOL) { - stop("Incorrect FUN_MOD for use in CreateInputsModel") + stop("incorrect 'FUN_MOD' for use in 'CreateInputsModel'") } ##check_arguments if ("GR" %in% ObjectClass | "CemaNeige" %in% ObjectClass) { if (is.null(DatesR)) { - stop("DatesR is missing") + stop("'DatesR' is missing") } if (!"POSIXlt" %in% class(DatesR) & !"POSIXct" %in% class(DatesR)) { - stop("DatesR must be defined as POSIXlt or POSIXct") + stop("'DatesR' must be defined as 'POSIXlt' or 'POSIXct'") } if (!"POSIXlt" %in% class(DatesR)) { DatesR <- as.POSIXlt(DatesR) } if (!difftime(tail(DatesR, 1), tail(DatesR, 2), units = "secs")[[1]] %in% TimeStep) { TimeStepName <- grep("hourly|daily|monthly|yearly", ObjectClass, value = TRUE) - stop(paste0("The time step of the model inputs must be ", TimeStepName, "\n")) + stop(paste0("the time step of the model inputs must be ", TimeStepName, "\n")) } if (any(duplicated(DatesR))) { - stop("DatesR must not include duplicated values") + stop("'DatesR' must not include duplicated values") } LLL <- length(DatesR) } @@ -88,73 +88,73 @@ CreateInputsModel <- function(FUN_MOD, stop("Precip is missing") } if (is.null(PotEvap)) { - stop("PotEvap is missing") + stop("'PotEvap' is missing") } if (!is.vector(Precip) | !is.vector(PotEvap)) { - stop("Precip and PotEvap must be vectors of numeric values") + stop("'Precip' and 'PotEvap' must be vectors of numeric values") } if (!is.numeric(Precip) | !is.numeric(PotEvap)) { - stop("Precip and PotEvap must be vectors of numeric values") + stop("'Precip' and 'PotEvap' must be vectors of numeric values") } if (length(Precip) != LLL | length(PotEvap) != LLL) { - stop("Precip, PotEvap and DatesR must have the same length") + stop("'Precip', 'PotEvap' and 'DatesR' must have the same length") } } if ("CemaNeige" %in% ObjectClass) { if (is.null(Precip)) { - stop("Precip is missing") + stop("'Precip' is missing") } if (is.null(TempMean)) { - stop("TempMean is missing") + stop("'TempMean' is missing") } if (!is.vector(Precip) | !is.vector(TempMean)) { - stop("Precip and TempMean must be vectors of numeric values") + stop("'Precip' and 'TempMean' must be vectors of numeric values") } if (!is.numeric(Precip) | !is.numeric(TempMean)) { - stop("Precip and TempMean must be vectors of numeric values") + stop("'Precip' and 'TempMean' must be vectors of numeric values") } if (length(Precip) != LLL | length(TempMean) != LLL) { - stop("Precip, TempMean and DatesR must have the same length") + stop("'Precip', 'TempMean' and 'DatesR' must have the same length") } if (is.null(TempMin) != is.null(TempMax)) { - stop("TempMin and TempMax must be both defined if not null") + stop("'TempMin' and 'TempMax' must be both defined if not 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") + stop("'TempMin' and 'TempMax' must be vectors of numeric values") } if (!is.numeric(TempMin) | !is.numeric(TempMax)) { - stop("TempMin and TempMax must be vectors of numeric values") + stop("'TempMin' and 'TempMax' must be vectors of numeric values") } if (length(TempMin) != LLL | length(TempMax) != LLL) { - stop("TempMin, TempMax and DatesR must have the same length") + stop("'TempMin', 'TempMax' and 'DatesR' must have the same length") } } if (!is.null(HypsoData)) { if (!is.vector(HypsoData)) { - stop("HypsoData must be a vector of numeric values if not null") + stop("'HypsoData' must be a vector of numeric values if not null") } if (!is.numeric(HypsoData)) { - stop("HypsoData must be a vector of numeric values if not null") + stop("'HypsoData' must be a vector of numeric values if not null") } if (length(HypsoData) != 101) { - stop("HypsoData must be of length 101 if not null") + stop("'HypsoData' must be of length 101 if not null") } if (sum(is.na(HypsoData)) != 0 & sum(is.na(HypsoData)) != 101) { - stop("HypsoData must not contain any NA if not null") + stop("'HypsoData' must not contain any NA if not null") } } if (!is.null(ZInputs)) { if (length(ZInputs) != 1) { - stop("\t ZInputs must be a single numeric value if not null") + stop("'ZInputs' must be a single numeric value if not null") } if (is.na(ZInputs) | !is.numeric(ZInputs)) { - stop("\t ZInputs must be a single numeric value if not null") + stop("'ZInputs' must be a single numeric value if not null") } } if (is.null(HypsoData)) { if (verbose) { - warning("\t HypsoData is missing => a single layer is used and no extrapolation is made") + warning("'HypsoData' is missing: a single layer is used and no extrapolation is made") } HypsoData <- as.numeric(rep(NA, 101)) ZInputs <- as.numeric(NA) @@ -163,15 +163,15 @@ 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") + warning("'ZInputs' is missing: HypsoData[51] is used") } ZInputs <- HypsoData[51L] } if (NLayers <= 0) { - stop("NLayers must be a positive integer value") + stop("'NLayers' must be a positive integer value") } if (NLayers != as.integer(NLayers)) { - warning("Coerce NLayers to be of integer type (", NLayers, " => ", as.integer(NLayers), ")") + warning("Coerce 'NLayers' to be of integer type (", NLayers, ": ", as.integer(NLayers), ")") NLayers <- as.integer(NLayers) } } @@ -185,14 +185,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") + warning("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") + warning("Values < 0 or NA values detected in 'PotEvap' series") } } } @@ -201,14 +201,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") + warning("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") + warning("Values < -150 or NA values detected in 'TempMean' series") } } if (!is.null(TempMin) & !is.null(TempMax)) { @@ -216,26 +216,26 @@ 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") + warning("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") + warning("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", sep = "") + WTxt <- paste(WTxt, "\t Missing values are not allowed in 'InputsModel'", sep = "") Select <- (max(which(BOOL_NA)) + 1):length(BOOL_NA) if (Select[1L] > Select[2L]) { - stop("Time series could not be trunced since missing values were detected at the list time-step") + stop("time series could not be trunced since missing values were detected at the list time-step") } if ("GR" %in% ObjectClass) { Precip <- Precip[Select] @@ -252,8 +252,8 @@ CreateInputsModel <- function(FUN_MOD, DatesR <- DatesR[Select] - 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 = "") + WTxt <- paste0(WTxt, "\t -> data were trunced to keep the most recent available time-steps") + WTxt <- paste0(WTxt, "\t -> ", length(Select), " time-steps were kept") if (!is.null(WTxt) & verbose) { warning(WTxt) @@ -270,9 +270,9 @@ CreateInputsModel <- function(FUN_MOD, verbose = verbose) if (verbose) { if (NLayers == 1) { - message("\t Input series were successfully created on 1 elevation layer for use by CemaNeige") + message("input series were successfully created on 1 elevation layer for use by CemaNeige") } else { - message( "\t Input series were successfully created on ", NLayers, " elevation layers for use by CemaNeige") + message( "input series were successfully created on ", NLayers, " elevation layers for use by CemaNeige") } } } diff --git a/R/CreateRunOptions.R b/R/CreateRunOptions.R index 3118e3b7b41007452ff9c978c20cd1c48dfaede8..ac2c42f4d694ea9a1500065fa25fc8ad84d120c4 100644 --- a/R/CreateRunOptions.R +++ b/R/CreateRunOptions.R @@ -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("deprecated 'RunSnowModule' argument: please adapt 'FUN_MOD' instead.", call. = FALSE) } if (!is.logical(IsHyst) | length(IsHyst) != 1L) { stop("'IsHyst' must be a 'logical' of length 1") @@ -93,11 +93,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") + WTxt <- paste(WTxt, "model warm up period not defined: default configuration used", sep = "") ##If_the_run_period_starts_at_the_very_beginning_of_the_time_series if (IndPeriod_Run[1L] == 1L) { IndPeriod_WarmUp <- as.integer(0) - WTxt <- paste0(WTxt,"\t No data were found for model warm up!") + WTxt <- paste0(WTxt,"\n 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]] @@ -121,10 +121,10 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP TimeStep <- as.integer(365.25 * 24 * 60 * 60) } if (length(IndPeriod_WarmUp) * TimeStep / (365 * 24 * 60 * 60) >= 1) { - WTxt <- paste0(WTxt, "\t The year preceding the run period is used \n") + WTxt <- paste0(WTxt, "\n the year preceding the run period is used \n") } else { - WTxt <- paste0(WTxt, "\t Less than a year (without missing values) was found for model warm up: \n") - WTxt <- paste0(WTxt, "\t (", length(IndPeriod_WarmUp), " time-steps are used for initialisation) \n") + WTxt <- paste0(WTxt, "\n less than a year (without missing values) was found for model warm up:") + WTxt <- paste0(WTxt, "\n (", length(IndPeriod_WarmUp), " time-steps are used for initialisation)") } } } @@ -139,10 +139,10 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP stop("'IndPeriod_WarmUp' should be of type integer") } if (identical(IndPeriod_WarmUp, as.integer(0)) & verbose) { - message(paste0(WTxt, "\t No warm up period is used \n")) + message(paste0(WTxt, ". No warm up period is used")) } if ((IndPeriod_Run[1] - 1) != tail(IndPeriod_WarmUp, 1) & !identical(IndPeriod_WarmUp, as.integer(0))) { - WTxt <- paste0(WTxt, "\t Model warm up period is not directly before the model run period \n") + WTxt <- paste0(WTxt, ". Model warm up period is not directly before the model run period") } } if (!is.null(WTxt) & warnings) { @@ -161,11 +161,11 @@ 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'") + stop("the length of 'IniResLevels' must be 2 for the chosen 'FUN_MOD'") } 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'") + stop("the length of 'IniResLevels' must be 3 for the chosen 'FUN_MOD'") } } else if (is.null(IniStates)) { if (identical(FUN_MOD, RunModel_GR6J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J)) { @@ -181,10 +181,10 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP } ## check IniStates if (is.null(IniStates) & is.null(IniResLevels) & warnings) { - warning("\t Model states initialisation not defined -> default configuration used") + warning("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'") + warning("'IniStates' and 'IniResLevels' are both defined: store levels are taken from 'IniResLevels'") } if ("CemaNeige" %in% ObjectClass) { NLayers <- length(InputsModel$LayerPrecip) @@ -212,22 +212,22 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP stop("'IniStates' must be an object of class 'IniStates'\n") } 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")) } if (identical(FUN_MOD, RunModel_GR1A) & !is.null(IniStates)) { ## GR1A stop(paste0("'IniStates' is not available for this 'FUN_MOD'\n")) } 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")) + stop(paste0("non convenient IniStates for this 'FUN_MOD.' In 'IniStates', 'UH1' has to be a vector of NA for GR5J")) } 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'")) + stop(paste0("non convenient IniStates for this 'FUN_MOD.' GR6J needs an exponential store value in 'IniStates'")) } 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'")) + stop(paste0("non convenient IniStates for this 'FUN_MOD.' No exponential store value needed in 'IniStates'")) } # if (length(na.omit(unlist(IniStates))) != NState) { - # stop(paste0("The length of IniStates must be ", NState, " for the chosen FUN_MOD")) + # stop(paste0("the length of IniStates must be ", NState, " for the chosen FUN_MOD")) # } if (!"CemaNeige" %in% ObjectClass & any(is.na(IniStates$CemaNeigeLayers$G ))) { IniStates$CemaNeigeLayers$G <- NULL @@ -274,13 +274,13 @@ 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") + stop("'Outputs_Sim' must be a vector of characters") } if (!is.character(Outputs_Sim)) { - stop("Outputs_Sim must be a vector of characters") + stop("'Outputs_Sim' must be a vector of characters") } if (sum(is.na(Outputs_Sim)) != 0) { - stop("Outputs_Sim must not contain NA") + stop("'Outputs_Sim' must not contain NA") } if ("all" %in% Outputs_Sim) { Outputs_Sim <- c("DatesR", Outputs_all, "StateEnd") @@ -360,7 +360,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP MeanAnSolidPrecip <- rep(mean(SolidPrecip) * Factor, NLayers) ### default value: same Gseuil for all layers if (warnings) { - warning("\t 'MeanAnSolidPrecip' not defined -> it was automatically set to c(", + warning("'MeanAnSolidPrecip' not defined: it was automatically set to c(", paste(round(MeanAnSolidPrecip), collapse = ","), ") from the 'InputsModel' given to the function. ", "Be careful in case your application is (short-term) forecasting.\n") } @@ -382,8 +382,8 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP if ("GR" %in% ObjectClass & "CemaNeige" %in% ObjectClass) { if (!"PliqAndMelt" %in% Outputs_Cal & !"all" %in% Outputs_Cal) { 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 -> it was automatically added \n") + WTxt <- paste0(WTxt, "'PliqAndMelt' was not defined in 'Outputs_Cal' but is needed to feed the hydrological model with the snow modele outputs \n") + WTxt <- paste0(WTxt, ": it was automatically added \n") if (!is.null(WTxt) & warnings) { warning(WTxt) } @@ -391,8 +391,8 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP } if (!"PliqAndMelt" %in% Outputs_Sim & !"all" %in% Outputs_Sim) { 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 -> it was automatically added \n") + WTxt <- paste0(WTxt, "'PliqAndMelt' was not defined in 'Outputs_Sim' but is needed to feed the hydrological model with the snow modele outputs \n") + WTxt <- paste0(WTxt, ": it was automatically added \n") if (!is.null(WTxt) & warnings) { warning(WTxt) } @@ -405,8 +405,8 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP if ("GR" %in% ObjectClass) { if (!"Qsim" %in% Outputs_Cal & !"all" %in% Outputs_Cal) { WTxt <- NULL - WTxt <- paste0(WTxt, "\t 'Qsim' was not defined in 'Outputs_Cal' \n") - WTxt <- paste0(WTxt, "\t -> it was automatically added \n") + WTxt <- paste0(WTxt, "'Qsim' was not defined in 'Outputs_Cal' \n") + WTxt <- paste0(WTxt, ": it was automatically added \n") if (!is.null(WTxt) & warnings) { warning(WTxt) } @@ -414,8 +414,8 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP } if (!"Qsim" %in% Outputs_Sim & !"all" %in% Outputs_Sim) { WTxt <- NULL - WTxt <- paste0(WTxt, "\t 'Qsim' was not defined in 'Outputs_Sim' \n") - WTxt <- paste0(WTxt, "\t -> it was automatically added \n") + WTxt <- paste0(WTxt, "'Qsim' was not defined in 'Outputs_Sim' \n") + WTxt <- paste0(WTxt, ": it was automatically added \n") if (!is.null(WTxt) & warnings) { warning(WTxt) } @@ -432,8 +432,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP Outputs_Sim = Outputs_Sim) if ("CemaNeige" %in% ObjectClass) { - RunOptions <- - c(RunOptions, list(MeanAnSolidPrecip = MeanAnSolidPrecip)) + RunOptions <- c(RunOptions, list(MeanAnSolidPrecip = MeanAnSolidPrecip)) } class(RunOptions) <- c("RunOptions", ObjectClass) diff --git a/R/DataAltiExtrapolation_Valery.R b/R/DataAltiExtrapolation_Valery.R index e75850b001fdbd55925490e81272820107d49427..d1e85cca51719f4e50dd12c3109e2e6780294637 100644 --- a/R/DataAltiExtrapolation_Valery.R +++ b/R/DataAltiExtrapolation_Valery.R @@ -485,7 +485,6 @@ DataAltiExtrapolation_Valery <- function(DatesR, if (!is.null(TempMin) & !is.null(TempMax)) { LayerTempMin[[iLayer]] <- as.double(TempMin + (ZInputs - ZLayers[iLayer]) * abs(TabGradT[, "grad_Tmin"]) / 100) LayerTempMax[[iLayer]] <- as.double(TempMax + (ZInputs - ZLayers[iLayer]) * abs(TabGradT[, "grad_Tmax"]) / 100) - } } } @@ -550,4 +549,3 @@ DataAltiExtrapolation_Valery <- function(DatesR, } - diff --git a/R/ErrorCrit_KGE.R b/R/ErrorCrit_KGE.R index 3cb2952b80783f39c1456a8687d679292ea25ae6..f6dbcd6d0752b0a05d2b2fe365b4981e35202622 100644 --- a/R/ErrorCrit_KGE.R +++ b/R/ErrorCrit_KGE.R @@ -3,13 +3,13 @@ ErrorCrit_KGE <- function(InputsCrit, OutputsModel, warnings = TRUE, verbose = T ##Arguments_check________________________________ if (!inherits(InputsCrit, "InputsCrit")) { - stop("InputsCrit must be of class 'InputsCrit'") + stop("'InputsCrit' must be of class 'InputsCrit'") } if (inherits(InputsCrit, "Multi") | inherits(InputsCrit, "Compo")) { - stop("InputsCrit must be of class 'Single'. Use the ErrorCrit function on objects of class 'Multi' or 'Compo' with KGE") + stop("'InputsCrit' must be of class 'Single'. Use the 'ErrorCrit' function on objects of class 'Multi' or 'Compo' with KGE") } if (!inherits(OutputsModel, "OutputsModel")) { - stop("OutputsModel must be of class 'OutputsModel'") + stop("'OutputsModel' must be of class 'OutputsModel'") } @@ -55,7 +55,7 @@ ErrorCrit_KGE <- function(InputsCrit, OutputsModel, warnings = TRUE, verbose = T ##Data_transformation if (InputsCrit$transfo %in% c("log", "inv") & is.null(InputsCrit$epsilon) & warnings) { if (any(VarObs %in% 0)) { - warning("zeroes detected in Qobs: the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") + warning("zeroes detected in 'Qobs': the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") } if (any(VarSim %in% 0)) { warning("zeroes detected in Qsim: the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") diff --git a/R/ErrorCrit_KGE2.R b/R/ErrorCrit_KGE2.R index aab7a47235f91c3979b91d136439b2cb5c3e064d..a98bb7e0f32d714107282270f74bd592025ede29 100644 --- a/R/ErrorCrit_KGE2.R +++ b/R/ErrorCrit_KGE2.R @@ -3,13 +3,13 @@ ErrorCrit_KGE2 <- function(InputsCrit, OutputsModel, warnings = TRUE, verbose = ##Arguments_check________________________________ if (!inherits(InputsCrit, "InputsCrit")) { - stop("InputsCrit must be of class 'InputsCrit'") + stop("'InputsCrit' must be of class 'InputsCrit'") } if (inherits(InputsCrit, "Multi") | inherits(InputsCrit, "Compo")) { - stop("InputsCrit must be of class 'Single'. Use the ErrorCrit function on objects of class 'Multi' or 'Compo' with KGE'") + stop("'InputsCrit' must be of class 'Single'. Use the 'ErrorCrit' function on objects of class 'Multi' or 'Compo' with KGE'") } if (!inherits(OutputsModel, "OutputsModel")) { - stop("OutputsModel must be of class 'OutputsModel'") + stop("'OutputsModel' must be of class 'OutputsModel'") } @@ -58,7 +58,7 @@ ErrorCrit_KGE2 <- function(InputsCrit, OutputsModel, warnings = TRUE, verbose = warning("zeroes detected in Qobs: the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") } if (any(VarSim %in% 0)) { - warning("zeroes detected in Qsim: the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") + warning("zeroes detected in 'Qsim': the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") } } if ("epsilon" %in% names(InputsCrit) & !is.null(InputsCrit$epsilon)) { diff --git a/R/ErrorCrit_NSE.R b/R/ErrorCrit_NSE.R index a7da13d95824f7c0bc75f2d58b7e6e20e3f76226..cf1e17f3171e9bab0942305650c7fada214c5b40 100644 --- a/R/ErrorCrit_NSE.R +++ b/R/ErrorCrit_NSE.R @@ -3,13 +3,13 @@ ErrorCrit_NSE <- function(InputsCrit, OutputsModel, warnings = TRUE, verbose = T ##Arguments_check________________________________ if (!inherits(InputsCrit, "InputsCrit")) { - stop("InputsCrit must be of class 'InputsCrit'") + stop("'InputsCrit' must be of class 'InputsCrit'") } if (inherits(InputsCrit, "Multi") | inherits(InputsCrit, "Compo")) { - stop("InputsCrit must be of class 'Single'. Use the ErrorCrit function on objects of class 'Multi' or 'Compo' with NSE") + stop("'InputsCrit' must be of class 'Single'. Use the 'ErrorCrit' function on objects of class 'Multi' or 'Compo' with NSE") } if (!inherits(OutputsModel, "OutputsModel")) { - stop("OutputsModel must be of class 'OutputsModel'") + stop("'OutputsModel' must be of class 'OutputsModel'") } @@ -55,10 +55,10 @@ ErrorCrit_NSE <- function(InputsCrit, OutputsModel, warnings = TRUE, verbose = T ##Data_transformation if (InputsCrit$transfo %in% c("log", "inv") & is.null(InputsCrit$epsilon) & warnings) { if (any(VarObs %in% 0)) { - warning("zeroes detected in Qobs: the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") + warning("zeroes detected in 'Qobs': the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") } if (any(VarSim %in% 0)) { - warning("zeroes detected in Qsim: the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") + warning("zeroes detected in 'Qsim': the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") } } if ("epsilon" %in% names(InputsCrit) & !is.null(InputsCrit$epsilon)) { diff --git a/R/ErrorCrit_RMSE.R b/R/ErrorCrit_RMSE.R index 3e5d28f6769e9172b3751e0e255987906e61bd03..68f7121605ab5011168525b63e19566a132d1d3a 100644 --- a/R/ErrorCrit_RMSE.R +++ b/R/ErrorCrit_RMSE.R @@ -3,13 +3,13 @@ ErrorCrit_RMSE <- function(InputsCrit, OutputsModel, warnings = TRUE, verbose = ##Arguments_check________________________________ if (!inherits(InputsCrit, "InputsCrit")) { - stop("InputsCrit must be of class 'InputsCrit'") + stop("'InputsCrit' must be of class 'InputsCrit'") } if (inherits(InputsCrit, "Multi") | inherits(InputsCrit, "Compo")) { - stop("InputsCrit must be of class 'Single'. Use the ErrorCrit function on objects of class 'Multi' with RMSE") + stop("'InputsCrit' must be of class 'Single'. Use the 'ErrorCrit' function on objects of class 'Multi' with RMSE") } if (!inherits(OutputsModel, "OutputsModel")) { - stop("OutputsModel must be of class 'OutputsModel'") + stop("'OutputsModel' must be of class 'OutputsModel'") } @@ -55,10 +55,10 @@ ErrorCrit_RMSE <- function(InputsCrit, OutputsModel, warnings = TRUE, verbose = ##Data_transformation if (InputsCrit$transfo %in% c("log", "inv") & is.null(InputsCrit$epsilon) & warnings) { if (any(VarObs %in% 0)) { - warning("zeroes detected in Qobs: the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") + warning("zeroes detected in 'Qobs': the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") } if (any(VarSim %in% 0)) { - warning("zeroes detected in Qsim: the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") + warning("zeroes detected in 'Qsim': the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL") } } if ("epsilon" %in% names(InputsCrit) & !is.null(InputsCrit$epsilon)) { diff --git a/R/PEdaily_Oudin.R b/R/PEdaily_Oudin.R index dd42174ad801c80938fdfde88269a465b3f73dc0..4883dd34d7c2c5fe821826810c7fcf9cf92481ed 100644 --- a/R/PEdaily_Oudin.R +++ b/R/PEdaily_Oudin.R @@ -19,7 +19,7 @@ PEdaily_Oudin <- function(JD, Temp, LatRad, Lat, LatUnit = c("rad", "deg")) { stop("'Temp' and 'LatUnit' must have the same length") } if (!any(LatUnit %in% c("rad", "deg"))) { - stop("'LatUnit' must be \"rad\" or \"deg\"") + stop("'LatUnit' must be one of \"rad\" or \"deg\"") } if (!inherits(Lat, "numeric") | length(Lat) != 1) { stop("'Lat' must be a 'numeric' of length one") @@ -106,4 +106,3 @@ PEdaily_Oudin <- function(JD, Temp, LatRad, Lat, LatUnit = c("rad", "deg")) { return(PE_Oudin_D) } - diff --git a/R/RunModel_CemaNeige.R b/R/RunModel_CemaNeige.R index d58e93dfe7ab82ea697605597c029f9e92f84b67..b307918c98a12a8a0d880bd1e8e5cf4a1fa2a5d4 100644 --- a/R/RunModel_CemaNeige.R +++ b/R/RunModel_CemaNeige.R @@ -151,4 +151,3 @@ RunModel_CemaNeige <- function(InputsModel, RunOptions, Param) { } return(OutputsModel) } - diff --git a/R/RunModel_CemaNeigeGR4J.R b/R/RunModel_CemaNeigeGR4J.R index 6c79f9bc7f2f48aea16e3b10e972acb9fc2878a9..63566371ba1f98bf8002658dc38066c6b51e4884 100644 --- a/R/RunModel_CemaNeigeGR4J.R +++ b/R/RunModel_CemaNeigeGR4J.R @@ -9,15 +9,15 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ ##Arguments_check - if(!inherits(InputsModel,"InputsModel")){ stop("InputsModel must be of class 'InputsModel'") } - if(!inherits(InputsModel,"daily" )){ stop("InputsModel must be of class 'daily' ") } - if(!inherits(InputsModel,"GR" )){ stop("InputsModel must be of class 'GR' ") } - if(!inherits(InputsModel,"CemaNeige" )){ stop("InputsModel must be of class 'CemaNeige' ") } - if(!inherits(RunOptions,"RunOptions" )){ stop("RunOptions must be of class 'RunOptions' ") } - if(!inherits(RunOptions,"GR" )){ stop("RunOptions must be of class 'GR' ") } - if(!inherits(RunOptions,"CemaNeige" )){ stop("RunOptions must be of class 'CemaNeige' ") } - if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector") } - if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")) } + if(!inherits(InputsModel,"InputsModel")){ stop("'InputsModel' must be of class 'InputsModel'") } + if(!inherits(InputsModel,"daily" )){ stop("'InputsModel' must be of class 'daily' ") } + if(!inherits(InputsModel,"GR" )){ stop("'InputsModel' must be of class 'GR' ") } + if(!inherits(InputsModel,"CemaNeige" )){ stop("'InputsModel' must be of class 'CemaNeige' ") } + if(!inherits(RunOptions,"RunOptions" )){ stop("'RunOptions' must be of class 'RunOptions' ") } + if(!inherits(RunOptions,"GR" )){ stop("'RunOptions' must be of class 'GR' ") } + if(!inherits(RunOptions,"CemaNeige" )){ stop("'RunOptions' must be of class 'CemaNeige' ") } + if(!is.vector(Param) | !is.numeric(Param)){ stop("'Param' must be a numeric vector") } + if(sum(!is.na(Param))!=NParam){ stop(paste("'Param' must be a vector of length ",NParam," and contain no NA",sep="")) } Param <- as.double(Param); Param_X1X3_threshold <- 1e-2 @@ -179,4 +179,3 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ return(OutputsModel); } - diff --git a/R/RunModel_CemaNeigeGR5J.R b/R/RunModel_CemaNeigeGR5J.R index 9ae4c341327ad5fff5f1015b98ba4b1d7a946af0..02d0374afba25dd62fa5e234c13df0f8e11c1774 100644 --- a/R/RunModel_CemaNeigeGR5J.R +++ b/R/RunModel_CemaNeigeGR5J.R @@ -7,15 +7,15 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){ FortranOutputs <- .FortranOutputs(GR = "GR5J", isCN = TRUE) ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'") } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' ") } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' ") } - if(inherits(InputsModel,"CemaNeige" )==FALSE){ stop("InputsModel must be of class 'CemaNeige' ") } - if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' ") } - if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' ") } - if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("RunOptions must be of class 'CemaNeige' ") } - if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector") } - if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")) } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") } + if(inherits(InputsModel,"daily" )==FALSE){ stop("'InputsModel' must be of class 'daily' ") } + if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") } + if(inherits(InputsModel,"CemaNeige" )==FALSE){ stop("'InputsModel' must be of class 'CemaNeige' ") } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") } + if(inherits(RunOptions,"GR" )==FALSE){ stop("'RunOptions' must be of class 'GR' ") } + if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("'RunOptions' must be of class 'CemaNeige' ") } + if(!is.vector(Param) | !is.numeric(Param)){ stop("'Param' must be a numeric vector") } + if(sum(!is.na(Param))!=NParam){ stop(paste("'Param' must be a vector of length ",NParam," and contain no NA",sep="")) } Param <- as.double(Param); Param_X1X3_threshold <- 1e-2 @@ -176,4 +176,3 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){ return(OutputsModel); } - diff --git a/R/RunModel_CemaNeigeGR6J.R b/R/RunModel_CemaNeigeGR6J.R index db28275a9949e4a48ad3edf19addd7f1181b75e5..b17bf2d454288b0615463cc612a30e5e2b3f2cfe 100644 --- a/R/RunModel_CemaNeigeGR6J.R +++ b/R/RunModel_CemaNeigeGR6J.R @@ -7,15 +7,15 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){ FortranOutputs <- .FortranOutputs(GR = "GR6J", isCN = TRUE) ##Arguments_check - if(inherits(InputsModel,"InputsModel")==FALSE){ stop("InputsModel must be of class 'InputsModel'") } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' ") } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' ") } - if(inherits(InputsModel,"CemaNeige" )==FALSE){ stop("InputsModel must be of class 'CemaNeige' ") } - if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' ") } - if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' ") } - if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("RunOptions must be of class 'CemaNeige' ") } - if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector") } - if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")) } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") } + if(inherits(InputsModel,"daily" )==FALSE){ stop("'InputsModel' must be of class 'daily' ") } + if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") } + if(inherits(InputsModel,"CemaNeige" )==FALSE){ stop("'InputsModel' must be of class 'CemaNeige' ") } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") } + if(inherits(RunOptions,"GR" )==FALSE){ stop("'RunOptions' must be of class 'GR' ") } + if(inherits(RunOptions,"CemaNeige" )==FALSE){ stop("'RunOptions' must be of class 'CemaNeige' ") } + if(!is.vector(Param) | !is.numeric(Param)){ stop("'Param' must be a numeric vector") } + if(sum(!is.na(Param))!=NParam){ stop(paste("'Param' must be a vector of length ",NParam," and contain no NA",sep="")) } Param <- as.double(Param); Param_X1X3X6_threshold <- 1e-2 diff --git a/R/RunModel_GR1A.R b/R/RunModel_GR1A.R index 4c0eaee3df609bf28bc6ad5d498df4aab307522a..d636ab4d2ab7e04e73a47d6334965c1614c563ef 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'") } - if(inherits(InputsModel,"yearly" )==FALSE){ stop("InputsModel must be of class 'yearly' ") } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' ") } - if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' ") } - if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' ") } - if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector") } - if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")) } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") } + if(inherits(InputsModel,"yearly" )==FALSE){ stop("'InputsModel' must be of class 'yearly' ") } + if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") } + if(inherits(RunOptions,"GR" )==FALSE){ stop("'RunOptions' must be of class 'GR' ") } + if(!is.vector(Param) | !is.numeric(Param)){ stop("'Param' must be a numeric vector") } + if(sum(!is.na(Param))!=NParam){ stop(paste("'Param' must be a vector of length ",NParam," and contain no NA",sep="")) } Param <- as.double(Param); ##Input_data_preparation diff --git a/R/RunModel_GR2M.R b/R/RunModel_GR2M.R index ac37b14a74f81ce53557959bc7cf3d14ceffddb7..7f414e9f7fb2e4675551ce3d25cb2241e1726a17 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'") } - if(inherits(InputsModel,"monthly" )==FALSE){ stop("InputsModel must be of class 'monthly' ") } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' ") } - if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' ") } - if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' ") } - if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector") } - if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")) } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") } + if(inherits(InputsModel,"monthly" )==FALSE){ stop("'InputsModel' must be of class 'monthly' ") } + if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") } + if(inherits(RunOptions,"GR" )==FALSE){ stop("'RunOptions' must be of class 'GR' ") } + if(!is.vector(Param) | !is.numeric(Param)){ stop("'Param' must be a numeric vector") } + if(sum(!is.na(Param))!=NParam){ stop(paste("'Param' must be a vector of length ",NParam," and contain no NA",sep="")) } Param <- as.double(Param); Param_X1X2_threshold <- 1e-2 @@ -96,4 +96,3 @@ RunModel_GR2M <- function(InputsModel,RunOptions,Param){ return(OutputsModel); } - diff --git a/R/RunModel_GR4H.R b/R/RunModel_GR4H.R index 30d2532b565081b3f5eb8873c19dce7f9584fb36..ad6dd7d189f7a833c8ebf082d97f7a1ee9fdb860 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'") } - if(inherits(InputsModel,"hourly" )==FALSE){ stop("InputsModel must be of class 'hourly' ") } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' ") } - if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' ") } - if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' ") } - if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector") } - if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")) } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") } + if(inherits(InputsModel,"hourly" )==FALSE){ stop("'InputsModel' must be of class 'hourly' ") } + if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") } + if(inherits(RunOptions,"GR" )==FALSE){ stop("'RunOptions' must be of class 'GR' ") } + if(!is.vector(Param) | !is.numeric(Param)){ stop("'Param' must be a numeric vector") } + if(sum(!is.na(Param))!=NParam){ stop(paste("'Param' must be a vector of length ",NParam," and contain no NA",sep="")) } Param <- as.double(Param); Param_X1X3_threshold <- 1e-2 @@ -100,4 +100,3 @@ RunModel_GR4H <- function(InputsModel,RunOptions,Param){ return(OutputsModel); } - diff --git a/R/RunModel_GR4J.R b/R/RunModel_GR4J.R index 622d4edb10d637928917046234b00bfac83ff802..c0ea07f744a421c892ba011e284808415ea14a2b 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'") } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' ") } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' ") } - if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' ") } - if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' ") } - if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector") } - if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")) } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") } + if(inherits(InputsModel,"daily" )==FALSE){ stop("'InputsModel' must be of class 'daily' ") } + if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") } + if(inherits(RunOptions,"GR" )==FALSE){ stop("'RunOptions' must be of class 'GR' ") } + if(!is.vector(Param) | !is.numeric(Param)){ stop("'Param' must be a numeric vector") } + if(sum(!is.na(Param))!=NParam){ stop(paste("'Param' must be a vector of length ",NParam," and contain no NA",sep="")) } Param <- as.double(Param); Param_X1X3_threshold <- 1e-2 @@ -99,4 +99,3 @@ RunModel_GR4J <- function(InputsModel,RunOptions,Param){ return(OutputsModel); } - diff --git a/R/RunModel_GR5J.R b/R/RunModel_GR5J.R index 7d253668173424c80495dd15e3be39a71246f3b8..e098f09d3701cbeefd306734bbb9ec30122f2fc0 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'") } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' ") } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' ") } - if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' ") } - if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' ") } - if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector") } - if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")) } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") } + if(inherits(InputsModel,"daily" )==FALSE){ stop("'InputsModel' must be of class 'daily' ") } + if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") } + if(inherits(RunOptions,"GR" )==FALSE){ stop("'RunOptions' must be of class 'GR' ") } + if(!is.vector(Param) | !is.numeric(Param)){ stop("'Param' must be a numeric vector") } + if(sum(!is.na(Param))!=NParam){ stop(paste("'Param' must be a vector of length ",NParam," and contain no NA",sep="")) } Param <- as.double(Param); Param_X1X3_threshold <- 1e-2 @@ -100,4 +100,3 @@ RunModel_GR5J <- function(InputsModel,RunOptions,Param){ return(OutputsModel); } - diff --git a/R/RunModel_GR6J.R b/R/RunModel_GR6J.R index 64f69add53ce986b7f7eee3cb7f5cb650e0819fb..2f36a24a1d874d13da303ef68c74487abfd7ce7f 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'") } - if(inherits(InputsModel,"daily" )==FALSE){ stop("InputsModel must be of class 'daily' ") } - if(inherits(InputsModel,"GR" )==FALSE){ stop("InputsModel must be of class 'GR' ") } - if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("RunOptions must be of class 'RunOptions' ") } - if(inherits(RunOptions,"GR" )==FALSE){ stop("RunOptions must be of class 'GR' ") } - if(!is.vector(Param) | !is.numeric(Param)){ stop("Param must be a numeric vector") } - if(sum(!is.na(Param))!=NParam){ stop(paste("Param must be a vector of length ",NParam," and contain no NA",sep="")) } + if(inherits(InputsModel,"InputsModel")==FALSE){ stop("'InputsModel' must be of class 'InputsModel'") } + if(inherits(InputsModel,"daily" )==FALSE){ stop("'InputsModel' must be of class 'daily' ") } + if(inherits(InputsModel,"GR" )==FALSE){ stop("'InputsModel' must be of class 'GR' ") } + if(inherits(RunOptions,"RunOptions" )==FALSE){ stop("'RunOptions' must be of class 'RunOptions' ") } + if(inherits(RunOptions,"GR" )==FALSE){ stop("'RunOptions' must be of class 'GR' ") } + if(!is.vector(Param) | !is.numeric(Param)){ stop("'Param' must be a numeric vector") } + if(sum(!is.na(Param))!=NParam){ stop(paste("'Param' must be a vector of length ",NParam," and contain no NA",sep="")) } Param <- as.double(Param); Param_X1X3X6_threshold <- 1e-2 @@ -105,4 +105,4 @@ RunModel_GR6J <- function(InputsModel,RunOptions,Param){ return(OutputsModel); } - + \ No newline at end of file diff --git a/R/SeriesAggreg.R b/R/SeriesAggreg.R index 5ee8d9975307b8063bb491f54cb39c840c56f207..a1c3434ffb2876e2017ac75c1408a93a504b91cf 100644 --- a/R/SeriesAggreg.R +++ b/R/SeriesAggreg.R @@ -9,91 +9,91 @@ SeriesAggreg <- function(TabSeries, ##check_TabSeries if (is.null(TabSeries) ) { - stop("TabSeries must be a dataframe containing the dates and data to be converted") + stop("'TabSeries' must be a data.frame containing the dates and data to be converted") } if (!is.data.frame(TabSeries)) { - stop("TabSeries must be a dataframe containing the dates and data to be converted") + stop("'TabSeries' must be a data.frame containing the dates and data to be converted") } if (ncol(TabSeries) < 2) { - stop("TabSeries must contain at least two columns (including the coulmn of dates") + stop("'TabSeries' must contain at least two columns (including the coulmn of dates") } ##check_TimeFormat if (!any(class(TabSeries[, 1]) %in% "POSIXt")) { - stop("TabSeries first column must be a vector of class POSIXlt or POSIXct") + stop("'TabSeries' first column must be a vector of class 'POSIXlt' or 'POSIXct'") } if (any(class(TabSeries[, 1]) %in% "POSIXlt")) { TabSeries[, 1] <- as.POSIXct(TabSeries[, 1]) } for (iCol in 2:ncol(TabSeries)) { if (!is.numeric(TabSeries[,iCol])) { - stop("TabSeries columns (other than the first one) be of numeric class") + stop("'TabSeries' columns (other than the first one) be of numeric class") } } if (is.null(TimeFormat)) { - stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") + stop("'TimeFormat' must be one of 'hourly', 'daily', 'monthly' or 'yearly'") } if (!is.vector(TimeFormat)) { - stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") + stop("'TimeFormat' must be one of 'hourly', 'daily', 'monthly' or 'yearly'") } if (!is.character(TimeFormat)) { - stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") + stop("'TimeFormat' must be one of 'hourly', 'daily', 'monthly' or 'yearly'") } if (length(TimeFormat) != 1) { - stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") + stop("'TimeFormat' must be one of 'hourly', 'daily', 'monthly' or 'yearly'") } if (! TimeFormat %in% c("hourly", "daily", "monthly", "yearly")) { - stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") + stop("'TimeFormat' must be one of 'hourly', 'daily', 'monthly' or 'yearly'") } ##check_NewTimeFormat if (is.null(NewTimeFormat)) { - stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") + stop("'NewTimeFormat' must be one of 'hourly', 'daily', 'monthly' or 'yearly'") } if (!is.vector(NewTimeFormat)) { - stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") + stop("'NewTimeFormat' must be one of 'hourly', 'daily', 'monthly' or 'yearly'") } if (!is.character(NewTimeFormat)) { - stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") + stop("'NewTimeFormat' must be one of 'hourly', 'daily', 'monthly' or 'yearly'") } if (length(NewTimeFormat) != 1) { - stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") + stop("'NewTimeFormat' must be one of 'hourly', 'daily', 'monthly' or 'yearly'") } if (! NewTimeFormat %in% c("hourly", "daily", "monthly", "yearly")) { - stop("NewTimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly'") + stop("'NewTimeFormat' must be one of 'hourly', 'daily', 'monthly' or 'yearly'") } ##check_ConvertFun if (is.null(ConvertFun)) { - stop("ConvertFun must be a vector of character") + stop("'ConvertFun' must be a vector of character") } if (!is.vector(ConvertFun)) { - stop("ConvertFun must be a vector of character") + stop("'ConvertFun' must be a vector of character") } if (!is.character(ConvertFun)) { - stop("ConvertFun must be a vector of character") + stop("'ConvertFun' must be a vector of character") } if (length(ConvertFun) != (ncol(TabSeries) - 1)) { stop( - paste("ConvertFun must be of length", ncol(TabSeries) - 1, "(length=ncol(TabSeries)-1)") + paste("'ConvertFun' must be of length", ncol(TabSeries) - 1, "(length=ncol(TabSeries)-1)") ) } if (sum(ConvertFun %in% c("sum", "mean") == FALSE) != 0) { - stop("ConvertFun elements must be either 'sum' or 'mean'") + stop("'ConvertFun' elements must be one of 'sum' or 'mean'") } ##check_YearFirstMonth if (is.null(YearFirstMonth)) { - stop("YearFirstMonth must be an integer between 1 and 12") + stop("'YearFirstMonth' must be an integer between 1 and 12") } if (!is.vector(YearFirstMonth)) { - stop("YearFirstMonth must be an integer between 1 and 12") + stop("'YearFirstMonth' must be an integer between 1 and 12") } if (!is.numeric(YearFirstMonth)) { - stop("YearFirstMonth must be an integer between 1 and 12") + stop("'YearFirstMonth' must be an integer between 1 and 12") } YearFirstMonth <- as.integer(YearFirstMonth) if (length(YearFirstMonth) != 1) { - stop("YearFirstMonth must be only one integer between 1 and 12") + stop("'YearFirstMonth' must be only one integer between 1 and 12") } if (YearFirstMonth %in% (1:12) == FALSE) { - stop("YearFirstMonth must be only one integer between 1 and 12") + stop("'YearFirstMonth' must be only one integer between 1 and 12") } ##check_DatesR_integrity if (TimeFormat == "hourly") { @@ -110,13 +110,13 @@ 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") + stop("some dates might not be ordered or are missing in 'TabSeries'") } ##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") + stop("only time aggregation can be performed") } ##check_if_conversion_not_needed if ((TimeFormat == "hourly" & NewTimeFormat == "hourly" ) | @@ -124,7 +124,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") + warning("the old and new format are identical \n\t -> no time-step conversion was performed") return(TabSeries) } } @@ -165,7 +165,7 @@ SeriesAggreg <- function(TabSeries, NewDatesR <- data.frame(seq(from = TmpDatesR[min(Ind1)], to = TmpDatesR[max(Ind2)], by = "days")) } if (NewTimeFormat=="monthly") { - Ind1 <- which(format(TmpDatesR, "%d%H")=="0100") + Ind1 <- which(format(TmpDatesR, "%d%H") == "0100") Ind2 <- which(format(TmpDatesR,"%m%d%H") %in% paste0(c("0131", "0228", "0229", "0331", "0430", "0531", "0630", "0731", "0831", "0930", "1031", "1130", "1231"), Hmax)) Ind2[1:(length(Ind2) - 1)][diff(Ind2) == 1] <- NA Ind2 <- Ind2[!is.na(Ind2)] ### to keep only feb 29 if both feb 28 and feb 29 exists diff --git a/R/TransfoParam_CemaNeige.R b/R/TransfoParam_CemaNeige.R index b0b40417420f6d62e95ac53f972ab42bc7130cea..add5b9192756d0b6e43c3fe45925a312d3f397a6 100644 --- a/R/TransfoParam_CemaNeige.R +++ b/R/TransfoParam_CemaNeige.R @@ -16,7 +16,7 @@ TransfoParam_CemaNeige <- function(ParamIn, Direction) { stop("'Direction' must be a character vector of length 1 equal to 'RT' or 'TR'") } if (ncol(ParamIn) != NParam) { - stop(sprintf( "the CemaNeige module requires %i parameters", NParam)) + stop(sprintf("the CemaNeige module requires %i parameters", NParam)) } diff --git a/R/plot.OutputsModel.R b/R/plot.OutputsModel.R index 5a1c5b1aa27daa350734007f53c91d5b99d33d59..56f98a751804b8e4ca3e1acfeff7eed56eab0dbc 100644 --- a/R/plot.OutputsModel.R +++ b/R/plot.OutputsModel.R @@ -29,7 +29,7 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = BOOL_Qobs <- TRUE } } else if (inherits(OutputsModel, "GR") & !is.null(Qobs)) { - warning("Incorrect length of 'Qobs'. Time series of observed flow not drawn") + warning("incorrect length of 'Qobs'. Time series of observed flow not drawn") } BOOL_Snow <- FALSE @@ -55,7 +55,7 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = stop("'which' must be a vector of character") } 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'") + stop("incorrect element found in argument 'which':\nit can only contain 'all', 'Precip', 'Temp', 'SnowPack', 'Flows', 'Regime', 'CumFreq' or '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'") @@ -150,10 +150,10 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = 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") + warning("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") + warning("zeroes detected in 'Qsim': some plots in the log space will not be created using all time-steps") } BOOL_FilterZero <- TRUE @@ -799,5 +799,4 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = ## Restoring_layout_options layout(1) - }