Skip to content

Commit

Permalink
fix calcATA
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmseddy committed Apr 19, 2024
1 parent 4df9930 commit 17612b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ importFrom(terra,resample)
importFrom(terra,same.crs)
importFrom(terra,set.names)
importFrom(terra,setValues)
importFrom(terra,subset)
importFrom(terra,trim)
importFrom(terra,values)
importFrom(terra,vect)
Expand Down
5 changes: 3 additions & 2 deletions R/calcVars.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,17 @@ calcAsIs <- function(stacks, layers, .dots = NULL) {
}

#' @export
#' @importFrom terra app
#' @importFrom terra app subset
#' @rdname calcVars
calcATA <- function(stacks, layers, .dots = NULL) {
type <- calcStackLayersType(stacks, layers)
type_years <- grep(paste0("(", paste0(type, collapse = "|"), ")_years"), names(.dots), value = TRUE)
type_periods <- grep(paste0("(", paste0(type, collapse = "|"), ")_period"), names(.dots), value = TRUE)
stack_years <- stacks[paste0(gsub("_years", "", type_years), "_", .dots[[type_years]])]
stack_periods <- stacks[paste0(gsub("_period", "", type_periods), "_", .dots[[type_periods]])]
stack_periods <- stack_periods[grep("MAT", x = )]
checkCalcStackLayers(append(stack_years, stack_periods), layers)

stack_periods <- lapply(stack_periods, terra::subset, subset = "MAT_normal")
MAT_norm_mean <- rast(stack_periods) |> terra::app(fun = mean, na.rm = TRUE)

ATAstack <- lapply(stack_years, function(x) {
Expand Down

0 comments on commit 17612b8

Please sign in to comment.