2

I've got wind data which includes wind speed and wind direction.

However, my wind direction is defined anti-clockwise. Meaning, 45 deg for my data is actually NW.

Is there any chance to change this using Windrose in Python?

I've got the following code to plot the Windrose:

from windrose import WindroseAxes
import matplotlib.pyplot as plt

theta = [0, 60, 120, 180, 240, 300]
speed = [10, 0, 10, 40, 50, 40]

ax = WindroseAxes.from_ax()
ax.bar(theta, speed)
plt.show()
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Kakemonster
  • 97
  • 2
  • 11
  • 1
    Your code example should be a complete MVP. It does not run as is, as imports and variable definitions are missing. To run it, I'm currently stuck as `cm.autumn`. What is it? – Dunatotatos Feb 12 '19 at 07:52

1 Answers1

0

The direction of your windrose is determined by the theta list. If 90° is not on the side you wish, you can convert all theta angles to the opposite and therefore create a mirror of your original image.

Let's imagine your original code is the following.

from windrose import WindroseAxes                                                                                                                                                                                                                                                                                                                                                                                                                                                            
import matplotlib.pyplot as plt                                                                                                                                                                                                                                                                                                                                                                                                                                                              

theta = [0, 90]                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
speed = [10, 10]                                                                                                                                                                                                                                                                                                                                                                                                                                                                             

ax = WindroseAxes.from_ax()                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
ax.bar(theta, speed)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
plt.show()

And this shows you a graph with a bar on the East, while you want it on the West (or the opposite).

If you take the opposite angle, you swap the graph. The following code would server your purpose.

from windrose import WindroseAxes
import matplotlib.pyplot as plt

theta = [0, 90]
theta = [360 - x for x in theta] # Take the opposite angle
speed = [10, 10]

ax = WindroseAxes.from_ax()
ax.bar(theta, speed)
plt.show()
Dunatotatos
  • 1,706
  • 15
  • 25
  • Hi, my theta data is not sorted from min to max. It could look something like theta = [240, -50, 60, 345, -15]. Thus, I did have to change the definition and it didn't help just swapping the theta around. – Kakemonster Feb 12 '19 at 08:40
  • Could you update your question with the actual definition of theta? I guess something like `theta = map(lambda x: 360-x, theta)` could work, if I understand well your goal. – Dunatotatos Feb 12 '19 at 10:55
  • Hi, unfortunately I can't post the data.. But it is defined as 0 deg is north and then counterclockwise. So 90 deg is W etc. The data is 28 000 data points which includes the wind speed and direction. – Kakemonster Feb 13 '19 at 06:50
  • OK, got it. Strange enough, on my installation without any modification. 90° is East. Anyway, I edit my answer to reflect the understanding I have of your problem. – Dunatotatos Feb 13 '19 at 08:28
  • Thanks for your help! I've got another question about windrose. Do you know why my radius-label is showing the wind speed and not the percentage? – Kakemonster Feb 13 '19 at 08:34
  • StackOverflow works on a system of unique question/answer. If you have another problem or question, I encourage you to submit a new question, and not use this one as a chat. I'll be sure to take a look at your next question, though ;) – Dunatotatos Feb 13 '19 at 08:42