Skip to content

Commit

Permalink
Handle non-standard dimension names
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedia committed Jun 4, 2024
1 parent e590306 commit f4bb6be
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/makeSubset.seasonal.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' In the current version the Z dimension is ignored (and dropped),
#' as it is not planned to include multi-level variables.
#' @keywords internal
#' @note The Ensemble Axis is assumed to be named \dQuote{member}.
#'
#' @references \url{http://www.unidata.ucar.edu/software/thredds/v4.3/netcdf-java/v4.3/javadocAll/ucar/nc2/dt/grid/GeoGrid.html}
#' @author J Bedia, A.Cofino
Expand Down Expand Up @@ -106,15 +107,18 @@ makeSubset.seasonal <- function(grid, latLon, runTimePars, memberRangeList, fore
}
aux.list1 <- NULL
}
mdArray <- do.call("abind", c(aux.list, along = grep(gcs$getEnsembleAxis()$getDimensionsString(), dimNamesRef, fixed = TRUE)))
mdArray <- do.call("abind", c(aux.list, along = grep(gcs$getEnsembleAxis()$getName(), dimNamesRef, fixed = TRUE)))
aux.list <- NULL
if (any(dim(mdArray) == 1)) {
dimNames <- dimNamesRef[-which(dim(mdArray) == 1)]
mdArray <- drop(mdArray)
} else {
dimNames <- dimNamesRef
}
dimNames <- gsub("^time.*", "time", dimNames)
dimNames <- gsub("^time.*", "time", dimNames, ignore.case = TRUE)
## Fix lon-lat dimension names
dimNames <- gsub("^lon.*", "lon", dimNames, ignore.case = TRUE)
dimNames <- gsub("^lat.*", "lat", dimNames, ignore.case = TRUE)
mdArray <- unname(mdArray)
attr(mdArray, "dimensions") <- dimNames
# Date adjustment
Expand Down

0 comments on commit f4bb6be

Please sign in to comment.