Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. bash-$ ncdump -h .nc
  2. bash-$ R
  3. R> library(ncdf4)
  4. R> print(nc_open("test.nc")
  5.  
  6. my.nc <- nc_open("test.nc")
  7.  
  8. ncvar_get(my.nc, "lwdown", start = c(5, 1, 1), count = c(10, 1, 1))
  9.  
  10. my.nc$var$lwdown$dim[[1]]$name
  11. [1] "time"
  12. my.nc$var$lwdown$dim[[2]]$name
  13. [1] "lon"
  14. my.nc$var$lwdown$dim[[3]]$name
  15. [1] "lat"
  16.  
  17. start <- c(lat = 1, lon = 1, time = 5)
  18. count <- c(lat = 1, lon = 1, time = 10)
  19. dim.order <- sapply(my.nc$var$lwdown$dim, function(x) x$name)
  20.  
  21. ncvar_get(my.nc, "lwdown", start = start[dim.order], count = count[dim.order])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement