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

v1.6.3.18 style: minor typo revision, code indented and comment removed in PE_Oudin

Showing with 49 additions and 57 deletions
+49 -57
Package: airGR Package: airGR
Type: Package Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.3.17 Version: 1.6.3.18
Date: 2020-10-15 Date: 2020-10-16
Authors@R: c( Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), 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@inrae.fr"), person("Olivier", "Delaigue", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7668-8468"), email = "airGR@inrae.fr"),
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
### 1.6.3.17 Release Notes (2020-10-15) ### 1.6.3.18 Release Notes (2020-10-16)
#### New features #### New features
......
...@@ -6,12 +6,6 @@ PE_Oudin <- function(JD, Temp, ...@@ -6,12 +6,6 @@ PE_Oudin <- function(JD, Temp,
## ---------- check arguments ## ---------- check arguments
# if (!missing(LatRad)) {
# warning("Deprecated 'LatRad' argument. Please, use 'Lat' instead.")
# if (missing(Lat)) {
# Lat <- LatRad
# }
# }
if (!(inherits(JD, "numeric") | inherits(JD, "integer"))) { if (!(inherits(JD, "numeric") | inherits(JD, "integer"))) {
stop("'JD' must be of class 'numeric'") stop("'JD' must be of class 'numeric'")
} }
...@@ -21,7 +15,6 @@ PE_Oudin <- function(JD, Temp, ...@@ -21,7 +15,6 @@ PE_Oudin <- function(JD, Temp,
if (length(JD) != length(Temp)) { if (length(JD) != length(Temp)) {
stop("'JD' and 'Temp' must have the same length") stop("'JD' and 'Temp' must have the same length")
} }
if (!RunFortran & (!inherits(Lat, "numeric") | length(Lat) != 1)) { if (!RunFortran & (!inherits(Lat, "numeric") | length(Lat) != 1)) {
stop("'Lat' must be a 'numeric' of length one") stop("'Lat' must be a 'numeric' of length one")
} }
...@@ -67,8 +60,7 @@ PE_Oudin <- function(JD, Temp, ...@@ -67,8 +60,7 @@ PE_Oudin <- function(JD, Temp,
## ---------- Oudin's formula ## ---------- Oudin's formula
if (RunFortran) if (RunFortran) {
{
if (LatUnit[1L] == "rad") { if (LatUnit[1L] == "rad") {
Lat = Lat * 180 / pi Lat = Lat * 180 / pi
} }
...@@ -79,7 +71,7 @@ PE_Oudin <- function(JD, Temp, ...@@ -79,7 +71,7 @@ PE_Oudin <- function(JD, Temp,
Lat = rep(Lat, LInputs) Lat = rep(Lat, LInputs)
} }
RESULTS <- .Fortran("frun_etp_oudin", PACKAGE="airGR", RESULTS <- .Fortran("frun_etp_oudin", PACKAGE = "airGR",
##inputs ##inputs
LInputs = LInputs, LInputs = LInputs,
InputsLAT = as.double(Lat), InputsLAT = as.double(Lat),
...@@ -92,57 +84,57 @@ PE_Oudin <- function(JD, Temp, ...@@ -92,57 +84,57 @@ PE_Oudin <- function(JD, Temp,
} else { } else {
PE_Oudin_D <- rep(NA, length(Temp)) PE_Oudin_D <- rep(NA, length(Temp))
COSFI <- cos(FI) COSFI <- cos(FI)
AFI <- abs(FI / 42) AFI <- abs(FI / 42)
for (k in seq_along(Temp)) {
TETA <- 0.4093 * sin(JD[k] / 58.1 - 1.405)
COSTETA <- cos(TETA)
COSGZ <- max(0.001, cos(FI - TETA))
GZ <- acos(COSGZ)
COSOM <- 1 - COSGZ / COSFI / COSTETA
if (COSOM < -1) {
COSOM <- -1
}
if (COSOM > 1) {
COSOM <- 1
}
COSOM2 <- COSOM * COSOM
if (COSOM2 >= 1) { for (k in seq_along(Temp)) {
SINOM <- 0
} else { TETA <- 0.4093 * sin(JD[k] / 58.1 - 1.405)
SINOM <- sqrt(1 - COSOM2) COSTETA <- cos(TETA)
} COSGZ <- max(0.001, cos(FI - TETA))
GZ <- acos(COSGZ)
OM <- acos(COSOM) COSOM <- 1 - COSGZ / COSFI / COSTETA
COSPZ <- COSGZ + COSFI * COSTETA * (SINOM/OM - 1)
if (COSOM < -1) {
if (COSPZ < 0.001) { COSOM <- -1
COSPZ <- 0.001 }
} if (COSOM > 1) {
COSOM <- 1
ETA <- 1 + cos(JD[k] / 58.1) / 30 }
GE <- 446 * OM * COSPZ * ETA
COSOM2 <- COSOM * COSOM
if (is.na(Temp[k])) {
PE_Oudin_D[k] <- NA if (COSOM2 >= 1) {
} else { SINOM <- 0
if (Temp[k] >= -5.0) {
PE_Oudin_D[k] <- GE * (Temp[k] + 5) / 100 / 28.5
} else { } else {
PE_Oudin_D[k] <- 0 SINOM <- sqrt(1 - COSOM2)
} }
OM <- acos(COSOM)
COSPZ <- COSGZ + COSFI * COSTETA * (SINOM/OM - 1)
if (COSPZ < 0.001) {
COSPZ <- 0.001
}
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
}
}
} }
} }
}
## ---------- disaggregate PE from daily to hourly ## ---------- disaggregate PE from daily to hourly
if (TimeStepOut == "hourly") { if (TimeStepOut == "hourly") {
......
Supports Markdown
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