根据u,v分量绘制风速和风向

编程入门 行业动态 更新时间:2024-10-10 17:30:25
本文介绍了根据u,v分量绘制风速和风向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图绘制风速和风向,但是有一个错误代码不断告诉我序列太大;不能大于32."这是我正在使用的代码:

I'm trying to plot the wind speed and direction, but there is an error code that keeps telling me that "sequence too large; cannot be greater than 32." Here is the code that I am using:

N = 500 ws = np.array(u) wd = np.array(v) df = pd.DataFrame({'direction': [ws], 'speed': [wd]}) df direction speed 0 [[-7.87291, -8.19969, -8.41213, -8.42775, -8.4... [[-3.68055, -4.07912, -4.07992, -3.55594, -3.2... from windrose import plot_windrose N = 500 ws = np.random.random(u) * 6 wd = np.random.random(v) * 360 df = pd.DataFrame({'speed': ws, 'direction': wd}) plot_windrose(df, kind='contour', bins=np.arange(0.01,8,1), cmap=cm.hot, lw=3) ValueError Traceback (most recent call last) <ipython-input-78-dfb188ec377a> in <module>() 1 from windrose import plot_windrose 2 N = 500 3 ws = np.random.random(u) * 6 4 wd = np.random.random(v) * 360 5 df = pd.DataFrame({'speed': ws, 'direction': wd}) mtrand.pyx in mtrand.RandomState.random_sample (numpy\random\mtrand\mtrand.c:10396)() mtrand.pyx in mtrand.cont0_array (numpy\random\mtrand\mtrand.c:1865)() ValueError: sequence too large; cannot be greater than 32

如何解决此问题并绘制U和V?谢谢.

How do I fix this and plot the U and V? Thank you.

推荐答案

要绘制风U,V,请使用barbs和quiver.看下面的代码:

To plot wind U, V use barbs and quiver. Look at the code below:

import matplotlib.pylab as plt import numpy as np x = np.linspace(-5, 5, 5) X, Y = np.meshgrid(x, x) d = np.arctan(Y ** 2. - .25 * Y - X) U, V = 5 * np.cos(d), np.sin(d) # barbs plot ax1 = plt.subplot(1, 2, 1) ax1.barbs(X, Y, U, V) #quiver plot ax2 = plt.subplot(1, 2, 2) qui = ax2.quiver(X, Y, U, V) plt.quiverkey(qui, 0.9, 1.05, 1, '1 m/s',labelpos='E',fontproperties={'weight': 'bold'}) plt.show()

更多推荐

根据u,v分量绘制风速和风向

本文发布于:2023-11-22 02:17:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:风速   风向   分量

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!