爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6837|回复: 6

[求助] 做相关系数的显著性检验

[复制链接]

新浪微博达人勋

发表于 2022-5-16 17:23:54 | 显示全部楼层 |阅读模式

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

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

x
计算1979-2019年的EU遥相关指数与同期环流场(500hPa高度场或海平面气压场)的相关系数,并做相关系数的显著性检验

EU-R.py

1.81 KB, 下载次数: 25, 下载积分: 金钱 -5

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

新浪微博达人勋

 楼主| 发表于 2022-5-16 19:48:32 | 显示全部楼层
ds=xr.open_dataset('D:\dqqh\dq2022\dq2022\shixi1\hgt.mon.mean.nc')
hgt=ds.hgt
print(hgt.shape)
hgt_Jan_year=hgt.groupby('time.month')[1]
print(hgt_Jan_year.shape)
hgt_Jan=hgt_Jan_year[31:72,5,:,:]
print(hgt_Jan.shape)

lat=ds.variables['lat'][:]
lon=ds.variables['lon'][:]

##################################EU指数#####################################
hgt_1=hgt_Jan.loc[:,55,20]
hgt_2=hgt_Jan.loc[:,55,75]
hgt_3=hgt_Jan.loc[:,40,145]

I=hgt_2*(0.5)-hgt_1*(0.25)-hgt_3*(0.25)
print(I)

I_mean=np.mean(I) #标准化处理
I_sd=math.sqrt(sum((I-I_mean)**2)/41.0)
I_std=(I-I_mean)/I_sd
print(I_std.shape)

fig=plt.figure(figsize=(10,8))
ax1=fig.add_subplot()

ax1.plot(I_std,marker='o',linewidth=1.5,ms=5)
ax1.set_title('Std EU Index')
ax1.set_xlabel('Years')
plt.xticks(np.arange(0, 41, 5), np.arange(1979,2020,5))  #或者ax.set_xticks(np.arange(0, 41,5))//ax.set_xticklabels(np.arange(1979,2020,5))
plt.savefig(r'D:\dqqh\dq2022\dq2022\shixi3-4\EU-Index.jpg',dpi=300)
plt.show()
plt.close()

##################################与500hPa位势高度的相关系数############################
r,p = np.zeros((73,144)),np.zeros((73,144))
for i in range(73):
    for j in range(144):
        r[i,j],p[i,j]=pearsonr(hgt_Jan[:,i,j],I_std)
print(r.shape)

fig=plt.figure(figsize=(10,10))
ax1  = fig.add_subplot(111)
cmap = plt.get_cmap('RdBu_r')  #选择coloarmap

ax1 = plt.subplot(111, projection=ccrs.PlateCarree(central_longitude=180))
ax1.set_global() #使得轴域(Axes即两条坐标轴围城的区域)适应地图的大小
ax1.coastlines() #画出海岸线

ax1.set_xticks([0, 60, 120, 180, 240, 300, 360], crs=ccrs.PlateCarree())
ax1.set_yticks([-90, -60, -30, 0, 30, 60, 90], crs=ccrs.PlateCarree())
#zero_direction_label用来设置经度的0度加不加E和W
lon_formatter = LongitudeFormatter(zero_direction_label=False)
lat_formatter = LatitudeFormatter()
ax1.xaxis.set_major_formatter(lon_formatter)
ax1.yaxis.set_major_formatter(lat_formatter)

plt.contourf(lon,lat,r,cmap='RdBu_r',levels=np.arange(-1,1.1,0.1),transform=ccrs.PlateCarree(),zorder=0)
plt.colorbar(shrink=0.87,aspect=20)
#ax1.set_title(f'2019-500hPa Jan_anomaly gpm')
plt.savefig(r'D:\dqqh\dq2022\dq2022\shixi3-4\EU_hgt_r_plate.jpg',dpi=300)
plt.show()

#相关系数的t检验

代码如上
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2022-5-21 09:01:07 | 显示全部楼层
看样子同是信带大三学子
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2022-5-23 09:16:12 | 显示全部楼层
GXYYYYY 发表于 2022-5-21 09:01
看样子同是信带大三学子

哈哈,是的!
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2022-5-31 16:53:37 | 显示全部楼层
请问楼主如果缺测数量偏多的话该怎么处理呢
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2022-6-13 16:14:12 | 显示全部楼层
GXYYYYY 发表于 2022-5-21 09:01
看样子同是信带大三学子

我们老师是zy你们呢。。不会还是一个班的吧。。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2022-6-14 08:47:11 | 显示全部楼层
wei来守虎者 发表于 2022-6-13 16:14
我们老师是zy你们呢。。不会还是一个班的吧。。

看来不是哈哈哈哈哈 我们短期是华老师
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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