- 积分
- 3995
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-3-4
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
from windrose import WindroseAxes
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
import pandas as pd
df = pd.read_excel('E:/shuju.xlsx')
def wind_direction_change(wd):
wind_direction = np.array(wd)
wind_direction[np.where((wind_direction >= 0)&(wind_direction <= 135))[0]] = 90 - wind_direction[np.where((wind_direction >= 0)&(wind_direction <= 135))[0]]
wind_direction[np.where((wind_direction >= 315)&(wind_direction < 360))[0]] = 90 - wind_direction[np.where((wind_direction >= 315)&(wind_direction < 360))[0]]
wind_direction[np.where((wind_direction > 135)&(wind_direction < 315))[0]] = 450 - wind_direction[np.where((wind_direction > 135)&(wind_direction < 315))[0]]
wind_direction[np.where(wind_direction < 0)[0]] = 360 + wind_direction[np.where(wind_direction < 0)[0]]
return wind_direction
def drow_windrose(wd, ws):
axes = WindroseAxes.from_ax()
wd_new = wind_direction_change(wd)
axes.bar(wd_new, ws, normed=True, opening=0.8, edgecolor='#b5b5c8', cmap = cm.get_cmap(name='bwr'))#画图
axes.set_theta_zero_location('N')
axes.set_theta_direction(-1)
axes.set_legend()
plt.show()
# wind_speed = [6,4,4,3,4,2,6,1,1,2,1,2,1,2,1,1,1,1,0,0,0,1,0,1]
# wind_direction = [340,110,90,110,180,130,350,30,230,260,240,240,230,210,200,250,250,230,100,100,240,100,230,250]
wind_speed = df['最大风速']
wind_direction = df['最大风速风向']
drow_windrose(wind_direction, wind_speed)
|
|