I'm doing some statistics on ERA5 surface wind data. I've downloaded the u,v components and estimated wind direction using atan2(v,u) and converting it to positive degrees. Based on the ERA5 documentation, the positive direction is for wind blowing towards East and North, respectively for u and v.
I've plotted direction histograms and windroses using windrose.py. In the source code documentation, I see the following:
- direction : 1D array - directions the wind blows from, North centred
- blowto : bool. If True, the windrose will be pi rotated, to show where the wind blow to (usefull for pollutant rose).*
I've run the code passing the data with the ERA5 conventions, so where the wind blows to. Given that default blowto defaults to False, the histogram and the windrose should give the same results. I should then obtain the histogram and windroses in the direction the wind blows to (i.e. the program should not add 180 to the angles). However, the windrose is turned of 180 degrees with respect to the histogram.
Here's an excerpt of the code. csvdata is a numpy dataframe:
from windrose import WindroseAxes
import matplotlib.pyplot as plt
# print windrose for long-term data
u = csvdata['u']
v = csvdata['v']
speed = np.sqrt(u*u + v*v)
direction = np.degrees(np.arctan2(v, u))
direction %= 360 # turn all degrees to positive but don't loose direction
speed = speed.tolist()
direction = direction.tolist()
print (len(speed))
print (len(direction))
# windrose
ax = WindroseAxes.from_ax()
ax.box(direction, speed, bins=np.arange(0, max(speed), 1))
ax.set_legend()
ax.figure.savefig('windrose_longterm_{}.png'.format(point_string))
plt.clf()
# histogram direction
count, bins, patches = plt.hist(x=direction, bins='auto', alpha=0.7, rwidth=0.85)
maxfreq = count.max()
plt.ylim(ymax=np.ceil(maxfreq / 10) * 10 if maxfreq % 10 else maxfreq + 10)
plt.xlabel('Direction (Degrees)')
plt.ylabel('Frequency')
plt.title('Direction histogram for the entire dataset')
plt.savefig('histdir_longterm_{}.png'.format(point_string))
plt.clf()
Am I doing something wrong?