- 积分
- 501
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2021-3-9
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
前面已经得到突变点为2003年,并且过了99%的显著水平。现在进行合成分析,可是我研究的地区却没有过检验,求教一下程序是否有问题。- #1979-2020年5-10月的月平均、700百帕水平风场资料
- import numpy as np
- import Ngl,Nio
- f=Nio.open_file('/mnt/e/xinan/uv700_1979-2020_5-10.nc','r')
- #print(f)
- lon = f.variables['longitude'] # (361,)
- lat = f.variables['latitude'] # (161,)
- u = f.variables['u'] # (252,161,361)
- v = f.variables['v'] # (252,161,361)
- u = u*u.scale_factor+u.add_offset
- v = v*v.scale_factor+v.add_offset
- #突变年份为2003年,分成1979-2003和2004-2020两段做合成分析
- #(2003-1979+1)*6=150 & (2020-2004+1)*6=102
- ave_u1 = np.mean(u[0:150][:][:],0)
- ave_u2 = np.mean(u[150:252][:][:],0)
- ave_v1 = np.mean(v[0:150][:][:],0)
- ave_v2 = np.mean(v[150:252][:][:],0)
- dif_u = ave_u2-ave_u1
- dif_v = ave_v2-ave_v1
- # t 检验
- aveX = np.mean(v[0:150][:][:],0)
- aveY = np.mean(v[150:252][:][:],0)
- varX = np.var(v[0:150][:][:],0)
- varY = np.var(v[150:252][:][:],0)
- n1 = 25
- n2 = 17
- df = n1+n2-2
- d = (n1-1)*varX+(n2-1)*varY
- t = (aveX-aveY)/(np.sqrt(d/df)*np.sqrt(1/n1+1/n2))
- #print(t)_(161,361)
- print(np.min(t),np.max(t))
- #得到通过t检验的格点下标
- t1=[]
- t2=[]
- for i in range(0,161):
- for j in range(0,361):
- if np.abs(t[i][j])>=2.021: #自由度=40,α=0.05时,t=2.021
- t1.append(i)
- t2.append(j)
- print(len(t1),len(t2))
- #得到通过检验的格点经纬度
- lat1=[]
- lon1=[]
- for i in range(0,len(t1)):
- lat2=lat[t1[i]]
- lon2=lon[t2[i]]
- lat1.append(lat2)
- lon1.append(lon2)
- #print(len(lon1))
- wks = Ngl.open_wks('x11','/mnt/f/uv_700(ttest)')
-
- vcres = Ngl.Resources()
- mpres = Ngl.Resources()
- mpres.nglDraw =False
- mpres.nglFrame =False
- vcres.nglDraw =False
- vcres.nglFrame =False
- vcres.vfXArray =lon[::6]
- vcres.vfYArray =lat[::6]
- mpres.mpLimitMode = "LatLon" # Change the area of the
- mpres.mpMinLatF = 10 # map viewed.
- mpres.mpMaxLatF = 40
- mpres.mpMinLonF = 85
- mpres.mpMaxLonF = 120
- #需要的省界
- mpres.mpDataSetName = "Earth..4"
- mpres.mpDataBaseVersion = 'MediumRes'
- mpres.mpMaskAreaSpecifiers = ["Yunnan","Sichuan","Guizhou"]
- mpres.mpOutlineSpecifiers = ["Yunnan","Sichuan","Guizhou"]
- mpres.mpProvincialLineThicknessF = 2
- mpres.mpNationalLineThicknessF = 2
- mpres.mpOutlineBoundarySets = "Geophysical"
- mpres.mpGeophysicalLineThicknessF = 2.
- #箭头设置
- vcres.vcMinFracLengthF = 0.35 # Increase length of
- vcres.vcMinMagnitudeF = 0.001 # vectors.
- vcres.vcRefLengthF = 0.045
- vcres.vcRefMagnitudeF = 2.0
- vcres.vcGlyphStyle = 'CurlyVector'
- #题目
- mpres.tiMainString = "uv_700(ttest)"
- map_plot = Ngl.map(wks,mpres)
- vector_plot = Ngl.vector(wks,dif_u[::6,::6],dif_v[::6,::6],vcres)
- Ngl.overlay(map_plot,vector_plot)
- Ngl.draw(map_plot)
- #标记通过检验的位置
- mres = Ngl.Resources()
- mres.gsMarkerIndex = 16
- mres.gsMarkerSizeF = 0.002
- mres.gsMarkerColor = 'black'
- Ngl.polymarker(wks,map_plot,lon1,lat1,mres)
- Ngl.frame(wks)
复制代码
|
-
这个是画出来的图,打点的是过检验的地方。
|