爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 9035|回复: 5

[其他] 请教大家ncl如何写netcdf数据

[复制链接]

新浪微博达人勋

发表于 2014-8-29 17:48:54 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 天边的那边 于 2014-9-9 17:40 编辑

我想把数据写成nc格式的,不知道怎么写,向大家请教。这个是参照ncl手册写,出错了,不知道问题在哪begin
f=addfile("wrfinput_d01","r")
xlon =f->XLONG(0,:,:)
xlat = f->XLAT(0,:,:)

ff=asciiread("SEVP_CLI_CHN_PRE_DAY_GRID_0.25-20140826.asc",-1,"float")
x2=onedtond(ff(6:),(/144,256/))
x2@_FillValue = -999.00
nx=256
ny=144
rlat=new(ny,"float")
rlon=new(nx,"float")

rlon(0)=72.125
rlat(0)=18.125

do i=0,nx-1
rlon(i)=72.125+i*0.25
end do

do j=0,ny-1
rlat(j)=18.125+j*0.25
end do

x2!0="rlat"
x2!1="rlon"
x2&rlat=rlat(:)
x2&rlon=rlon(:)

wrf_tem=rgrid2rcm(x2&rlat,x2&rlon,x2,lat,lon,0)

rain=addfile("raintest.nc","c")
fileAtt = True
fileAtt@title = "raintogrid"
fileAtt@Conventions = "None"
fileAtt@creation_date = systemfunc("date")
fileattdef(rain,fileAtt)

dimNames = (/"time","lat","lon"/)
dimSizes = (/-1,ny,nx/)
dimUnlim = (/True,False,False/)

filedimdef(rain,dimNames,dimSizes,dimUnlim)
filevardef(rain,"time",typeof(time),getvardims(time))
filevardef(rain,"lat",typeof(lat),"lat")
filevardef(rain,"lon","float","lon")
filevardef(rain,"TMP",typeof(T),getvardims(T))

filevarattdef(rain,"time",time)
filevarattdef(rain,"lat",xlat)
filevarattdef(rain,"lon",xlon)
filevarattdef(rain,"TMP",T)
setfileoption(rain,"SuppressDefineMode",False)

rain->time = (/time/)
rain->wrf_tem = wrf_tem
rain->xlat = xlat
rain->xlon = xlon
print(wrf_tem)
end

这是ncl脚本,load部分没有给出






密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-9-9 11:41:42 | 显示全部楼层
怎么没有人帮我看问题出在哪里呀
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-9-9 12:01:00 | 显示全部楼层
天边的那边 发表于 2014-9-9 11:41
怎么没有人帮我看问题出在哪里呀

ncl程序出错,命令行提示的错误信息对查错是非常重要的。很可惜,楼主用“出错了”三个字概括了。这样的提问,是很难得到有效帮助的。

简单看了一下代码片段,就发现了一个问题。赋值时引用的变量,之前根本就没有定义!
filevardef(rain,"lat",typeof(lat),"lat")
filevardef(rain,"lon","float","lon")
filevardef(rain,"TMP",typeof(T),getvardims(T))

rain->wrf_tem = wrf_tem
rain->xlat = xlat
rain->xlon = xlon
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-9-9 17:34:26 | 显示全部楼层
longlivehj 发表于 2014-9-9 12:01
ncl程序出错,命令行提示的错误信息对查错是非常重要的。很可惜,楼主用“出错了”三个字概括了。这样的 ...

之前是定义了的,没有把脚本写全
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-9-9 17:43:12 | 显示全部楼层
fatal:Could not create (raintest.nc)
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 45 in file test.ncl
这个是错误信息,第45行内容fileattdef(rain,fileAtt)

TMP的确是没有定义,我看手册中没有明确给出TMP代表什么
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-7-3 16:34:26 | 显示全部楼层
楼主,写nc文件的官网脚本在哪?没找到,麻烦楼主发一下网址,正好要用~
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表