Skip to content

Commit

Permalink
Update/add on-screen messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedia committed Jul 21, 2017
1 parent b66ec53 commit b9cb265
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions R/petGrid.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ petGrid <- function(tasmin = NULL,
method = c("thornthwaite", "hargreaves"),
...) {
method <- match.arg(method, choices = c("thornthwaite", "hargreaves"))
message("[", Sys.time(), "] Computing PET-", method, " ...")
out <- switch(method,
"thornthwaite" = petGrid.th(tas, ...),
"hargreaves" = petGrid.har(tasmin, tasmax, pr, ...))
message("[", Sys.time(), "] Done")
## Recover the grid structure -----------------------
coords <- getCoordinates(out$ref.grid)
pet.grid <- out$ref.grid
Expand Down
6 changes: 3 additions & 3 deletions R/speiGrid.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ speiGrid <- function(pr.grid, et0.grid = NULL, scale = 3, ...) {
coords <- getCoordinates(pr.grid)
dimNames <- getDim(pr.grid)
n.mem <- getShape(pr.grid, "member")
method <- ifelse(is.null(et0.grid), "SPI", "SPEI")
method <- paste(ifelse(is.null(et0.grid), "SPI", "SPEI"), scale, sep = "-")
message("[", Sys.time(), "] Computing ", method, " ...")
spei.list <- lapply(1:n.mem, function(x) {
pr <- subsetGrid(pr.grid, members = x, drop = TRUE) %>% extract2("Data") %>% array3Dto2Dmat()
Expand All @@ -68,8 +68,8 @@ speiGrid <- function(pr.grid, et0.grid = NULL, scale = 3, ...) {
pr.grid$Data <- do.call("abind", c(spei.list, along = -1L)) %>% unname()
attr(pr.grid$Data, "dimensions") <- dimNames
pr.grid <- redim(pr.grid, drop = TRUE)
pr.grid$Variable$varName <- paste(method, scale, sep = "_")
longname <- ifelse(method == "SPI", "Standardized Precipitation Index", "Standardized Precipitation-Evapotranspiration Index")
pr.grid$Variable$varName <- method
longname <- ifelse(grepl("SPI", method), "Standardized Precipitation Index", "Standardized Precipitation-Evapotranspiration Index")
attr(pr.grid$Variable, "longname") <- paste(longname, scale)
attr(pr.grid$Variable, "units") <- "n/d"
attr(pr.grid$Variable, "daily_agg_cellfun") <- "sum"
Expand Down

0 comments on commit b9cb265

Please sign in to comment.