首页 > 解决方案 > 使用风数据的 Python Windrose - 不确定约定

问题描述

我正在对 ERA5 地表风数据进行一些统计。我已经使用 atan2(v,u) 下载了 u,v 分量和估计的风向,并将其转换为正度数。根据 ERA5 文档,正向是风向东和向北,分别为 u 和 v。

我使用 windrose.py 绘制了方向直方图和风玫瑰图。在源代码文档中,我看到以下内容:

我已经运行了使用 ERA5 约定传递数据的代码,所以风吹到哪里去了。鉴于默认的 blowto 默认为 False,直方图和风玫瑰图应该给出相同的结果。然后我应该获得直方图和风吹向方向的风玫瑰图(即程序不应该在角度上增加 180)。然而,windrose 相对于直方图旋转了 180 度。

这是代码的摘录。csvdata 是一个 numpy 数据框:

from windrose import WindroseAxes
import matplotlib.pyplot as plt

# print windrose for long-term data
u = csvdata['u']
v = csvdata['v']
speed = np.sqrt(u*u + v*v)
direction = np.degrees(np.arctan2(v, u)) 
direction %= 360 # turn all degrees to positive but don't loose direction
speed = speed.tolist()
direction = direction.tolist()
print (len(speed))
print (len(direction))

# windrose
ax = WindroseAxes.from_ax()
ax.box(direction, speed, bins=np.arange(0, max(speed), 1))
ax.set_legend()
ax.figure.savefig('windrose_longterm_{}.png'.format(point_string))
plt.clf()

# histogram direction
count, bins, patches = plt.hist(x=direction, bins='auto', alpha=0.7, rwidth=0.85)
maxfreq = count.max()
plt.ylim(ymax=np.ceil(maxfreq / 10) * 10 if maxfreq % 10 else maxfreq + 10)
plt.xlabel('Direction (Degrees)')
plt.ylabel('Frequency')
plt.title('Direction histogram for the entire dataset')
plt.savefig('histdir_longterm_{}.png'.format(point_string))
plt.clf()

难道我做错了什么?

非常感谢,基亚拉

标签: pythonmatplotlibhistogramwindrose

解决方案


推荐阅读