为何Metpy两种方法绘制Skew-T图干绝热线结果不同?
问题
我尝试在Skew-T对数气压图上绘制一条经过指定气块温压点(p_trg=900hPa,T_trg=15℃)的位温线。Metpy提供两种实现方式:metpy.plots.plot_dry_adiabats(直接绘制干绝热线)和metpy.calc.dry_lapse(生成数值数组后通过SkewT.ax.plot绘制),但两种方法结果存在差异,后者结果看似正确。
两种方法均需设置位于图表边界的起始点,我通过metpy.calc.potential_temperature和metpy.calc.temperature_from_potential_temperature依次计算该点的温压值,实现代码如下:
import matplotlib.pyplot as plt import metpy.calc as mpcalc from metpy.units import units from metpy.plots import SkewT import numpy as np # coordinate of the target point p_trg=900*units.hPa T_trg=15*units.degC fig = plt.figure(figsize=(9, 5)) skew = SkewT(fig, rotation=30) skew.ax.set_xticks(range(-15,26,5)) skew.ax.set_yticks(range(600,1010,50)) skew.ax.set_ylim(1020, 600) skew.ax.set_xlim(-10,27) # potential temperature of the line theta=mpcalc.potential_temperature(p_trg, T_trg) # point on the border of the chart and on the potential temperature line p_bord=skew.ax.get_ylim()[0]*units.hPa T_bord=mpcalc.temperature_from_potential_temperature(p_bord,potential_temperature=theta) # pressure values to be included in the line (first value on the border) pressure_levels=np.append(p_bord.magnitude, np.array([1010,900,800,700,600]))*units.hPa # plot the dry adiabat line skew.plot_dry_adiabats(t0=[T_bord.magnitude]*T_bord.units,pressure=pressure_levels) # privide the value of T at each pressur level and plot them dry_lapse_T=mpcalc.dry_lapse(pressure=pressure_levels, temperature=T_bord,reference_pressure=p_bord) skew.ax.plot(dry_lapse_T,pressure_levels)
恳请帮忙解释两种方法结果存在差异的原因。
差异原因分析
plot_dry_adiabats参数理解错误:该函数的t0参数要求传入的是位温值(θ),而非边界点的实际温度(T_bord)。你传入了边界点的温度,相当于让函数绘制一条从该温度出发的干绝热过程线,而非对应目标点位温的干绝热线,这是结果偏差的核心原因。dry_lapse逻辑完全正确:你先通过位温反算出边界点温度,再用dry_lapse沿干绝热过程计算各气压层的温度,这完全符合位温线的定义——同一干绝热线上所有点的位温相同,因此计算出的温度序列能准确经过目标点。- 修正方案:使用
plot_dry_adiabats时,直接传入目标点的位温theta即可,无需用边界点温度。修正后的代码行应为:skew.plot_dry_adiabats(t0=[theta.magnitude]*theta.units, pressure=pressure_levels)
内容的提问来源于stack exchange,提问作者Fabrizio
相关产品推荐
相关产品推荐

