Commit 6995f167 authored by Dorchies David's avatar Dorchies David
Browse files

v1.6.8.26 fix: NA produced when aggregating from montly time step

Refs #41, #73
Showing with 13 additions and 7 deletions
+13 -7
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.8.25 Version: 1.6.8.26
Date: 2020-12-02 Date: 2020-12-02
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")),
......
...@@ -102,10 +102,16 @@ SeriesAggreg.data.frame <- function(x, ...@@ -102,10 +102,16 @@ SeriesAggreg.data.frame <- function(x,
stop <- stop <-
sprintf("%i-12-31 00:00:00", as.numeric(format(TabSeries2$DatesR[nrow(TabSeries2)], format = "%Y")) + sprintf("%i-12-31 00:00:00", as.numeric(format(TabSeries2$DatesR[nrow(TabSeries2)], format = "%Y")) +
1) 1)
by <- Ts <- format(diff(x$DatesR[1:2]))
ifelse(grepl("hours", format(diff( if(gsub("[0-9]+ ", "", Ts) == "hours") {
x$DatesR[1:2] by <- "hours"
))), yes = "hours", no = "days") } else {
if(gsub(" days$", "", Ts) == "1") {
by <- "days"
} else {
by <- "months"
}
}
fakeTs <- fakeTs <-
data.frame(DatesR = seq( data.frame(DatesR = seq(
from = as.POSIXct(start, tz = "UTC"), from = as.POSIXct(start, tz = "UTC"),
......
...@@ -194,6 +194,6 @@ test_that("SeriesAggreg from and to the same time step should return initial tim ...@@ -194,6 +194,6 @@ test_that("SeriesAggreg from and to the same time step should return initial tim
PotEvap = BasinObs$E PotEvap = BasinObs$E
) )
I2 <- SeriesAggreg(InputsModel, "%Y%m") I2 <- SeriesAggreg(InputsModel, "%Y%m")
I3 <- SeriesAggreg(I2, "%Y%m") expect_warning(SeriesAggreg(I2, "%Y%m"), regexp = "No time-step conversion was performed")
expect_equal(I2, I3) expect_equal(I2, suppressWarnings(SeriesAggreg(I2, "%Y%m")))
}) })
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