爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6964|回复: 15

[脚本编辑] grads提示Data Request Error: Invalid grid coordinates

[复制链接]
回帖奖励 10 金钱 回复本帖可获得 2 金钱奖励! 每人限 1 次

新浪微博达人勋

发表于 2017-9-30 18:38:24 | 显示全部楼层 |阅读模式

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

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

x
请教一下会grads的小伙伴,用grads画图出现了一个错误:
系统提示如下:
Data Request Error: Invalid grid coordinates
  World coordinates convert to non-integer  grid coordinates
    Variable = uwndclim  Dimension = 3
  Error ocurred at column 6

原gs文件和CTL文件:(另附件可直接下载)
'reinit'
'open D:\grads2\ex4.ctl'
'open D:\grads2\clim_ex4.ctl'

'set lon  90 270'
'set lat -30  60'
'set lev 850'
'run define_colors.gs'
len=0.25
scale=5
'set dfile 2'
'set t 1 12'
'define uwndclim=uwnd'
'define vwndclim=vwnd'
'define slpclim =slp'
'modify uwndclim seasonal'
'modify vwndclim seasonal'
'modify slpclim  seasonal'
'set dfile 1'
'set t 1 24'
'define uwndanom=uwnd-uwndclim'
'define vwndanom=vwnd-vwndclim'
'define slpanom = slp/100.-slpclim'
t=11
while(t<=16)
    monstr=getmonstr(t)
    if (t>12)
        mon=t-12
        timestr=15%monstr%1998
    else
        mon=t
        timestr=15%monstr%1997
    endif
    'set time ' timestr
   
*math_int(num): the integer part of the num not greater than num
*x0=0 and x0=1 mean the sub-plots are on the left and right columns, respectively.
*
*math_mod(num1,num2): the integer part of the reminder when num1 is divided by num2
*y0=0,y0=1 and y0=2 mean the sub-plots are on the top,middle and bottom rows, respectively.
    x0=math_int((t-11)/3)
    y0=math_mod((t-11),3)
*xl: the width of white space on the left of a sub-plot
*xr: the width of white space on the right of a sub-plot
*cb: the width for color bar in the left of plot
*thus, (11-xl*2-xr*2-cb)/2 is the width of each sub-plot.   
    xl=0
    xr=0
    cb=0.8
    wd=(11-xl*2-xr*2-cb)/2
    xmin=xl+(wd+xl+xr)*x0
    xmax=xmin+wd
*yt: the height of white space above a sub-plot
*yb: the height of white space below a sub-plot
*thus, (8.5-yt*3-yb*3)/3 is the height of each sub-plot
         
    yt=0.1
    yb=0.2
    ht=(8.5-yt*3-yb*3)/3
    ymax=8.5-yt-(ht+yt+yb)*y0
    ymin=ymax-ht
    'set parea 'xmin' 'xmax' 'ymin' 'ymax
    'set gxout shaded'
    'set grads off'
    'set grid off'
    'set clevs -10 -7 -5 -3 -2 -1 1 2 3 5 7 10'
    'set ccols 99  97  95   94   93    92   0   82  83     84   85    87   89'
    'd slpanom'
    'set arrscl 'len' 'scale
    'set arrowhead -0.4'
    'set arrlab off'
    'set ccolor 1'
    'd skip(uwndanom,3);skip(vwndanom,3)'
    if (mon=3)
        'cbarn 1 1'
    endif
    'q w2xy 90 55'
    xl=subwrd(result,3)
    yl=subwrd(result,6)
    'q w2xy 108 65'
    xo=subwrd(result,3)
    yo=subwrd(result,6)
     'set line 1'
    'draw rec  'xl' 'yl' 'xo' 'yo
    'set line 0'
    'draw recf 'xl' 'yl' 'xo' 'yo
    'set string 1 c'
    'draw string 'xo/2+xl/2' 'yo/2+yl/2' 'monstr
   t=t+1
endwhile
rc = arrow(10.3,0.8,len,scale)
'gxprint D:\grads2\4-2.png white'
function arrow(x,y,len,scale)
'set line 1 1 4'
'draw line 'x-len/2.' 'y' 'x+len/2.' 'y
'draw line 'x+len/2.-0.05' 'y+0.04' 'x+len/2.' 'y
'draw line 'x+len/2.-0.05' 'y-0.04' 'x+len/2.' 'y
'set string 1 c'
'set strsiz 0.12'
'draw string 'x' 'y-0.13' 'scale
return
function getmonstr(mon)
mon=math_mod(mon,12)
if(mon=1)
    monstr='JAN'
endif
if(mon=2)
    monstr='FEB'
endif
if(mon=3)
    monstr='MAR'
endif
if(mon=4)
    monstr='APR'
endif
if(mon=5)
    monstr='MAY'
endif
if(mon=6)
    monstr='JUN'
endif
if(mon=7)
    monstr='JUL'
endif
if(mon=8)
    monstr='AUG'
endif
if(mon=9)
    monstr='SEP'
endif
if(mon=10)
    monstr='OCT'
endif
if(mon=11)
    monstr='NOV'
endif
if(mon=12|mon=0)
    monstr='DEC'
endif
return monstr
;
这是我的上机作业,上传的gs文件是老师供我们参考的,若有侵犯版权问题,我会及时删帖的。最后,祝各位小伙伴们国庆节快乐!

temp.gs

3.24 KB, 下载次数: 4, 下载积分: 金钱 -5

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

新浪微博达人勋

发表于 2017-10-1 05:01:28 | 显示全部楼层

回帖奖励 +2 金钱

建议把数据也传上来,不然试一试很难知道哪里有问题的~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-10-1 06:18:50 | 显示全部楼层

回帖奖励 +2 金钱

顶一个!
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2017-10-1 06:27:15 | 显示全部楼层
tulalang 发表于 2017-10-1 05:01
建议把数据也传上来,不然试一试很难知道哪里有问题的~

好的,谢谢您,马上传数据
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-10-1 06:37:02 | 显示全部楼层
dat数据+ctl文件,ctl文件是老师提供的数据变量,我自己写的,应该没有很大的问题。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-10-1 06:39:35 | 显示全部楼层
ctl+dat文件压缩包

ctl dat.zip

18.47 MB, 下载次数: 20, 下载积分: 金钱 -5

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

新浪微博达人勋

发表于 2017-10-1 09:36:12 | 显示全部楼层
兄弟。。你的ctl,gs,数据都没出现你帖子里的问题,成功出图。。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-10-1 09:37:00 | 显示全部楼层
你看看是不是这样的图。。
1.png
4-2.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-10-1 10:11:27 | 显示全部楼层
tulalang 发表于 2017-10-1 09:37
你看看是不是这样的图。。

好像是的,。请问一下,您在运行时有木有出现那个问题呢?
为啥我的老师提示错误
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-10-1 10:12:15 | 显示全部楼层
tulalang 发表于 2017-10-1 09:36
兄弟。。你的ctl,gs,数据都没出现你帖子里的问题,成功出图。。

为啥我的有问题,运行老师提示那个错误。不知道为什么
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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