在 skewT metpy 中添加跨所有压力的混合线

adding mixing lines across all pressures in skewT metpy

我可以绘制一个标准的 SkewT 图表,混合线最高可达 p=600hPa,使用默认调用 plot_mixing_lines() 但我想将它们扩展到对流层上层。我尝试执行以下操作:

import matplotlib.pyplot as plt
from metpy.plots import SkewT
from metpy.units import units

fig=plt.figure(figsize=(9, 9))
skew=SkewT(fig)
skew.plot_moist_adiabats()
plevs=[ '1', '2', '3',
            '5', '7', '10',
            '20', '30', '50',
            '70', '100', '125',
            '150', '175', '200',
            '225', '250', '300',
            '350', '400', '450',
            '500', '550', '600',
            '650', '700', '750',
            '775', '800', '825',
            '850', '875', '900',
            '925', '950', '975',
            '1000']
plevs = units.Quantity(plevs,"hPa")
skew.plot_mixing_lines(pressure=plevs)

但因错误而失败:

~/Library/Python/3.9/lib/python/site-packages/pint/quantity.py in _mul_div(self, other, magnitude_op, units_op)
   1285                 return NotImplemented
   1286 
-> 1287             magnitude = magnitude_op(self._magnitude, other_magnitude)
   1288             units = units_op(self._units, self.UnitsContainer())
   1289 

UFuncTypeError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U4'), dtype('float64')) -> None

我在网上找到的所有示例用法要么没有混合线,要么使用默认值。我在做傻事吗?

现在在 metpy 1.1 上,python 3.9.9 在 Clang 13.0.0 上,并将 matplotllib 回滚到 3.4

这里的问题是 plevs 中的所有值都是字符串而不是值。我用 plevs = list(map(int, plevs)) 解决了这个问题,但您可能会发现更容易尝试:

import numpy as np
plevs = np.logspace(0, 3, 100)

这会给你 100 个点,在 1 (10^0) 和 1000 (10^3)​​ 之间按对数间隔。