Metpy:指定风数据的测速仪位置点?

Metpy: hodograph place point at specified wind data?

我正在尝试将地面以上特定高度的风数据包含到大气探测的测速仪中。更具体地说,我希望将 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 公里、3 公里、6 公里、9 公里)。我怎样才能做到这一点? 顺便说一下,还有没有办法在圆圈内包含路径轴的标签?

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

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)