- 积分
- 42918
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-8-28
- 最后登录
- 1970-1-1
|
发表于 2019-6-16 22:22:36
|
显示全部楼层
不好意思,这个很久了,我也快忘记了。不过确实是我的问题,在GrADS里面的 if 语句可以用来提取满足某些条件的数据,但我回复的用法有问题。你可以去看看官网的函数说明。http://cola.gmu.edu/grads/gadoc/gadocindex.html
if()
This function performs an if/then/else expression evaluation. It is available starting with GrADS version 2.1.1.b0.
Syntax
if (logical_expr, then_expr, else_expr)
where:
logical_expr - any valid logical expression that has a boolean (yes/no) result
then_expr - the result expression if logical_expr is true
else_expr - the result expression if logical_expr is false
All the arguments must be expressions for gridded data -- the logical operators and the if() function have not yet been implemented for station data.
Usage Notes
The logical_expr should include one or more of the logical operators: =, !=, >, >=, <, <=, |, &
The result of a logical operation is boolean -- an answer to a yes/no question. If the expression is true the result is 1, and if the expression is false the answer is -1. The if() function will evaluate logical_expr and wherever the result is >0 it will place the value of then_expr, and wherever the result is <0 it will place the value of else_expr.
The argumentsthen_expr and else_expr may be any GrADS expression, including a constant. If you want then_expr or else_expr to be undefined, then use maskout() instead of the if() function.
Examples
Here is a script sample to find the minimum and maximum 2-meter temperature at each grid point over a 12-month period:
'define tmin = const(t2m,1e9)'
'define tmax = const(t2m,-1e9)'
t = 1
while (t <= 12)
'set t 't
'define tmin = if(t2m<tmin,t2m,tmin)'
'define tmax = if(t2m>tmax,t2m,tmax)'
t = t + 1
endwhile |
|