Meteorology 101: How To Plot Windrose

Dwikita Ichsana
5 min readMay 24, 2023

--

Well, Hello Friends!

This is the third post explaining about meteorology. In the first topic i explained about How To Download and Plot Meteorological Data from ERA5. Afterwards, the second topic explained about How To Plot Wind Map, which is still related from the first topic. So, if you missed the first and the second topics, you can check them out by clicking the link above or open up my medium profile!

Fig 1. Borger windrose from weather.com

So, what is windrose? Windrose is a diagram that shows wind condition, speed and direction over a period of time at specific location. Windrose is very useful in many and varied situations. In the aviation sector, the pilot needs the information of windrose for take off or land the aircraft. Besides that, in the wind energy sector, the information on windrose absolute must be available for the orientation of turbine placement and, of course, part of the study of wind characteristics on the site. But, how to create and read the windrose diagram?

To create the windrose, you can average wind direction and wind speed over a period time interval e.g. 1 day, 1 month, 3 month, or longer. For example, in Figure 1, the wind data that used to create windrose is from 01 Juli 1996–27 February 2023. Then, the wind data is sorted by wind direction so that the percentage of time that the wind was blowing from each direction can be determined. Typically the wind direction data is sorted into twelve equal arc segments, with 30° each segment, in preparation for plotting a circular graph in which the radius of each of the twelve segments represents the percentage of time that the wind blew from each of the twelve 30° direction segments[1].

Fig 2. Edited windrose from Fig 1

Then to read the windrose, first, you can match the windrose’s color toward the windrose’s color bar. For example, let’s use the wind blowing from the south in Figure 2. Note that the wind blowing is “from” that direction, not “toward” it. As you can see, the dark-red color shows a wind speed of 20+ mph, the orange color shows 15–19.9 mph, the yellow color shows 10–14.9 mph, and so on. Afterward, note on the spoke, there is a percentage on each radius. It defines how long the wind blew at different speeds. For example, let’s see the orange color. Let’s say the orange color starts from asmaller ring for like 4.5% and ends at a larger ring for like 5.75%. Then, subtract 4.5 from 5.75, and you get the percentage of time the wind blew at that speed and direction; 1.25 percent.

So, how to create the windrose plot?

PLOT THE WINDROSE

So, we will use the same data as before; ERA5.

Let’s open our jupyter notebook!

This is the library you have to declared.

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import xarray as xr
from windrose import WindroseAxes

For those of you who don’t have windrose library, you can install it using:

$ pip install windrose

Or install it in another way (read here for installing windrose library).

Next, open the ERA5 data.

data = xr.open_dataset('ERA5.nc')

Define the u-v component of wind as ‘wind_u’ and ‘wind_v’.

wind_u = data.u10
wind_v = data.v10

Then, calculate the wind speed by calculate the square root from the sum of ‘wind_u’ and ‘wind_v’.

WS = np.sqrt(wind_u**2 + wind_v**2)

Remember windrose diagram is formed by wind speed and wind direction. But, in this case, based on the data that we have, we don’t have wind direction variable; what we have is u-v component of wind. Then, how to get the direction variable?

From the second topic which is How To Plot Wind Map, it has been mentioned a little about how to calculate it, which is using arctan2 function. To make it easier to calculate it, we can create arctan2 function.

def wind_uv_to_dir(U,V):
"""
Calculates the wind direction from the u and v component of wind.
Takes into account the wind direction coordinates is different than the
trig unit circle coordinate. If the wind directin is 360 then returns zero
(by %360)
Inputs:
U = west/east direction (wind from the west is positive, from the east is negative)
V = south/noth direction (wind from the south is positive, from the north is negative)
"""
WDIR= (270-np.rad2deg(np.arctan2(V,U)))%360
return WDIR

By the way, i don’t own this function. Say thanks to Brian Blaylock to provide this function. You can check another function and script about meteorology in his Github here.

Then, let’s calculate the wind direction from that function.

wind_dir = wind_uv_to_dir(wind_u,wind_v)
Fig 3. Wind direction from calculation using arctan2 function

Note that the wind direction still has a dimensional coordinates. As we know, windrose is a diagram that shows wind condition, speed and direction over a period of time at a specific location. We have to choose a specific location first to be able to plot windrose. For example, i will choose the coordinate of Bandung, which is 6.75 S and 107.5 W. To find where those coordinates are in the coordinates variable, i will search using numpy.where feature.

Fig 4. Searching array using numpy.where

With that feature, we can easily find where the array contains the coordinates that we want to plot. Next, let’s get into the visualization of the windrose!

#Plot Wind Rose

new_labels = ["E", "N-E", "N", "N-W", "W", "S-W", "S", "S-E"]
ax = WindroseAxes.from_ax(theta_labels=new_labels)
ax.bar(wind_dir[:,87,70], WS[:,87,70], normed=True, bins=np.arange(0, 3.5, 0.5))
ax.set_legend(title = 'Wind Speed in m/s', loc='center right', bbox_to_anchor=(1.25,0.5))

Because the data that we used only have 24 data or hours in time dimension, we include them all in. Let’s just say it’s a diurnal cycle, for instance, but it’s only for 1 day hehe. Then, let’s call the windrose module, which is WindroseAxes (you can read the full documentation on using windrose module here), and set its labels. Define the labels here it’s very important because if you don’t set the labels, the direction of the windrose will be wrong. I don’t know why this function returns the wrong direction :(. Furthermore, you can adjust the bins or range of wind speed in order to suit your needs.

And there it is, the windrose!

Fig 5. Windrose of Bandung

I think that’s it. If you have a question you can ask here in the comment section or through my LinkedIn here. You can access my code and ERA5 data via my Github here. Hopefully this tutorial useful for you!

Thank’s for reading!

References:

  1. Windrose explained by Novalynx
  2. Borger windrose by weather.gov

--

--