stephpenn1 / SeniorThesis

Changes in Antarctic Intermediate Water physical properties; RCP 8.5; CESM1 - BGC
0 stars 0 forks source link

open entire directory #7

Open cahartin opened 8 years ago

cahartin commented 8 years ago

`

Open all files

files= list.files(pattern='*.nc',full.names=TRUE) global_temp=list()

Loop over files

for(i in seq_along(files)) { print (files[i])

nc = nc_open(files[i])

Read the whole nc file and pull out variables of interest

global_temp [[i]] <- data.frame(temp = ncvar_get(nc,'tas'), year= round((ncvar_get(nc,'time')/1e4), digits=0), file= basename(files[i])) nc_close(nc) }

#Add the values from each file to a single data.frame df<-bind_rows(globaltemp) %>% separate(file, into = c("var", "model","scenario", "ens", "yrs", "regrid"), sep = "")

write.table(df, "C:/Users/hart428/Documents/glb_temp_KC/glb_mean_esmrcp85.csv", sep =",", row.names=F) `