爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4806|回复: 4

[脚本编辑] 关于maskout中如何能把默认缺测的部分赋值

[复制链接]
发表于 2014-9-5 18:42:37 | 显示全部楼层 |阅读模式

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

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

x
关于maskout的一个问题:
如果在gs文件中定义一个量如:定义a为降水大于100mm('define a=maskout(rainnc,rainnc-100)'),那么如果将这个变量a与别的量(如水平风速U)进行运算后画图如:‘d a*u’那么则会出现问题,出不来图。
根据我分析应该是因为把a变量中小于100mm的降水设为缺测,那么这个缺测的部分与u相乘后则会报错,出不来图。
那么要是我想把a变量中小于100mm的降水视为0或任意一个常数,怎么与风速u相乘后进行整体计算出图?
谢谢!
密码修改失败请联系微信:mofangbao
发表于 2014-9-5 19:07:49 | 显示全部楼层
结合const试试吧
const()

const (expr, value, <-u|-a>)

This is a powerful function that allows the user to change the missing values of a variable, set all the non-missing values of a variable to a constant, or set all possible values of a variable (both valid and missing) to a constant.

expr   a valid GrADS expression
value  a constant, either an integer or floating point value
-u     all missing data are set to value; non-missing data are unchanged
-a     all data are set to value, both missing and non-missing
Default behaviour is to set all non-missing data equal to value; missing data are unchanged
Usage Notes

The const function operates on both gridded and station data.
If value is given as an integer, it will still be treated as as floating point.
Examples

The const function assigns a new value to missing data, so that missing data may participate in operations:
const(z, 0, -u)
The const function is used with the set gxout linefill graphics output option to define a straight horizontal line:
set lon -90
set lat -90 90
set gxout linefill
set lev 500
d const(t, -20);t-273
In this example, const is used to calculate a daily timeseries of the fraction of the globe convered by precipitation greater than 10mm/day:
set lon 0 360
set lat -90 90
set t 1 last
define ones = const(const(maskout(p,p-10),1),0,-u)
set x 1
set y 1
display tloop(aave(ones,lon=0,lon=360,lat=0,lat=360))
Notes: The defined variable "ones" contains 1 wherever the precip value is greater than 10, and 0 whever the precip value is less than 10. This is done via nested functions; first maskout sets all values less than 10 to missing, then const sets all non-missing values to 1, then const is used with the -u flag to set all the missing data values to 0. The aave function calculates an area weighted average. Since we are averaging zeros and ones, the result is the fraction of the area where there are ones. See the tloop function for a description of how to perform time series of areal averages.
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-9-6 12:41:17 | 显示全部楼层
river 发表于 2014-9-5 19:07
结合const试试吧
const()

谢谢,我也试过这个,但是用const的话是对一个量比较方便,但是与别的量相乘等进行运算时就有问题。我再看看吧 谢谢
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-9-8 22:02:14 | 显示全部楼层
司空摘月 发表于 2014-9-6 12:41
谢谢,我也试过这个,但是用const的话是对一个量比较方便,但是与别的量相乘等进行运算时就有问题。我再 ...

@river 的提醒下,结合const还是解决了这个问题,主要是在const(p,0,-u)这个函数中,注意-u的选项。有了-u则会把缺测值赋值为0,其他值不变。
密码修改失败请联系微信:mofangbao
发表于 2014-9-8 22:10:00 | 显示全部楼层
司空摘月 发表于 2014-9-8 22:02
在@river 的提醒下,结合const还是解决了这个问题,主要是在const(p,0,-u)这个函数中,注意-u的选项。有 ...

解决问题就好
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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