ropensci / tidync

NetCDF exploration and data extraction
https://docs.ropensci.org/tidync
91 stars 12 forks source link

approach to scalars? #86

Open mdsumner opened 5 years ago

mdsumner commented 5 years ago

From the ncmeta/tidync perspective they could be identified as living on the S grid.

tidync should allow r activate("S") %>% hyper_tibble() and give a single row data frame.

Not sure for stars, as a multivariate single-element array?

stars is ok with an array:

stars::st_as_stars(array(1, 1))

but not with a single-element vector:

stars::st_as_stars(1)

Examples are relatively rare, but there's a Unidata example here:

## identify SCALARS
scl_vars <- c("nStaticIds", "globalInventory", "firstOverflow", "filterSetNum")
u <- "https://www.unidata.ucar.edu/software/netcdf/examples/madis-hydro.nc"
tfile <- file.path(tempdir(), basename(u))
## 1.1 Mb
if (!file.exists(tfile)) download.file(u, tfile, mode = "wb")

con <- RNetCDF::open.nc(tfile)

lapply(scl_vars, function(var) RNetCDF::var.get.nc(con, var))
#> [[1]]
#> [1] 196
#> 
#> [[2]]
#> [1] 1118481
#> 
#> [[3]]
#> [1] NA
#> 
#> [[4]]
#> [1] 2

#unlink(tfile)

Created on 2019-03-20 by the reprex package (v0.2.1)

mdsumner commented 1 day ago

we should support scalars, variables that don't have dimensions


## wget https://github.com/user-attachments/files/17415359/NSIDC0051_SEAICE_PS_S25km_19781027_v2.0.nc.zip

tidync::tidync("NSIDC0051_SEAICE_PS_S25km_19781027_v2.0.nc")