爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 10900|回复: 10

[脚本编辑] grads中利用tcorr函数求相关系数的问题

[复制链接]
发表于 2015-6-18 22:51:02 | 显示全部楼层 |阅读模式

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

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

x
QQ图片20150618223659.png
QQ图片20150618223709.png
在上面的两个gs中,第一个打开的文件都是关于W-Y指数的,第二个是关于海温场的(一共44年,每年的678月取一个平均海温)。
我的问题如下:
1,我在做求相关系数的过程中,用了朋友的gs文件,只改变了相关的变量名等,但是问题层出不穷,不是提示范围溢出,就是提示第一个应是0维变量。但是在朋友的他自己实验中,他的gs相对应的cti文件,可以得到正确的结果图形。
2,我在写自己的gs的过程中,相对应朋友的gs文件而言,我认为起决定性的改变,就是我加了set dfile 2 这条语句,加了这语句之后,我的gs在我的程序中就可以得到正确的结论。随后,在朋友的gs中,我也相应的加上这一条语句,然而,却得不到正确的结论了。
3,我不明白,为什么我的gs加上set dfile 2 就是正确的,朋友的加上却不对了。
4,我不明白,define之后的set lon lat的设置到底是相对那个文件而言的,file1?orfile2?
谢谢各位大神的帮助解答,小白不胜感激。

密码修改失败请联系微信:mofangbao
发表于 2015-6-19 08:04:52 | 显示全部楼层
你已经加了set dfile 2然后在求相关的时候用了seaave.2,然后还得到了正确结果?我也是醉了······
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-6-19 09:08:11 | 显示全部楼层
river 发表于 2015-6-19 08:04
你已经加了set dfile 2然后在求相关的时候用了seaave.2,然后还得到了正确结果?我也是醉了······

我也醉了……,在seaave后不管加不加.2,运行的结果都是对的,我哭~~
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-6-19 09:09:29 | 显示全部楼层
river 发表于 2015-6-19 08:04
你已经加了set dfile 2然后在求相关的时候用了seaave.2,然后还得到了正确结果?我也是醉了······

但是,只要我不加set dfile 2,它就是得不到
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-6-19 09:19:45 | 显示全部楼层
gs更改如图,运行之后的错误也如图
11.png
222.jpg
密码修改失败请联系微信:mofangbao
发表于 2015-6-19 19:51:22 | 显示全部楼层
田芽儿 发表于 2015-6-19 09:19
gs更改如图,运行之后的错误也如图

set dfile 2是一定要加的,把变量的.2去掉
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-6-20 13:43:11 | 显示全部楼层
river 发表于 2015-6-19 19:51
set dfile 2是一定要加的,把变量的.2去掉

去掉了,结果也得到了,只是不明白为什么,朋友的不加set dfile 2 是正确的,我的一定要加才可以得到结果。
密码修改失败请联系微信:mofangbao
发表于 2015-6-20 22:05:00 | 显示全部楼层
田芽儿 发表于 2015-6-20 13:43
去掉了,结果也得到了,只是不明白为什么,朋友的不加set dfile 2 是正确的,我的一定要加才可以得到结果 ...

也不是一定要用set dfile 命令的,和使用的资料有一定关系。你看一下官方用法吧。
tcorr()

tcorr (expr1, expr2, tdim1, tdim2)

This function produces a spatial map of temporal correlation coefficients.

expr1   - a valid GrADS expression that varies in time
expr2   - a valid GrADS expression that varies in time and may also vary in X and Y
tdim1   - starting time dimension expression
tdim2   - ending time dimension expression
The expr1 time series is correlated to the time series at each grid point in expr2. The result is a grid of correlation coefficients that matches the X and Y dimensions of expr2.

Usage Notes

If both expr1 and expr2 vary only in time, the output is a single value.
Use the scorr function to do correlation over the spatial domain.
Example

This example calculates the temporal correlation between sea level pressure and the defined variable elnino, an areal average of surface temperature in the equatorial Pacific.
set x 1
set y 1
set z 1
set t 1 100
define elnino = aave(ts,lon=-160,lon=-80,lat=-10,lat=10)
set lon -180 180
set lat -90 90
set z 1
set t 1
d tcorr(elnino, slp, t=1, t=100)
密码修改失败请联系微信:mofangbao
发表于 2015-6-25 15:10:37 | 显示全部楼层
set lon 30 385是不是这里溢出了
密码修改失败请联系微信:mofangbao
发表于 2015-6-25 15:13:39 | 显示全部楼层
你那个set lat lon是关于你当前默认的文件中的设置吧
你写在set dfile 2之后在设置就是对于文件2的设置吧
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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