hypertidy / ncmeta

Tidy NetCDF metadata

Home Page:https://hypertidy.github.io/ncmeta/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nc_grids is not normal form

mdsumner opened this issue · comments

From @mdsumner on February 13, 2019 7:29

nc_grids should have distinct grids, and nc_vars should list the grid it's in

library(dplyr)
f <- system.file("extdata/argo", package = "tidync") %>% list.files(full.names = TRUE)
tidync::tidync(f)
nc_vars(f) %>% distinct(name)
nc_grids(f) %>% distinct(grid)

Both should have ndims, nc_grids also nvars

  • check this package
  • check stars
  • check tidync

Following on from ropensci/tidync#77 pain, this will help the default variable or grid selection:

  • no NC_CHAR by default
  • pick the most dims
  • always in native order otherwise

Copied from original issue: ropensci/tidync#78

This is actually hard because this is used in quite a lot of places.

Can shortcut now with a function like this scheme, and pick off the variables from top to bottom.

nc_axes(f) %>% dplyr::inner_join(nc_dims(f), c("dimension" = "id")) %>% dplyr::inner_join(nc_vars(f), c("variable" = "name")) %>% arrange(type == "NC_CHAR", -ndims)

Now trying nesting column "variables" within nc_grids, so the output is normal but we can simply unnest to list every grid with every variable. It also works along with the change in priority-choice of the default variable/grid.

Looking good. b433604