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
parent b028fc19
Pipeline #18085 failed with stages
in 1 minute and 24 seconds
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.8.25
Version: 1.6.8.26
Date: 2020-12-02
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -102,10 +102,16 @@ SeriesAggreg.data.frame <- function(x,
stop <-
sprintf("%i-12-31 00:00:00", as.numeric(format(TabSeries2$DatesR[nrow(TabSeries2)], format = "%Y")) +
1)
by <-
ifelse(grepl("hours", format(diff(
x$DatesR[1:2]
))), yes = "hours", no = "days")
Ts <- format(diff(x$DatesR[1:2]))
if(gsub("[0-9]+ ", "", Ts) == "hours") {
by <- "hours"
} else {
if(gsub(" days$", "", Ts) == "1") {
by <- "days"
} else {
by <- "months"
}
}
fakeTs <-
data.frame(DatesR = seq(
from = as.POSIXct(start, tz = "UTC"),
......
......@@ -194,6 +194,6 @@ test_that("SeriesAggreg from and to the same time step should return initial tim
PotEvap = BasinObs$E
)
I2 <- SeriesAggreg(InputsModel, "%Y%m")
I3 <- SeriesAggreg(I2, "%Y%m")
expect_equal(I2, I3)
expect_warning(SeriesAggreg(I2, "%Y%m"), regexp = "No time-step conversion was performed")
expect_equal(I2, suppressWarnings(SeriesAggreg(I2, "%Y%m")))
})
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