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

v1.2.8.11 CLEAN: input checks added to PEdaily_Oudin

parent 90f76f91
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")),
......
......@@ -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)
____________________________________________________________________________________
......
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)
......
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