爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 9616|回复: 0

[经验总结] python风玫瑰图

[复制链接]

新浪微博达人勋

发表于 2021-11-10 20:29:45 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

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)

Figure_1.png

shuju.xlsx

785.22 KB, 下载次数: 39, 下载积分: 金钱 -5

密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表