hypertidy / ncmeta

Tidy NetCDF metadata
https://hypertidy.github.io/ncmeta/
11 stars 5 forks source link

nc_grids is not normal form #26

Closed mdsumner closed 5 years ago

mdsumner commented 5 years ago

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

Following on from https://github.com/hypertidy/tidync/issues/77 pain, this will help the default variable or grid selection:

Copied from original issue: hypertidy/tidync#78

mdsumner commented 5 years ago

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)
mdsumner commented 5 years ago

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.

mdsumner commented 5 years ago

Looking good. b433604