Metpy:数量对象和其大小都没有属性' ax'

发布于 2025-01-24 00:09:24 字数 1295 浏览 2 评论 0原文

我正在使用一些可大的数据,带有变量tempdewpt压力u_windv_wind

有数千天的数据,我发现了几个数据的数据,并希望使用百分位数据创建声图。

结束了看起来像这样的数据框架:

压力温度
897170
889160
885160
...在找到百分位数并将每个变量的百分位数组合到每个百分位数的

一个数据范围之后,我 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:bentibuteError:code> notity otterity botect oft量对象或其幅度([[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[一堆数字])具有属性的“ ax”

我尝试使它起作用,但没有想法。关于如何解决此错误的任何建议?

I'm working with some sizeable data, with variables temp, dewpt, pressure, u_wind, and v_wind.

There are thousands of days of data, and I found several percentiles of the data, and am looking to create sounding plots using the percentile data.

After finding the percentiles and combining each variable's percentile into one dataframe for each percentile, I wind up with dataframes that look like this:

pressuretempdewpt
897170
889160
885160
.........

I then use the standard advanced sounding code provided by 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)

However, whenever I try to run from the skew.plot lines and on, I get the error:

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

I've tried getting it to work, but am out of ideas. Any suggestions on how to get around this error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兮颜 2025-01-31 00:09:24

我认为问题是这一行:

skew = SkewT

不是创建新的skewt实例,它正在制作名称skew指向skewt class(有点像别名)。要创建一个新实例,您需要添加()。另外,如果您希望它使用上面创建的fig,您也需要通过它,因此我认为您需要这样做:

skew = SkewT(fig)

I think the problem is that this line:

skew = SkewT

isn't creating a new SkewT instance, it's making the name skew point to the SkewT class (kinda like an alias). To create a new instance, you need to add (). Also, if you want it to use the fig you created above, you need to pass that as well, so I think you want this:

skew = SkewT(fig)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文