Wind Data

Wind speed conversion

WindKit makes it easy to convert wind speed (magnitude) and direction to wind velocity vectors (U and V components) and vice versa.

In [1]: import numpy as np

In [2]: import windkit as wk

In [3]: ws = np.array([5, 10, 15])  # Wind speed in m/s

In [4]: wd = np.array([0, 45, 225])  # Wind direction in degrees

In [5]: u, v = wk.wind_vectors(ws, wd)

We can visualize the wind vectors using matplotlib:

In [6]: import matplotlib.pyplot as plt

In [7]: fig, ax = plt.subplots()

In [8]: ax.plot([0, u[0]], [0, v[0]], marker="o")
Out[8]: [<matplotlib.lines.Line2D at 0x7d7ab1c1c050>]

In [9]: ax.plot([0, u[1]], [0, v[1]], marker="o")
Out[9]: [<matplotlib.lines.Line2D at 0x7d7ab1c1c190>]

In [10]: ax.plot([0, u[2]], [0, v[2]], marker="o")
Out[10]: [<matplotlib.lines.Line2D at 0x7d7ab1c1c2d0>]
../_images/wind_vectors.png

Converting back to wind speed and direction.

In [11]: ws_converted, wd_converted = wk.wind_speed_and_direction(u, v)

In [12]: print(np.allclose(ws, ws_converted))
True

In [13]: print(np.allclose(wd, wd_converted))
True