Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. rm(list=ls())
  2. library(ncdf4)
  3. #day="20150501"
  4. hour=c("00","01","02","03","04","05","06","07","08","09","10",11:23)
  5. class(hour)
  6. #----------------Solution 1----------------
  7. nc<-list()
  8. for(i in c(0:23)){
  9. precip.file<-paste("C:\\Users\\TOM\\Desktop\\R(資料庫)\\20150501\\gsmap_mvk.20150501.",
  10. paste(hour[i],paste("00.v6.4133.0",".nc")),sep="")
  11. #precip<-"C:\\Users\\TOM\\Desktop\\R(資料庫)\\20150501\\gsmap_mvk.20150501."00"00.v6.4133.0.nc"
  12. # i<-i+1
  13. nc[i]<-nc_open(precip.file) #List Contain all nc file
  14. }
  15. precip.file
  16. View(matrix(precip.file))
  17.  
  18. #----------------Solution 2----------------
  19. read_nc_file<-function(hr){
  20. filepath<-paste("C:\\Users\\TOM\\Desktop\\R(資料庫)\\20150501\\gsmap_mvk.20150501.",
  21. paste(hr,paste("00.v6.4133.0",".nc")),sep="")
  22. return(nc_open(filepath))
  23. }
  24. nc<-lapply(hour,read_nc_file) #List Contain all nc file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement