- 积分
- 5156
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-4-18
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2014-7-15 20:39:08
|
显示全部楼层
本帖最后由 zzzzzx 于 2014-7-15 20:40 编辑
找人要了个相同区域的文件,这次有了...
float xlat(y, x) ;
xlat:units = "degree_north" ;
xlat:FieldType = 104 ;
xlat:MemoryOrder = "XY " ;
xlat:description = "LATITUDE, SOUTH IS NEGATIVE" ;
float xlong(y, x) ;
xlong:units = "degree_east" ;
xlong:FieldType = 104 ;
xlong:MemoryOrder = "XY " ;
xlong:description = "LONGITUDE, WEST IS NEGATIVE" ;
然后我想创建个新的nc文件,然后把time,lat,lon,变量根据原文件直接赋值,这样让新创建的nc文件能直接被grads打开,这样可行吗?我试了下,东拼西凑的ncl脚本有问题...
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
begin
;---read in a netCDF variable
fi = addfile ("pi_results_18_27.daymean.nc", "r")
lat = fi->xlat ; read in netCDF variable
time = fi->time
lon = fi->xlong
t2 = fi->T2
fout = addfile("out.nc","c")
; create global attributes
fileAtt = True
fileAtt@title = "Sample"
fileAtt@Conventions = "None"
fileAtt@creation_date = systemfunc("date")
setfileoption(fout,“DefineMode”,True) ; optional
fileattdef(fout,fileAtt)
; predefine coordinate variables
dimNames = (/"time","lat","lon"/)
dimSizes = (/-1,nlat,nlon/) ; -1 means unspecified
dimUnlim = (/True,False,False/)
; predefine names, type, dimensions
; explicit dimension naming or getvardims can be used
filedimdef(fout,dimNames,dimSizes,dimUnlim)
filevardef(fout,"time",typeof(time),getvardims(time))
filevardef(fout,"lat" ,typeof(lat) ,"lat")
filevardef(fout,"lon" ,"float" ,"lon")
filevardef(fout,"TMP" ,typeof(T) , getvardims(T) )
; predefine each variable’s attributes
filevarattdef(fout,"time",time)
filevarattdef(fout,"lat" ,lat)
filevarattdef(fout,"lon" ,lon)
filevarattdef(fout,"t2" ,t2)
setfileoption(fout,”SuppressDefineMode”,False) ; optional
; output values only
fout->time = (/time/)
fout->lat = (/lat/)
fout->lon = (/lon/)
fout->t2 = (/t2/) ;t2
end
初学ncl,问题估计很多...能否请你帮忙看一下呢?错误提示是
fatal:syntax error: line 18 in file gaigeshi.ncl before or near setfileoption(fout,
|
|