Metpy:数量对象和其大小都没有属性' ax'
我正在使用一些可大的数据,带有变量temp
,dewpt
,压力
,u_wind
和v_wind
。
有数千天的数据,我发现了几个数据的数据,并希望使用百分位数据创建声图。
结束了看起来像这样的数据框架:
压力 | 温度 | 露 |
---|---|---|
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: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:
pressure | temp | dewpt |
---|---|---|
897 | 17 | 0 |
889 | 16 | 0 |
885 | 16 | 0 |
... | ... | ... |
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题是这一行:
不是创建新的
skewt
实例,它正在制作名称skew
指向skewt
class(有点像别名)。要创建一个新实例,您需要添加()
。另外,如果您希望它使用上面创建的fig
,您也需要通过它,因此我认为您需要这样做:I think the problem is that this line:
isn't creating a new
SkewT
instance, it's making the nameskew
point to theSkewT
class (kinda like an alias). To create a new instance, you need to add()
. Also, if you want it to use thefig
you created above, you need to pass that as well, so I think you want this: