Commit 60c20876 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.3.2.6 CLEAN: PE_Oudin code slightly improved

Showing with 8 additions and 11 deletions
+8 -11
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.3.2.5 Version: 1.3.2.6
Date: 2019-05-22 Date: 2019-05-22
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")),
......
...@@ -14,7 +14,7 @@ output: ...@@ -14,7 +14,7 @@ output:
### 1.3.2.5 Release Notes (2019-05-22) ### 1.3.2.6 Release Notes (2019-05-22)
#### New features #### New features
......
...@@ -53,22 +53,19 @@ PE_Oudin <- function(JD, Temp, ...@@ -53,22 +53,19 @@ PE_Oudin <- function(JD, Temp,
if (!(TimeStepOut %in% c("daily", "hourly"))) { if (!(TimeStepOut %in% c("daily", "hourly"))) {
stop("'TimeStepOut' must be one of \"daily\" or \"hourly\"") stop("'TimeStepOut' must be one of \"daily\" or \"hourly\"")
} }
if (TimeStepIn == "daily") { rleJD <- rle(JD)
rleJD <- rle(JD) if (TimeStepIn == "daily" & any(rleJD$lengths != 1)) {
if (any(rleJD$lengths != 1)) { stop("each day must have only one identical value of julian days")
stop("each day must have only one identical value of julian days") }
} if (TimeStepIn == "hourly" & any(rleJD$lengths != 24)) {
stop("each day must have 24 identical values of julian days (one for each hour)")
} }
## ---------- hourly inputs aggregation ## ---------- hourly inputs aggregation
if (TimeStepIn == "hourly") { if (TimeStepIn == "hourly") {
rleJD <- rle(JD)
JD <- rleJD$values JD <- rleJD$values
if (any(rleJD$lengths != 24)) {
stop("each day must have 24 identical values of julian days (one for each hour)")
}
idJD <- rep(seq_along(JD), each = rleJD$lengths[1L]) idJD <- rep(seq_along(JD), each = rleJD$lengths[1L])
Temp <- as.vector(tapply(X = Temp, INDEX = idJD, FUN = mean)) Temp <- as.vector(tapply(X = Temp, INDEX = idJD, FUN = mean))
} }
......
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