Skip to content

Commit

Permalink
[BUGFIX] Fix wind rose plots (#930)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulf81 authored Jun 25, 2024
1 parent 01115bf commit 236e60b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions floris/wind_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,11 @@ def plot(

# Get the wd_step
if wd_step is None:
wd_step = wd_bins[1] - wd_bins[0]
if len(wd_bins) >= 2:
wd_step = wd_bins[1] - wd_bins[0]
else:
# This admittedly an odd edge case
wd_step = 360.0

# Get a color array
color_array = plt.get_cmap(color_map, len(ws_bins))
Expand All @@ -619,7 +623,7 @@ def plot(
rects = []
freq_table_sub = freq_table[wd_idx, :].flatten()
for ws_idx, ws in reversed(list(enumerate(ws_bins))):
plot_val = freq_table_sub[:ws_idx].sum()
plot_val = freq_table_sub[:ws_idx + 1].sum()
rects.append(
ax.bar(
np.radians(wd),
Expand Down Expand Up @@ -1453,7 +1457,7 @@ def plot(
color_map="viridis_r",
wd_step=15.0,
wind_rose_var_step=None,
legend_kwargs={},
legend_kwargs={"title": "Wind speed [m/s]"},
):
"""
This method creates a wind rose plot showing the frequency of occurrence
Expand All @@ -1480,7 +1484,7 @@ def plot(
will be used if wind_rose_var = "ws", and a value of 4% will be
used if wind_rose_var = "ti".
legend_kwargs (dict, optional): Keyword arguments to be passed to
ax.legend().
ax.legend(). Defaults to {"title": "Wind speed [m/s]"}.
Returns:
:py:class:`matplotlib.pyplot.axes`: A figure axes object containing
Expand Down Expand Up @@ -1519,7 +1523,7 @@ def plot(
rects = []
freq_table_sub = freq_table[wd_idx, :].flatten()
for var_idx, ws in reversed(list(enumerate(var_bins))):
plot_val = freq_table_sub[:var_idx].sum()
plot_val = freq_table_sub[:var_idx + 1].sum()
rects.append(
ax.bar(
np.radians(wd),
Expand Down

0 comments on commit 236e60b

Please sign in to comment.