爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 24116|回复: 4

[求助] 风场绘制位置出错

[复制链接]
发表于 2021-3-27 13:33:44 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 百雀羚口服 于 2021-3-27 13:40 编辑

读取的是190-230E的数据,海温场能够正常绘制,但风场却画到了10-50E的位置,求指教

U=w['u'][26::2,:,:].mean(dim='time').sel(latitude=slice(20,10),longitude=slice(190,230))
V=w['v'][26::2,:,:].mean(dim='time').sel(latitude=slice(20,10),longitude=slice(190,230))
SST=sst['sst'][26::2,:,:].mean(dim='time').sel(latitude=slice(20,10),longitude=slice(190,230))
lon=U['longitude']
lat=V['latitude']
proj=ccrs.PlateCarree(central_longitude=180)
datacrs=ccrs.PlateCarree()
fig1=plt.figure(figsize=(12,8),dpi=500)
ax1=fig1.add_axes([0.1,0.1,0.6,0.6],projection=proj)
ax1.coastlines(lw=0.6)
ax1.set_xticks(np.arange(0,361,60),crs=ccrs.PlateCarree())
ax1.set_yticks(np.arange(-90,90,20),crs=ccrs.PlateCarree())
ax1.xaxis.set_major_formatter(LongitudeFormatter())
ax1.yaxis.set_major_formatter(LatitudeFormatter())
ax1.set_extent([0,250,0,50], crs=ccrs.PlateCarree())
ax1.set_title('(a)  Jul(5 months before)',loc='left')
ax1.contourf(lon,lat,SST,np.arange(295,302,0.3),cmap=plt.get_cmap('RdBu_r'),extend='both',transform=datacrs)
q=ax1.quiver(lon[::20],lat[::20],U[::20,::20],V[::20,::20],pivot='mid',scale=40,scale_units='inches',width=0.0018,headwidth=4)   
ax1.quiverkey(q,0.95,0.1,5,r'$5 \frac{m}{s}$',labelpos='W')
codes=[Path.MOVETO,Path.LINETO,Path.LINETO,Path.LINETO,Path.CLOSEPOLY,]
vertices=[(10,10),(10,20),(50,20),(50,10),(0,0)]
path=Path(vertices,codes)
patch=patches.PathPatch(path,facecolor='NONE',edgecolor='k',ls='-',lw=1)
ax1.add_patch(patch)
aha.png
aha.png
code.png
密码修改失败请联系微信:mofangbao
发表于 2021-3-27 17:04:38 | 显示全部楼层
ax.quiver里面没有指定transform,那么会默认使用ax.projection,也就是ccrs.PlateCarree(central_longitude=180),所以风场从190-230E减了180度,偏离到10-50E了。
应该指定transform=ccrs.PlateCarree()
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-3-28 14:39:34 | 显示全部楼层
灭火器 发表于 2021-3-27 17:04
ax.quiver里面没有指定transform,那么会默认使用ax.projection,也就是ccrs.PlateCarree(central_longitud ...

感谢解答!是这样添加吗q=ax1.quiver(lon[::20],lat[::20],U[::20,::20],V[::20,::20],pivot='mid',scale=40,scale_units='inches',width=0.0018,headwidth=4,transform=ccrs.PlateCarree())
可是我改完之后报错了

error.png
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2021-3-29 08:44:00 | 显示全部楼层
百雀羚口服 发表于 2021-3-28 14:39
感谢解答!是这样添加吗q=ax1.quiver(lon[::20],lat[::20],U[::20,::20],V[::20,::20],pivot='mid',scale ...

你这报错不是写的很清楚吗,不要用xarray的DataArray来画quiver图。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-3-29 14:02:16 | 显示全部楼层
灭火器 发表于 2021-3-29 08:44
你这报错不是写的很清楚吗,不要用xarray的DataArray来画quiver图。

谢谢!!成功了
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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