立即注册 登录
气象家园 返回首页

49784909的个人空间 http://bbs.06climate.com/?65271 [收藏] [复制] [分享] [RSS]

日志

Python风向风速计算uv

已有 159 次阅读2021-3-30 15:28 |个人分类:python

#def u(x, y):
#     if x<=90:
#         uwnd=y*np.sin(x*np.pi/180)
#     if x>90 and x<=180:
#         uwnd=y*np.sin((180-x)*np.pi/180)
#     if x>180 and x<=270:
#         uwnd=-y*np.sin((x-180)*np.pi/180)
#     if x>270 and x<=360:
#         uwnd=-y*np.sin((360-x)*np.pi/180)
#     return (uwnd)
#def v(x, y):
#     if x<=90:
#         vwnd=y*np.cos(x*np.pi/180)
#     if x>90 and x<=180:
#         vwnd=-y*np.cos((180-x)*np.pi/180)
#     if x>180 and x<=270:
#         vwnd=-y*np.cos((x-180)*np.pi/180)
#     if x>270 and x<=360:
#         vwnd=y*np.cos((360-x)*np.pi/180)
#     return (vwnd)
#df['u'] = df.apply(lambda x: u(x.direction, x.speed), axis = 1)  
#df['v'] = df.apply(lambda x: v(x.direction, x.speed), axis = 1)    

                           或者
df['u'] = df.apply(lambda x: x['speed'] *math.sin((180-x['direction'])*np.pi/180), axis=1) 
df['v'] = df.apply(lambda x: x['speed'] *math.cos( x['direction']*np.pi/180), axis=1) 

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

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

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

返回顶部