0
我有以下腳本將分析輸出寫入單個NCDF4文件。該腳本正在寫入第一個文件並停止。 我得到的錯誤是: -無法循環創建分析中的多個NCDF4文件
錯誤R_nc4_create:權限被拒絕(創建模式爲4096) 錯誤nc_create(ncfname,列表(tmp_def,tmp_def2),force_v4 = T): 錯誤nc_create!
似乎是有點問題: -
ncfname<- sprintf('%sA.nc', Listbreak3)
,我無法弄清楚。
我的腳本是一個更大的分析的一部分。但是這部分利益在下面。
這可能是循環的,但我認爲,循環是好的
希望有人已經寫在環多NCDF4文件
寫NCDF4文件 #tunits<-"days since 1800-01-01 00:00:00"
#Define dimensions
##################################################################
londim<-ncdim_def("Lon","degrees_east",as.double(Lon))
latdim<-ncdim_def("Lat", "degrees_north",as.double(Lat))
timedim<-ncdim_def("timeset",tunits,as.double(timeset))
#Define variables
##################################################################
fillvalue<-NA
dlname<-"2 meter air temperature"
dlname2<-" 2 meter max air temperature"
tmp_def<-ncvar_def("Y2ts_Stripped","deg_C",
list(londim,latdim,timedim),fillvalue,dlname,prec = "double")
tmp_def2<-ncvar_def("X2ts_Stripped","deg_C",
list(londim,latdim,timedim),fillvalue,dlname2,prec = "double")
ncatt_put(ncout,"Lon","axis","X")
ncatt_put(ncout, "Lat", "axis", "Y")
ncatt_put(ncout, "timeset","axis", "T")
#################################################
title<-c(1:2)
names(title)<-c("jack","jill")
title<-as.data.frame(title)
###############################################
Listbreak<-filelist
#Create Ncdf4 file and put arrays
##################################################################
for (i in 1:length(Listbreak)){
Listbreak2<-do.call(rbind, strsplit(Listbreak, "[[:punct:]]|\\s"))
[,c(1, 2,3)]###Breaking up the file name
Listbreak3<-Listbreak2[,2]
ncfname<- sprintf('%sA.nc', Listbreak3)
ncout<-nc_create(ncfname,list(tmp_def,tmp_def2),force_v4=T)
ncvar_put(ncout,tmp_def,Y2ts_Stripped,start=NA,count = NA)
ncvar_put(ncout,tmp_def2,X2ts_stripped, start= NA,count = NA)
}
# attributes # the 0 designates the attribute as global
###########################################################
ncatt_put(ncout,0,"Make_NCDF4_File",1, prec="int")
ncatt_put(ncout,0,"Maynooth_University",1,prec="short")
ncatt_put(ncout,0,"AR000087828",1, prec="short")
ncatt_put(ncout,0,"description","this is the script to write NCDF4
files")
#Close file and write date to disk
##########################################################
nc_close(ncout)