Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • s2dv s2dv
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 17
    • Issues 17
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • 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
  • s2dvs2dv
  • Issues
  • #83
Closed
Open
Issue created Nov 15, 2022 by aho@ahoMaintainer

CDORemap() doesn't reorder the unlimited dimension to the last position

Reported by @jramon, CDORemap() doesn't work well for certain cases. The error message is like:

Error in R_nc4_def_var_double: NetCDF: NC_UNLIMITED in the wrong index
Name of variable that the error occurred on: "var"
[1] "----------------------"
[1] "Var:  var"
[1] "Ndims:  4"
[1] "Dimids: "
[1] 3 2 1 0
Error in ncvar_add(nc, vars[[ivar]], verbose = verbose, indefine = TRUE) : 
  Error in ncvar_add, defining var var

The error shows if the input array reaches all the following conditions:
(1) dimension number is more than 4 (2) more than 3 dimensions are not of length 1 (3) the last dimension is not lat or lon.

For example:

data5 <- array(rnorm(1000), dim = c(window = 9, var = 2, lat = 10, lon = 12, ens = 1))
res <- CDORemap(data_array = data5,
                lats = 1:10, lons = 1:12,
                grid = 'r100x50', method = 'con', crop = T)

The error comes from NcToArray(), which expects to have the unlimited dimension as the last dimension. CDORemap() doesn't reorder the dimensions well for the problematic case above. At line 780, check dim(subset) and we can see that the "time" dimension is not at the last position.

@jramon the workaround now is to make "longitude" the last dimension. I'll report here when the bug is solved.

Best,
An-Chi

Edited Nov 16, 2022 by aho
Assignee
Assign to
Time tracking