diff --git a/DESCRIPTION b/DESCRIPTION index 569dece952a116235073d7f877b84165be9b60f9..71dce2dea155259259e43d479cf12170e7e19a7e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.2.8.10 +Version: 1.2.8.11 Date: 2019-03-12 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), diff --git a/NEWS.rmd b/NEWS.rmd index 1a6f3cc6423de123bd7d69f9dda01c3b1449e63d..72926193a6078da72ab6fd9aef7212770ba0cc6b 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -13,7 +13,7 @@ output: -### 1.2.8.10 Release Notes (2019-03-12) +### 1.2.8.11 Release Notes (2019-03-12) @@ -73,6 +73,8 @@ output: - <code>Calibration()</code> function now returns an error message if <code>FUN_CALIB</code> is not a function +- Inputs of <code>PEdaily_Oudin()</code> are now checked + - <code>PEdaily_Oudin()</code> example corrected (the Julian day was one day too early) ____________________________________________________________________________________ diff --git a/R/PEdaily_Oudin.R b/R/PEdaily_Oudin.R index 4105fe9ab9067cdfecad31caf337cdb45f5792ed..38f6d2587df646342072b50a1d3ac929d7416f25 100644 --- a/R/PEdaily_Oudin.R +++ b/R/PEdaily_Oudin.R @@ -1,18 +1,29 @@ PEdaily_Oudin <- function(JD, Temp, LatRad, Lat, LatUnit = c("rad", "deg")) { + + ## ---------- check arguments + if (!missing(LatRad)) { warning("Deprecated \"LatRad\" argument. Please, use \"Lat\" instead.") if (missing(Lat)) { Lat <- LatRad } } - - if (!any(LatUnit %in%c("rad", "deg"))) { - stop("\"LatUnit\" must be \"rad\" or \"deg\".") + if (!inherits(JD, "numeric")) { + stop("'JD' must be of class 'numeric'") + } + if (!inherits(Temp, "numeric")) { + stop("'Temp' must be of class 'numeric'") + } + 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 \"rad\" or \"deg\"") + } + if (!inherits(Lat, "numeric") | length(Lat) != 1) { + stop("'Lat' must be a 'numeric' of length one") } - - PE_Oudin_D <- rep(NA, length(Temp)) - if (LatUnit[1L] == "rad") { FI <- Lat } @@ -20,6 +31,10 @@ PEdaily_Oudin <- function(JD, Temp, LatRad, Lat, LatUnit = c("rad", "deg")) { FI <- Lat / (180 / pi) } + + ## ---------- Oudin's formula + + PE_Oudin_D <- rep(NA, length(Temp)) COSFI <- cos(FI) AFI <- abs(FI / 42)