hypertidy / quadmesh

raster grid as indexed quad mesh
https://hypertidy.github.io/quadmesh/
25 stars 2 forks source link

mesh for lon_vertices/lat_vertices #33

Open mdsumner opened 4 years ago

mdsumner commented 4 years ago
Data Source (1): tos_Omon_IPSL-CM5A-MR_rcp85_r1i1p1_200601-210012.nc ...

Grids (7) <dimension family> : <associated variables> 

[1]   D2,D1,D0 : tos
[2]   D4,D2,D1 : lat_vertices, lon_vertices    **ACTIVE GRID** ( 108472  values per variable)
[3]   D2,D1    : lat, lon
[4]   D3,D0    : time_bnds
[5]   D0       : time
[6]   D1       : j
[7]   D2       : i

Dimensions 5 (3 active): 

  dim   name   length   min   max start count  dmin  dmax unlim coord_dim 
  <chr> <chr>   <dbl> <dbl> <dbl> <int> <int> <dbl> <dbl> <lgl> <lgl>     
1 D1    j         149     1   149     1   149     1   149 FALSE TRUE      
2 D2    i         182     1   182     1   182     1   182 FALSE TRUE      
3 D4    verti…      4     1     4     1     4     1     4 FALSE FALSE     

Inactive dimensions:

  dim   name  length   min    max unlim coord_dim 
  <chr> <chr>  <dbl> <dbl>  <dbl> <lgl> <lgl>     
1 D0    time    1140  15.5 34660. TRUE  TRUE      
2 D3    bnds       2   1       2  FALSE FALSE 
mdsumner commented 4 years ago

still doesn't work very well for mesh_plot


f <- "tos_Omon_IPSL-CM5A-MR_rcp85_r1i1p1_200601-210012.nc"
x <- tidync(f)
lon <- hyper_array(x)[[2]]
lat <- hyper_array(x)[[1]]
time_idx <- 1
qm <- rgl::qmesh3d(vertices = rbind(x = as.vector(lon), 
                              y = as.vector(lat), 
                              z = rep(c(hyper_array(x %>% activate("D2,D1,D0"))[["tos"]][,,time_idx]), each = 4L), h = 1), 
             indices = matrix(seq_along(lon), nrow = 4L))

regrid to normal is best I think