Metpy:Quantity 对象及其大小都没有属性 'ax'

Metpy: Neither Quantity object nor its magnitude has attribute 'ax'

我正在处理一些相当大的数据,其中包含变量 tempdewptpressureu_windv_wind.

有数千天的数据,我找到了数据的几个百分位数,我正在寻找使用百分位数数据创建探测图。

找到百分位数并将每个变量的百分位数组合成每个百分位数的一个数据帧后,我最终得到如下所示的数据帧:

pressure temp dewpt
897 17 0
889 16 0
885 16 0
... ... ...

然后我使用metpy提供的标准高级探空代码:

T_50th = data_50th['temp'].values * units.degC
Td_50th = data_50th['dewpt'].values * units.degC
p_50th = data_50th['pressure'].values * units.hPa

fig = plt.figure(figsize=(9,9))
add_metpy_logo(fig, 115, 100)
skew = SkewT

skew.plot(p_50th, T_50th, 'r')
skew.plot(p_50th, Td_50th, 'g')
skew.ax.set_ylim(1000,10)
skew.ax.set_xlim(-50, 60)

但是,每当我尝试从 skew.plot 行开始 运行 时,我都会收到错误消息:

AttributeError: Neither Quantity object nor its magnitude ([bunch of numbers]) has attribute 'ax'

我试过让它工作,但我没有想法。关于如何解决此错误的任何建议?

我认为问题在于这一行:

skew = SkewT

不是在创建一个新的 SkewT 实例,而是使名称 skew 指向 SkewT class(有点像别名)。要创建新实例,您需要添加 ()。另外,如果你想让它使用你上面创建的 fig,你也需要传递它,所以我想你想要这个:

skew = SkewT(fig)