After compiling and running successfully WRF + MCIP, I have data of Wind_Speed and Wind_Direction which is save in a dataframe like this:
column_names = ['Wind_Direction', 'Wind_Speed', 'Velocidad_x', 'Velocidad_y']
df = pd.DataFrame(columns = column_names)
for index in range(Wind_Direction.size):
value = []; value.append(Wind_Direction[index]); value.append(Wind_Speed[index])
value.append(Wind_Speed[index] * np.sin(Wind_Direction[index]*pi/180.0))
value.append(Wind_Speed[index] * np.cos(Wind_Direction[index]*pi/180.0))
df.loc[index] = value
After that I plot the wind rose base on data in my dataframe. Example code:
colors = ['darkgreen', 'green', 'blue', 'yellow', 'orange', 'red']
cmap = LinearSegmentedColormap.from_list("Custom", colors)
ax = WindroseAxes.from_ax()
ax.bar(df['Wind_Direction'], df['Wind_Speed'], nsector=36, normed=True, blowto=False, opening=1.0, edgecolor='white', cmap=cmap, bins=np.arange(0, 3.5, 0.5))
ax.set_legend()
plt.savefig(f'F:/Wind_Vector/Wind_Blow_From/Wind_Rose.png')
plt.close('all')
ax = WindroseAxes.from_ax()
ax.bar(df['Wind_Direction'], df['Wind_Speed'], nsector=36, normed=True, blowto=True, opening=1.0, edgecolor='white', cmap=cmap, bins=np.arange(0, 3.5, 0.5))
ax.set_legend()
plt.savefig(f'F:/Wind_Vector/Wind_Blow_To/Wind_Rose.png')
plt.close('all')
What I actually got
Picture of my wind rose
But the thing is I don’t want the bins that divide like this
bins=np.arange(0, 3.5, 0.5)
What I want is to divide like this picture:
Picture of bins width
So I have try to change the bins=np.array(0, 0.5, 2.10, 3.60, 5.70, 8.80, 11.10)
but then the traceback error appear:
Traceback (most recent call last):
File "E:MeteorologyWind_Rose.py", line 48, in <module>
ax.bar(df['Wind_Direction'], df['Wind_Speed'], nsector=36, normed=True, blowto=False, opening=0.8,
edgecolor='white', cmap=cmap, bins=np.array(0, 0.5, 2.10, 3.60, 5.70, 8.80, 11.10))
TypeError: array() takes from 1 to 2 positional arguments but 7 were given
I have try to search many webs and this website fits me
https://windrose.xyz/
But it don’t have any source code so I frustrated and don’t know how to solve.
Bình Phạm Quốc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.