0

我正在尝试使用metpy为倾斜图上的线条添加标签。我不确定是否可能(在 GitHub 上查看了metpy,似乎他们还没有实现这个功能)。但本质上,我只想为潮湿绝热、干燥绝热和混合比贴上标签。目前,我用来调用和绘制这些函数的代码是:

# Choose temperatures for moist adiabats
t0 = units.K * np.arange(278.15, 306.15, 4)
msa = skew.plot_moist_adiabats(t0=t0, linestyles='solid', colors='lime', linewidths=1.5)
# Choose starting temperatures in Kelvin for the dry adiabats
t0 = units.K * np.arange(243.15, 443.15, 10)
skew.plot_dry_adiabats(t0=t0,
                         linestyles='solid',
                         colors='gray',
                         linewidth=1.5)

# Choose the range of pressures that the mixing ratio lines are drawn over
p = units.hPa * np.linspace(1000, 400, 7)
skew.plot_mixing_lines(w=w, p=p, colors='lime')
4

1 回答 1

0

MetPy 目前不具备自动标记这些特殊行的能力。正如我确定您发现的那样,目前存在一个未解决的问题。现在你最好的解决方案是使用ax.text在绘图上手动添加文本的方法,计算行顶部的露点来定位文本:

import metpy.calc as mpcalc
from metpy.plots import SkewT
from metpy.units import units

skew = SkewT()

w = np.array([0.028, 0.024, 0.020, 0.016, 0.012, 0.008, 0.004])[:, None] * units('g/g')
p = units.hPa * np.linspace(1000, 400, 7)
skew.plot_mixing_lines(w=w, p=p, colors='lime')

# Label every third line
for val in w.flatten()[::3]:
    top_p = p[-1]
    dewpt = mpcalc.dewpoint(mpcalc.vapor_pressure(top_p, val))
    skew.ax.text(dewpt, top_p, str(val.to('g/kg').m),
                 horizontalalignment='center')
于 2020-09-29T05:27:51.843 回答