【发布时间】:2021-01-10 00:10:05
【问题描述】:
我正在尝试使用 cartopy 在地图上绘制一些风矢量。然而,风看起来很奇怪,所以我在 75N 的一圈点上使用风矢量做了一个简单的测试。风矢量应指向远离纬度/经度网格 45 度的方向,因为在立体投影下 u-winds 和 v-winds 的大小相同,这应该保持角度。
from matplotlib import pyplot as plt
import numpy as np
import cartopy.crs as ccrs
pcproj = ccrs.PlateCarree()
lon0 = -150
mapproj = ccrs.Stereographic(
central_longitude=lon0,central_latitude=75,
true_scale_latitude=75,
)
XLIM = 300e3; YLIM=300e3
dm =5; dp=1
fig = plt.figure(0,(7,7))
ax = fig.add_axes([0.1,0.1,0.85,0.9],projection=mapproj)
ax.set_extent([-XLIM,XLIM,-YLIM,YLIM],crs=mapproj)
ax.coastlines(resolution='50m',color='.5',linewidth=1.5)
lon_grid = np.arange(-180,181,dm)
lat_grid = np.arange(-80,86,dp)
gl = ax.gridlines(draw_labels=True,
xlocs=lon_grid,ylocs=lat_grid,
x_inline=False,y_inline=False,
color='k',linestyle='dotted')
# --- draw 45 degree winds at 75N
lon = np.linspace(0,360,73)
lat = np.ones(len(lon))*75
uu = np.ones(len(lon))*10
vv = uu*1.
pts = mapproj.transform_points(pcproj,lon,lat)
xx = pts[...,0]; yy = pts[...,1]
ux,vx = mapproj.transform_vectors(pcproj,lon,lat,uu,vv)
ax.quiver(xx,yy,ux,vx,transform=mapproj)
很明显,风矢量与纬度/经度网格不成 45 度。
我检查了ux、vx 在 150W 和 75N 的投影中心。这里的风应该与纬度/经度网格相同,但它是 (3.54,13.7) 而不是 (10,10)。
风向量看起来和使用这条线一样
ax.quiver(lon,lat,uu,vv,transform=pcproj)
这可能不足为奇,因为我认为 quiver 在后台使用了 transform_vector 和 transform_points。
我尝试了沿纬度/经度网格方向的风,它们被正确转换。
这是transform_vectors 中的错误还是我使用不正确?
更新:
正如@swatchai 所建议的,现在,u-wind 在输入到transform_vectors 之前应该除以cos(lat)。我怀疑这是预期的行为,但应该使用这种规范化,直到未来的 cartopy 更新改变了行为。他们可能会选择只更新文档字符串。不过,在未来的 cartopy 更新中需要注意一些事情。
【问题讨论】:
标签: python-3.x vector rotation transform cartopy