Commit d60a9458 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.4.3.68 CLEAN: LatUnit, TimeStepIn and TimeStepInOut arguments now checked...

v1.4.3.68 CLEAN: LatUnit, TimeStepIn and TimeStepInOut arguments now checked using the match.arg function in PE_Oudin #37
parent 13521c41
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.4.3.67
Version: 1.4.3.68
Date: 2020-03-29
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -4,13 +4,17 @@
### 1.4.3.67 Release Notes (2020-03-29)
### 1.4.3.68 Release Notes (2020-03-29)
#### CRAN-compatibility updates
- The 'hydroPSO' package is back on CRAN and it is again suggested (cf. the 'param_optim' vignette).
#### Minor user-visible changes
- Character argument verification now use partial matching in <code>PE_Oudin()</code> and <code>SeriesAggreg()</code> functions.
____________________________________________________________________________________
......
......@@ -20,9 +20,7 @@ PE_Oudin <- function(JD, Temp,
if (length(JD) != length(Temp)) {
stop("'Temp' and 'LatUnit' must have the same length")
}
if (!any(LatUnit %in% c("rad", "deg"))) {
stop("'LatUnit' must be one of \"rad\" or \"deg\"")
}
LatUnit <- match.arg(LatUnit, choices = c("rad", "deg"))
if (!inherits(Lat, "numeric") | length(Lat) != 1) {
stop("'Lat' must be a 'numeric' of length one")
}
......@@ -41,18 +39,9 @@ PE_Oudin <- function(JD, Temp,
if (any(JD < 0) | any(JD > 366)) {
stop("'JD' must only contain integers from 1 to 366")
}
if (!inherits(TimeStepIn, "character") | length(TimeStepIn) != 1) {
stop("'TimeStepIn' must be a 'character' of length one")
}
if (!inherits(TimeStepOut, "character") | length(TimeStepOut) != 1) {
stop("'TimeStepIn' must be a 'character' of length one")
}
if (!(TimeStepIn %in% c("daily", "hourly"))) {
stop("'TimeStepIn' must be one of \"daily\" or \"hourly\"")
}
if (!(TimeStepOut %in% c("daily", "hourly"))) {
stop("'TimeStepOut' must be one of \"daily\" or \"hourly\"")
}
TimeStep <- c("daily", "hourly")
TimeStepIn <- match.arg(TimeStepIn , choices = TimeStep)
TimeStepOut <- match.arg(TimeStepOut, choices = TimeStep)
rleJD <- rle(JD)
if (TimeStepIn == "daily" & any(rleJD$lengths != 1)) {
stop("each day must have only one identical value of julian days")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment