Example: WindRoseWRG

Example: WindRoseWRG#

"""Example: WindRoseWRG

`WindRoseWRG` is a type of WindData object, like `WindRose` and `TimeSeries`, that
is used to store wind data in a format that can be used by the FLORIS model.  `WindRoseWRG`
is different that `WindRose` however because the internal data holds the information
of the WRG file and then a `WindRose` object is created for each turbine in a provided
layout.

In this example the WRG file generated in the previous example is read in
using the `WindRoseWRG` object, and wind roses as points on the WRG grid, as will
as in-between interpolated points have wind roses calculated using the `get_wind_rose_at_point`
method.  Finally, the wind roses are upsampled to 5 degree wind direction bins and plotted.

"""
import matplotlib.pyplot as plt
import numpy as np

from floris import WindRoseWRG


# Read the WRG file
wind_rose_wrg = WindRoseWRG("wrg_example.wrg")

# Print some basic information
print(wind_rose_wrg)

# The wind roses were set to have a higher concentration of faster north winds for
# increasing y, show that this is contained within the wind roses, even those interpolated
# between grid points
y_points_to_test = np.array([0, 500, 1000, 1500, 2000])

fig, axarr = plt.subplots(1, 5, figsize=(16, 5), subplot_kw={"polar": True})

for i in range(5):
    wind_rose = wind_rose_wrg.get_wind_rose_at_point(0, y_points_to_test[i])
    wind_rose.plot(ax=axarr[i], ws_step=5)
    if i %2 == 0:
        axarr[i].set_title(f"y = {y_points_to_test[i]}")
    else:
        axarr[i].set_title(f"y = {y_points_to_test[i]}\n(Interpolated)")

# Go through the axarr and delete the legends except for the middle
for ax in [axarr[0], axarr[1], axarr[3], axarr[4]]:
    ax.legend().set_visible(False)


# Draw a horizontal line on each axis indicating the level of the lower wind speed
# bucket for the north wind from the first wind rose
for i in range(5):
    axarr[i].axhline(y=0.036, color="red", alpha=0.5)

fig.suptitle("Wind Roses at locations with increasing y.  Note the location where the 5 m/s bin \
transitions to 10 m/s for north wind at y = 0 is \nindicated by the red line to show \
the increase in wind speed to the north as y increases.")

# Since wind directions was not specified, the wind directions implied by the number of sectors
# in the WRG was used, however the wind directions can be set using the set_wind_directions method
# or passed in at initialization.  Here we upsample from 12, 30-deg sectors, to 72 5-deg sectors
wind_rose_wrg.set_wd_step(5.0)

fig, axarr = plt.subplots(1, 5, figsize=(16, 5), subplot_kw={"polar": True})

for i in range(5):
    wind_rose = wind_rose_wrg.get_wind_rose_at_point(0, y_points_to_test[i])
    wind_rose.plot(ax=axarr[i], ws_step=5)
    if i %2 == 0:
        axarr[i].set_title(f"y = {y_points_to_test[i]}")
    else:
        axarr[i].set_title(f"y = {y_points_to_test[i]}\n(Interpolated)")

# Go through the axarr and delete all the legends except for the middle
for ax in axarr:
    ax.legend().set_visible(False)

fig.suptitle('Wind roses with upsampling to 5-deg bins')

plt.show()
import warnings
warnings.filterwarnings('ignore')
WindResourceGrid with 2 x 3 grid points, min x: 0.0, min y: 0.0, grid size: 1000.0, z: 0.0, h: 90.0, 12 sectors
Wind directions in file: [  0.  30.  60.  90. 120. 150. 180. 210. 240. 270. 300. 330.]
Wind directions: [  0.  30.  60.  90. 120. 150. 180. 210. 240. 270. 300. 330.]
Wind speeds: [ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9. 10. 11. 12. 13. 14. 15. 16. 17.
 18. 19. 20. 21. 22. 23. 24. 25.]
ti_table: 0.06
/home/runner/work/floris/floris/floris/wind_data.py:2952: RuntimeWarning: invalid value encountered in power
  exponent = -((x / a) ** k)
/home/runner/work/floris/floris/floris/wind_data.py:2952: RuntimeWarning: invalid value encountered in power
  exponent = -((x / a) ** k)
/home/runner/work/floris/floris/floris/wind_data.py:2952: RuntimeWarning: invalid value encountered in power
  exponent = -((x / a) ** k)
/home/runner/work/floris/floris/floris/wind_data.py:2952: RuntimeWarning: invalid value encountered in power
  exponent = -((x / a) ** k)
/home/runner/work/floris/floris/floris/wind_data.py:2952: RuntimeWarning: invalid value encountered in power
  exponent = -((x / a) ** k)
/tmp/ipykernel_4727/3152068732.py:44: UserWarning: No artists with labels found to put in legend.  Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
  ax.legend().set_visible(False)
/home/runner/work/floris/floris/floris/wind_data.py:2952: RuntimeWarning: invalid value encountered in power
  exponent = -((x / a) ** k)
/home/runner/work/floris/floris/floris/wind_data.py:2952: RuntimeWarning: invalid value encountered in power
  exponent = -((x / a) ** k)
/home/runner/work/floris/floris/floris/wind_data.py:2952: RuntimeWarning: invalid value encountered in power
  exponent = -((x / a) ** k)
/home/runner/work/floris/floris/floris/wind_data.py:2952: RuntimeWarning: invalid value encountered in power
  exponent = -((x / a) ** k)
/home/runner/work/floris/floris/floris/wind_data.py:2952: RuntimeWarning: invalid value encountered in power
  exponent = -((x / a) ** k)
/tmp/ipykernel_4727/3152068732.py:73: UserWarning: No artists with labels found to put in legend.  Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
  ax.legend().set_visible(False)
../../_images/57df50880732fc2cd274636b07543eec527a2ae3706f01524bd86ae9048af290.png ../../_images/b305a2913e8c3ff88af1bd1acf71706a19ca8b224ec570f936af7b5f96d015c0.png