Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • ClimProjDiags ClimProjDiags
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Earth SciencesEarth Sciences
  • ClimProjDiagsClimProjDiags
  • Issues
  • #16
Closed
Open
Issue created Mar 08, 2023 by Eva Rifà@erifarovMaintainer

Include a warning in Subset

Hi @aho,

There is an inconsistency with the Subset function. It happens when the data array has an attribute called 'dimensions' and they are ordered differently than actual dimensions of the array. This is due to line 51 where this attribute is evaluated before checking the names(dim(data)). Then, for this case, the output data subset mixes the dimensions incorrectly.

It is not a big deal, but I think this line could be removed and replaced directly with dim_names <- names(dim(data)). I found the error when using Load where there is this attribute called 'dimensions' which is created additionally. Do you think it is something that could be changed?

Here there is an example of the code where you can see the error:

library(ClimProjDiags)
library(s2dv)

data <- array(1:217560, dim = c(dataset = 1, sdate = 12, lon = 37, lat = 35, member = 2, ftime = 7))
attr(data, 'dimensions') <- names(dim(data))
dimnames <- names(dim(data))
data <- Reorder(data, sort(dimnames))
datas_subset <- Subset(data, along = 'dataset', 1, drop = 'selected')

dim(datas_subset)
#  sdate    lon    lat member  ftime 
#      7     35     37      2     12 

# wrong dimensions

Thank you,
Eva

Edited Mar 08, 2023 by Eva Rifà
Assignee
Assign to
Time tracking