在Metpy 1.5中绘制包裹虚拟温度剖面

huangapple go评论77阅读模式
英文:

Plotting the Parcel Virtual Temp Profile in Metpy 1.5

问题

MetPy 1.5.0已于今天早些时候发布,我有机会测试虚拟温度校正的CAPE/CIN热力参数。

但是,通过在我的端上使用我的初学者技能进行尝试,如图所示,校正的剖面(虚线黑线)未接近/收敛到未校正的剖面(实线黑线)。也许我遗漏了一些小细节?有解决方法吗?

以下是最小可复制的代码;

from metpy.calc import cape_cin, dewpoint_from_relative_humidity, parcel_profile
from metpy.units import units

# 压力
p = [1008., 1000., 950., 900., 850., 800., 750., 700., 650., 600.,
     550., 500., 450., 400., 350., 300., 250., 200.,
     175., 150., 125., 100., 80., 70., 60., 50.,
     40., 30., 25., 20.] * units.hPa
# 温度
T = [29.3, 28.1, 23.5, 20.9, 18.4, 15.9, 13.1, 10.1, 6.7, 3.1,
     -0.5, -4.5, -9.0, -14.8, -21.5, -29.7, -40.0, -52.4,
     -59.2, -66.5, -74.1, -78.5, -76.0, -71.6, -66.7, -61.3,
     -56.3, -51.7, -50.7, -47.5] * units.degC
# 相对湿度
rh = [.85, .65, .36, .39, .82, .72, .75, .86, .65, .22, .52,
      .66, .64, .20, .05, .75, .76, .45, .25, .48, .76, .88,
      .56, .88, .39, .67, .15, .04, .94, .35] * units.dimensionless
# 计算露点
Td = dewpoint_from_relative_humidity(T, rh)

# 这个还需要吗?还是不再需要了?
mxr = mpcalc.mixing_ratio_from_relative_humidity(p, T, rh).to('g/kg')
vt = mpcalc.virtual_temperature(T, mxr, 0.622)

# 计算抬升气块温度
prof = parcel_profile(p, T[0], Td[0]).to('degC')

# 这个需要吗?或者在Metpy 1.5中的抬升气块剖面中有一个隐藏的“返回”函数,可以获取正确的抬升气块虚拟温度剖面?
prof1 = parcel_profile(p, vt[0], Td[0]).to('degC')

# 创建一个新的图。这里的尺寸给出了一个良好的纵横比
fig = plt.figure(figsize=(13,13))

# 绘图网格
gs = gridspec.GridSpec(3, 3)
skew = SkewT(fig, rotation=45, subplot=gs[:, :2])

skew.plot(p, T, 'r', label='环境温度')
skew.plot(p, vt, 'r', ls='--', label='虚拟温度')
skew.plot(p, Td, 'g', label='露点温度')
skew.ax.set_ylim(1000, 100)
skew.plot(p, prof, color='k', ls='-', lw=2, label='气块温度')
skew.plot(p, prof1, color='k', ls='--', lw=1, label='气块虚拟温度(位移)')

skew.ax.legend()

# 添加相关的特殊线
skew.plot_dry_adiabats(alpha=0.2)
skew.plot_moist_adiabats(alpha=0.2)

# 良好的纵横比边界
skew.ax.set_xlim(-30, 40)

# 显示图
plt.show()

在Metpy 1.5中绘制包裹虚拟温度剖面

英文:

MetPy 1.5.0 was rolled out earlier today and I get the chance to test out the virtual temperature corrected CAPE/CIN thermo parameters.

But, upon trying it out on my end with my novice skills as seen in the figure, the corrected profile (dashed black line) is not approaching/converging towards the uncorrected profile (solid black line). Perhaps I missed out something small? Is there a solution for this one?

The minimum reproducible code below is;

from metpy.calc import cape_cin, dewpoint_from_relative_humidity, parcel_profile
from metpy.units import units
# pressure
p = [1008., 1000., 950., 900., 850., 800., 750., 700., 650., 600.,
550., 500., 450., 400., 350., 300., 250., 200.,
175., 150., 125., 100., 80., 70., 60., 50.,
40., 30., 25., 20.] * units.hPa
# temperature
T = [29.3, 28.1, 23.5, 20.9, 18.4, 15.9, 13.1, 10.1, 6.7, 3.1,
-0.5, -4.5, -9.0, -14.8, -21.5, -29.7, -40.0, -52.4,
-59.2, -66.5, -74.1, -78.5, -76.0, -71.6, -66.7, -61.3,
-56.3, -51.7, -50.7, -47.5] * units.degC
# relative humidity
rh = [.85, .65, .36, .39, .82, .72, .75, .86, .65, .22, .52,
.66, .64, .20, .05, .75, .76, .45, .25, .48, .76, .88,
.56, .88, .39, .67, .15, .04, .94, .35] * units.dimensionless
# calculate dewpoint
Td = dewpoint_from_relative_humidity(T, rh)
# Is this still needed? or no longer? 
mxr = mpcalc.mixing_ratio_from_relative_humidity(p, T, rh).to('g/kg')
vt = mpcalc.virtual_temperature(T, mxr, 0.622)
# compture parcel temperature
prof = parcel_profile(p, T[0], Td[0]).to('degC')
# Is this needed? or there's a 'return' function hidden in parcel profile to get 
# the correct parcel virtual temperature profile in Metpy 1.5? 
prof1 = parcel_profile(p, vt[0], Td[0]).to('degC')
# Create a new figure. The dimensions here give a good aspect ratio
fig = plt.figure(figsize=(13,13))
# Grid for plots
gs = gridspec.GridSpec(3, 3)
skew = SkewT(fig, rotation=45, subplot=gs[:, :2])
skew.plot(p, T, 'r', label='Environmental Temperature')
skew.plot(p, vt, 'r', ls='--', label='Virtual Temperature')
skew.plot(p, Td, 'g', label='Dewpoint Temparature')
skew.ax.set_ylim(1000, 100)
skew.plot(p, prof, color='k', ls='-', lw=2, label='Parcel Temperature')
skew.plot(p, prof1, color='k', ls='--', lw=1, label='Parcel Virtual Temperature (displaced)')
skew.ax.legend()
# Add the relevant special lines
skew.plot_dry_adiabats(alpha=0.2)
skew.plot_moist_adiabats(alpha=0.2)
# Good bounds for aspect ratio
skew.ax.set_xlim(-30, 40)
# Show the plot
plt.show()

在Metpy 1.5中绘制包裹虚拟温度剖面

答案1

得分: 1

我们选择不将使用虚拟温度校正的配置文件作为单独的 API 函数添加。如果这很重要,您可以在 GitHub 上提出一个功能请求

要计算配置文件的正确虚拟温度,您需要正确的包水汽混合比。这包括:

  • 低于LCL:环境混合比(或 saturation_mixing_ratio(dewpoint)
  • 在或高于LCL:饱和混合比(saturation_mixing_ratio(temperature)

因此,在 MetPy 的 cape_cin 计算中,这变为:

below_lcl = pressure > pressure_lcl
parcel_mixing_ratio = np.where(below_lcl, saturation_mixing_ratio(pressure, dewpoint),
                               saturation_mixing_ratio(pressure, temperature))
parcel_profile = virtual_temperature(parcel_profile, parcel_mixing_ratio)
英文:

We made the choice not to add the profile "corrected" using virtual temperature as a separate API function. If this is important to have, you are welcome to open a feature request over on GitHub.

To calculate the proper virtual temperature for the profile, you need to have the correct parcel water vapor mixing ratio. This consists of:

  • Below LCL: ambient mixing ratio (or saturation_mixing_ratio(dewpoint))
  • At or Above LCL: saturation mixing ratio (saturation_mixing_ratio(temperature))

So within MetPy's cape_cin calculation this becomes:

below_lcl = pressure > pressure_lcl
parcel_mixing_ratio = np.where(below_lcl, saturation_mixing_ratio(pressure, dewpoint),
                               saturation_mixing_ratio(pressure, temperature))
parcel_profile = virtual_temperature(parcel_profile, parcel_mixing_ratio)

huangapple
  • 本文由 发表于 2023年5月18日 09:20:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76277163.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定