Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • airGRteaching airGRteaching
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 7
    • Issues 7
    • List
    • Boards
    • Service Desk
    • Milestones
  • Redmine
    • Redmine
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • HYCAR-HydroHYCAR-Hydro
  • airGRteachingairGRteaching
  • Issues
  • #64
Closed
Open
Issue created Nov 04, 2022 by Delaigue Olivier@olivier.delaigueOwner

Fix 'SimGR' tests when running on a non UTC timezone

From: Joshua Ulrich 3 November 2022 20:45
CC: Kurt Hornik

One package test fails when I run 'R CMD check' with a non-UTC timezone. I found this issue while running reverse-dependency checks for xts. I wanted to make sure it wasn't an xts bug.

There's a reproducible example below. Kurt found the issue is with the lines that compare dates with a character string, because the result is locale-dependent.

Let me know if you have questions.

# the expected result (a warning)
  Sys.setenv(TZ="UTC")
  require(airGRteaching)
  data(L0123001, package = "airGR")

  BasinObsSubNA <- BasinObs[, c("DatesR", "P", "E", "Qmm", "T")]
  BasinObsSubNA[BasinObsSubNA$DatesR >= "1994-01-01", ]$Qmm <- NA
  BasinObsTotNA <- BasinObsSubNA[BasinObsSubNA$DatesR >= "1994-01-01", ]

  PrepSubNA <- PrepGR(ObsDF = BasinObsSubNA, HydroModel = "GR4J", CemaNeige = FALSE)
  PrepTotNA <- PrepGR(ObsDF = BasinObsTotNA, HydroModel = "GR4J", CemaNeige = FALSE)

  object <- SimGR(PrepGR = PrepTotNA, Param = c(270.426, 0.984, 108.853, 2.149),
      EffCrit = "KGE2", WupPer = c("1994-01-01", "1994-12-31"),
      SimPer = c("1995-01-01", "1998-12-31")) ## Warning message:
## In SimGR(PrepGR = PrepTotNA, Param = c(270.426, 0.984, 108.853,  :
## "PrepGR" does not contain any Qobs values. The efficiency criterion is not computed
# error if the timezone isn't UTC
  Sys.setenv(TZ="America/Chicago")
  require(airGRteaching)
  data(L0123001, package = "airGR")

  BasinObsSubNA <- BasinObs[, c("DatesR", "P", "E", "Qmm", "T")]
  BasinObsSubNA[BasinObsSubNA$DatesR >= "1994-01-01", ]$Qmm <- NA
  BasinObsTotNA <- BasinObsSubNA[BasinObsSubNA$DatesR >= "1994-01-01", ]

  PrepSubNA <- PrepGR(ObsDF = BasinObsSubNA, HydroModel = "GR4J", CemaNeige = FALSE)
  PrepTotNA <- PrepGR(ObsDF = BasinObsTotNA, HydroModel = "GR4J", CemaNeige = FALSE)

  object <- SimGR(PrepGR = PrepTotNA, Param = c(270.426, 0.984, 108.853, 2.149),
      EffCrit = "KGE2", WupPer = c("1994-01-01", "1994-12-31"),
      SimPer = c("1995-01-01", "1998-12-31")) ## Error in SimGR(PrepGR = PrepTotNA, Param = c(270.426, 0.984, 108.853,  :
## Non convenient date for the warm-up period "WupPer"
Edited Nov 04, 2022 by Delaigue Olivier
Assignee
Assign to
Time tracking