diff --git a/DESCRIPTION b/DESCRIPTION index b0f49d47df5ccfe346fefabbe591103cfd1c9296..56720f75c0e39ba90129e968f8a98a21838780e4 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.9.8 -Date: 2019-03-13 +Version: 1.2.9.9 +Date: 2019-03-18 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 32e638f5e2402a5716de8f596e9ff6b113a71fae..67b74e68a917eca666b5b47f06d03445808ad667 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -13,7 +13,7 @@ output: -### 1.2.9.8 Release Notes (2019-03-13) +### 1.2.9.9 Release Notes (2019-03-18) @@ -60,6 +60,8 @@ output: - It is now possible to be redirected on the documantation about <code>plot.OutputsModel()</code> with <code>?plot</code>. +- <code>plot.OutputsModel()</code> does not return a warning message anymore when <code>Qobs = NULL</code>. + - It is now possible to use a character vector the function name (in addition to function objects) in all <code>FUN_*</code> arguments of the following functions: <code>Calibration()</code>, <code>Calibration_Michel()</code>, <code>CreateCalibOptions()</code>, <code>CreateIniStates()</code>, <code>CreateIniStates()</code>, <code>CreateInputsCrit()</code>, <code>CreateInputsModel()</code>, <code>CreateRunOptions()</code>, <code>ErrorCrit()</code>, <code>RunModel()</code> and <code>TransfoParam()</code>. diff --git a/R/PEdaily_Oudin.R b/R/PEdaily_Oudin.R index 38f6d2587df646342072b50a1d3ac929d7416f25..dd42174ad801c80938fdfde88269a465b3f73dc0 100644 --- a/R/PEdaily_Oudin.R +++ b/R/PEdaily_Oudin.R @@ -9,10 +9,10 @@ PEdaily_Oudin <- function(JD, Temp, LatRad, Lat, LatUnit = c("rad", "deg")) { Lat <- LatRad } } - if (!inherits(JD, "numeric")) { + if (!(inherits(JD, "numeric") | inherits(JD, "integer"))) { stop("'JD' must be of class 'numeric'") } - if (!inherits(Temp, "numeric")) { + if (!(inherits(Temp, "numeric") | inherits(Temp, "integer"))) { stop("'Temp' must be of class 'numeric'") } if (length(JD) != length(Temp)) { @@ -24,12 +24,21 @@ PEdaily_Oudin <- function(JD, Temp, LatRad, Lat, LatUnit = c("rad", "deg")) { if (!inherits(Lat, "numeric") | length(Lat) != 1) { stop("'Lat' must be a 'numeric' of length one") } + if (LatUnit[1L] == "rad" & ((Lat >= pi/2) | (Lat <= -pi/2))) { + stop("'Lat' must be comprised between -pi/2 and +pi/2 degrees") + } + if (LatUnit[1L] == "deg" & ((Lat >= 90) | (Lat <= -90))) { + stop("'Lat' must be comprised between -90 and +90 degrees") + } if (LatUnit[1L] == "rad") { FI <- Lat } if (LatUnit[1L] == "deg") { FI <- Lat / (180 / pi) } + if (any(JD < 0) | any(JD > 366)) { + stop("'JD' must only contain integers from 1 to 366") + } ## ---------- Oudin's formula @@ -71,14 +80,29 @@ PEdaily_Oudin <- function(JD, Temp, LatRad, Lat, LatUnit = c("rad", "deg")) { ETA <- 1 + cos(JD[k] / 58.1) / 30 GE <- 446 * OM * COSPZ * ETA + if (is.na(Temp[k])) { + PE_Oudin_D[k] <- NA + } else { if (Temp[k] >= -5.0) { PE_Oudin_D[k] <- GE * (Temp[k] + 5) / 100 / 28.5 } else { PE_Oudin_D[k] <- 0 } + } } + if (any(is.na(Temp))) { + if (any(is.na(PE_Oudin_D))) { + warning("'Temp' time series, and therefore the returned 'PE' time series, contain missing value(s)") + } else { + warning("'Temp' time series contains missing value(s)") + } + } + if (!any(is.na(Temp)) & any(is.na(PE_Oudin_D))) { + warning("returned 'PE' time series contains missing value(s)") + } + return(PE_Oudin_D) }