Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • startR startR
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 29
    • Issues 29
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • 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
  • Earth SciencesEarth Sciences
  • startRstartR
  • Issues
  • #102
Closed
Open
Issue created May 14, 2021 by Nuria Pérez-Zanón@nperezMaintainer

Error when using depends and array of values in DCPP case

Hi @aho

As we have already commented, the code below fails with the message: If providing selectors for the depending dimension 'chunk', a vector of selectors must be provided for each selector of the dimension it depends on, 'sdate'. while it works with indices() (see tests in !135 (merged)).

library(startR)
DatesSequence <- function(sdate, inimonth, finalmonth, lag, nyears) {
  if (!is.numeric(sdate)) {
     sdate <- as.numeric(sdate)
  }
  sequence <- unlist(lapply(sdate, function(x) {
                a <- paste0((sdate + lag): (sdate + nyears),
                           sprintf('%02d', inimonth))
                b <- paste0((sdate + lag): (sdate + nyears),
                          sprintf('%02d', finalmonth))
                return(paste0(a, '-', b))}))
  sequence <- array(sequence,
                    c(sdate = length(sdate),
                      chunk = length(sequence)/length(sdate)))
  return(sequence)
}

path <- '/esarchive/exp/CMIP6/dcppA-hindcast/hadgem3-gc31-mm/cmip6-dcppA-hindcast_i1p1/DCPP/MOHC/HadGEM3-GC31-MM/dcppA-hindcast/r1i1p1f2/Omon/tos/gn/v20200417/$var$_Omon_HadGEM3-GC31-MM_dcppA-hindcast_s$sdate$-r1i1p1f2_gn_$chunk$.nc'

sdates <- c('2017', '2018')
chunks <- DatesSequence(sdates,
              inimonth = 1, finalmonth = 12, lag = 1, nyears = 3)

dat <- Start(dat = path,
             var = 'tos',
             sdate = sdates,
             chunk = values(chunks),
             chunk_depends = 'sdate',
             time = 'all',
             i = indices(1),
             j = 'all',
             time_across = 'chunk',
             merge_across_dims = TRUE,
             retrieve = TRUE,
             return_vars = list(time = 'sdate'))

It is not urgent since we know that we can use indices() to avoid the problem.

Cheers,

Núria

Assignee
Assign to
Time tracking