Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • CSTools CSTools
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 28
    • Issues 28
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • External
  • CSToolsCSTools
  • Merge requests
  • !146

Add condition in as.s2dv_cube in Variables$metadata

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Eva Rifà requested to merge develop-fix_as.s2dv_cube into master Mar 14, 2023
  • Overview 0
  • Commits 1
  • Pipelines 1
  • Changes 1

Correct as.s2dv_cube to avoid overwrite variables with different length in multiple datasets:

Within the element Variables creation loop, if variable (ex. 'lon') is already there, don't add it to esult$attrs$Variable$metadata. This could cause inconsistency if datasets are loaded with different longitudes or latitudes values.

With this change, the coordinates elements and the corresponding metadata in $attrs$Variables is equal.

    ## Variables
    for (var_type in names(attributes(object)$Variables)) {
      if (!is.null(attributes(object)$Variables[[var_type]])) {
        for (var in names(attributes(object)$Variables[[var_type]])) {
          attr_variable <- attributes(object)$Variables[[var_type]][[var]]
          if (is.null(result$attrs$Dates)) {
            if (inherits(attr_variable, "POSIXct")) {
              result$attrs$Dates <- attr_variable
            }
          }
          if (is.null(result$attrs$Variable$metadata[[var]])) {
            result$attrs$Variable$metadata[[var]] <- attr_variable
          }
        }
      }
    }
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: develop-fix_as.s2dv_cube