爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6815|回复: 8

[脚本编辑] grads求最大值,没有输出结果

[复制链接]
发表于 2016-4-20 15:49:55 | 显示全部楼层 |阅读模式

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

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

x

想用grads求最大值,然后求最大值经纬度上的高度值。。。可是grads没有输出结果,不管最大值还是高度值都没有。。。求大神帮忙。。。
ix=37
while(ix<=51)
'set x 'ix''
'define um=max(uwnd,lat=30,lat=40)'
*'d um'
'set ccolor 15'
'define locy=maxloc(um,lat=30,lat=40)'
*define locx=maxloc(um,lon=90,lon=130)'
ix=ix+1
endwhile
'set lat 'locy''
'set lon 'locx''
'set t 1'
'd hgt'

密码修改失败请联系微信:mofangbao
发表于 2016-4-20 17:14:38 | 显示全部楼层
你的max函数用的用问题吧,直接用max嵌套就行,不需要循环,例如'define um=max(max(uwnd,lat=30,lat=40),lon=37,lon=51)'
新版grads种直接有函数可以用,甚至都不需要max嵌套
amax()

This function returns an area maximum -- the maximum value in a grid spanning an X-Y region. The syntax is:

amax(expr, xdim1, xdim2, ydim1, ydim2)

where:

expr    any valid GrADS grid expression
xdim1   starting X or LON dimension expression
xdim2   ending X or LON dimension expression
ydim1   starting Y or LAT dimension expression
ydim2   ending Y or LAT dimension expression
For global maximum, a shorthand may be used:

amax(expr, global) or
amax(expr, g)
is the same as
amax(expr, lon=0, lon=360, lat=-90, lat=90)
Usage Notes

This function will only work with GrADS version 2.0.2 or later.
This function is more efficient that using nested max functions.
Related functions amaxlocx and amaxlocy will return the grid location (X or Y) of the maximum value. If more than one grid box contains the maximum value, the location returned will be the first one encountered as the grid is scanned. The grid is scanned by rows from south to north, and each row is scanned from west to east.
A similar set of functions exists for finding the minimum over an area: amin, aminlocx, and aminlocy.
Examples

Get the maximum value of the variable ps over a specified grid domain:
d amax(ps,x=10,x=120,y=15,y=45)

Get the maximum value of the variable sstanom over the nino3.4 domain:
d amax(sstanom,lon=-170,lon=-120,lat=-5,lat=5)
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

发表于 2016-4-20 16:42:25 | 显示全部楼层
'define um=max(uwnd,lat=30,lat=40)'
在这句之前,把维数说清楚看看。um的维数环境到底是啥样的?
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-4-21 12:15:41 | 显示全部楼层
问题解决了,的确不需要循环。谢谢你啦!
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-4-21 12:16:17 | 显示全部楼层
river 发表于 2016-4-20 17:14
你的max函数用的用问题吧,直接用max嵌套就行,不需要循环,例如'define um=max(max(uwnd,lat=30,lat=40),l ...

问题解决了,的确不需要循环。谢谢你啦!
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-4-21 12:17:16 | 显示全部楼层
学而不厌 发表于 2016-4-20 16:42
'define um=max(uwnd,lat=30,lat=40)'
在这句之前,把维数说清楚看看。um的维数环境到底是啥样的?

问题解决了,是循环那里有问题。谢谢你啦~
密码修改失败请联系微信:mofangbao
发表于 2016-4-21 14:49:53 | 显示全部楼层
王小禾 发表于 2016-4-21 12:17
问题解决了,是循环那里有问题。谢谢你啦~

把改好的发出了,让我也学习学习吧
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-4-21 18:17:56 | 显示全部楼层
学而不厌 发表于 2016-4-21 14:49
把改好的发出了,让我也学习学习吧

'reinit'
'open hgt.ctl'
'open uwnd.ctl'
'define um=maxloc(uwnd.2,lat=10,lat=60)'
'set ccolor 15'
'set gxout print'
'd um'
record=substr(result,5,800)
re=write(,record)
至于高度场。。。还没求出来呢。。。
密码修改失败请联系微信:mofangbao
发表于 2018-4-17 12:18:07 | 显示全部楼层
学习一下,刚好用到!!!
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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