- 积分
- 72
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2021-1-13
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我想把ERA5的降水资料,1979年全年,一天一个文件,写入一个nc文件当中。首先批量把变量读取出来,然后写入nc。写入nc文件的代码完全是copy《NCL数据处理与绘图基础教程》的,但是试了好多次就是fileattdef(fout, fAtt)这一句有错误,错误提示如下:fatal:Could not create (G:\ERA5\daily\1979.nc)warning:FileSetFileOption: invalid file or format
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 31 in file practice.ncl
有高人的话救救孩子吧,把百度找遍了也不知道是哪里的错误
下面是我的代码:
- begin
- list_of_files = systemfunc("ls G:/ERA5/daily/precipitation/1979/era5.precip.197901*.nc")
- file_list = addfiles(list_of_files, "r")
- outfile = "G:\ERA5\daily\1979.nc"
- time = file_list[:]->time
- lat = file_list[0]->lat
- lon = file_list[0]->lon
- tprate = file_list[:]->tprate
- ;printVarSummary(time)
- ;printVarSummary(lat)
- ;printVarSummary(lon)
- ;printVarSummary(pre)
- ntim = dimsizes(time)
- nlat = dimsizes(lat)
- nlon = dimsizes(lon)
- pre = tprate
- pre = tprate*1000*60*60*24
- pre@units = "mm"
- fout = addfile(outfile, "c")
- setfileoption(fout, "DefineMode", True)
- fAtt = True
- fAtt@title = "NCL Efficient Approach to netCDF Creation"
- fAtt@souce_file = file_list
- fAtt@Conventions = "CF"
- fAtt@creation_date = systemfunc("date")
- fAtt@history = "NCL scripts: practice.ncl"
- fAtt@comment = "Convert variable tprate from pricipitation rate to amount"
- fileattdef(fout, fAtt)
- dimNames = (/"time", "lat", "lon"/)
- dimSizes = (/"-1", "nlat", "nlon"/)
- dimUnlim = (/True, False, False/)
- filedimdef(fout,dimNames,dimSizes,dimUnlim)
- filevardef(fout,"time",typeof(time),getvardims(time))
- filevardef(fout,"lat",typeof(lat),getvardims(lat))
- filevardef(fout,"lon",typeof(lon),getvardims(lon))
- filevardef(fout,"pre",typeof(tprate),getvardims(tprate))
- filevarattdef(fout,"time",time)
- filevarattdef(fout,"lat",lat)
- filevarattdef(fout,"lon",lon)
- filevarattdef(fout,"pre",pre)
- setfileoption(fout,"DefineMode",False)
- fout->pre = (/pre/)
- fout->time = (/time/)
- fout->lat = (/lat/)
- fout->lon = (/lon/)
- delete(time)
- delete(lat)
- delete(lon)
- delete(tprate)
- delete(pre)
- end
复制代码
|
|