Metpy:hodograph 将点放在指定的风数据上?

Metpy: hodograph place point at specified wind data?

提问人:user5618251 提问时间:5/24/2021 最后编辑:ForceBruuser5618251 更新时间:5/25/2021 访问量:371

问:

我正在尝试将地面以上特定高度的风数据纳入大气探测的全息图中。更具体地说,我希望将地表的风,1 公里、3 公里、6 公里和 9 公里绘制成一个点。到目前为止,我刚刚实现了在边界中将它们分开:

# Make an array of segment boundaries - don't forget units!
boundaries_h = [0, 1000, 3000, 6000, 9000] * units.meter

# Make a list of colors for the segments
colors_h = ['#66B2FF', '#3333FF', '#7F00FF', '#000000']

# Create a hodograph
ax_hod = inset_axes(skew.ax, '37.5%', '36.5%', loc=1)
wmax = np.concatenate((u, v))
wmax = np.max(wmax)
h = Hodograph(ax_hod, component_range=wmax.magnitude+2)
if wmax.magnitude < 20:
    h.add_grid(increment=5)
if wmax.magnitude < 40 and wmax.magnitude > 20:
    h.add_grid(increment=10)
if wmax.magnitude > 40:
    h.add_grid(increment=20)
h.plot_colormapped(u, v, z, intervals=boundaries_h, colors=colors_h)

基本上,我只想要每个段的开头和结尾的点,并带有指定高度的文本(sfc、1 km、3 km、6 km、9 km)。我该怎么做? 顺便问一下,有没有办法将全息轴的标签包含在圆圈内?

enter image description here

蟒蛇 梅蒂

评论


答:

1赞 DopplerShift 5/25/2021 #1

除非您已经拥有这些边界点,否则您需要手动插值到这些边界点。您可以使用 --绘制为匹配的彩色点,或者如果您不希望它们着色,则可以使用。这应该可以作为上述代码的补充。scatterplot

import matplotlib.colors as mcolors
import matplotlib.patheffects as mpatheffects
import metpy.interpolate as mpinterpolate

# Interpolate to the boundary heights
u_pts, v_pts = mpinterpolate.interpolate_1d(boundaries_h, z, u, v)

# Generate a colormap/norm to color the points with scatter
cmap = mcolors.ListedColormap(colors_h)
norm = mcolors.BoundaryNorm(boundaries_h.m, cmap.N)
ax_hod.scatter(u_pts, v_pts, c=boundaries_h, cmap=cmap, norm=norm, zorder=10)

# Loop over points and heights to plot text (using a path effect to
# get outlined text that should show up better)
for up, vp, z in zip(u_pts, v_pts, boundaries_h):
    z_str = '{:~.0f}'.format(z.to('km')) if z else 'Sfc'
    ax_hod.text(up, vp, z_str, ha='center', fontsize=12,
                path_effects=[mpatheffects.withStroke(foreground='white', linewidth=2)],
                zorder=12)

# Change tick parameters to put the ticks and labels inside
ax_hod.tick_params(axis='y', direction='in', pad=-20)
ax_hod.tick_params(axis='x', direction='in', pad=-15)