python - 使用风数据的 Python Windrose - 不确定约定
问题描述
我正在对 ERA5 地表风数据进行一些统计。我已经使用 atan2(v,u) 下载了 u,v 分量和估计的风向,并将其转换为正度数。根据 ERA5 文档,正向是风向东和向北,分别为 u 和 v。
我使用 windrose.py 绘制了方向直方图和风玫瑰图。在源代码文档中,我看到以下内容:
- 方向:一维数组 - 风吹来的方向,以北为中心
- 吹奏:布尔。如果为真,windrose 将被 pi 旋转,以显示风吹向的位置(对污染玫瑰有用)。*
我已经运行了使用 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()
难道我做错了什么?
非常感谢,基亚拉
解决方案
推荐阅读
- java - 如何使用 Pageable 对嵌入实体的属性进行排序?
- powershell - Powershell 导入-csv
- powershell - jenkins powershell 插件 url 编码
- angular - 防止无效的电子邮件/密码提示
- html - 如何正确对齐 ng-repeat 复选框
- c# - 如何在不嵌入另一个 TextBlock 和使用属性设置器的情况下使 WPF TextBlock 文本的一部分变为粗体
- python - Python:如何将第二个函数的执行延迟一秒
- css - Bootstrap 4 分钟宽度的流体容器(更改响应行为)
- powershell - 用于检查 C:驱动器容量并写入 CSV 文件的 Powershell 脚本
- java - LocalDateTime 之间的差异