Skip to content

Commit

Permalink
Merge pull request #318 from rcjackson/wind_rose_calm
Browse files Browse the repository at this point in the history
ADD: Percent calm to wind rose.
  • Loading branch information
jhemedin authored Apr 30, 2021
2 parents c57fb55 + e77ed28 commit f0ea82a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions act/plotting/WindRoseDisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def set_rrng(self, rrng, subplot_index=(0,)):
def plot(self, dir_field, spd_field, dsname=None, subplot_index=(0,),
cmap=None, set_title=None, num_dirs=20, spd_bins=None,
tick_interval=3, legend_loc=0, legend_bbox=None, legend_title=None,
calm_threshold=1.,
**kwargs):
"""
Makes the wind rose plot from the given dataset.
Expand Down Expand Up @@ -114,6 +115,8 @@ def plot(self, dir_field, spd_field, dsname=None, subplot_index=(0,),
Legend bounding box coordinates
legend_title : string
Legend title
calm_threshold : float
Winds below this threshold are considered to be calm.
**kwargs : keyword arguments
Additional keyword arguments will be passed into :func:plt.bar
Expand Down Expand Up @@ -200,6 +203,11 @@ def plot(self, dir_field, spd_field, dsname=None, subplot_index=(0,),
self.axes[subplot_index].set_theta_zero_location("N")
self.axes[subplot_index].set_theta_direction(-1)

# Add an annulus with text stating % of time calm
pct_calm = np.sum(spd_data <= calm_threshold) / len(spd_data) * 100
self.axes[subplot_index].set_rorigin(-2.5)
self.axes[subplot_index].annotate("%3.2f%%\n calm" % pct_calm, xy=(0, -2.5), ha='center', va='center')

# Set the ticks to be nice numbers
tick_max = tick_interval * round(
np.nanmax(np.cumsum(wind_hist, axis=1)) / tick_interval)
Expand Down
Binary file modified act/tests/baseline/test_wind_rose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion act/tests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_get_ord():
assert "ORD" in my_asoses.keys()
assert np.all(
np.equal(my_asoses["ORD"]["sknt"].values[:10],
np.array([13., 11., 11., 11., 9., 10., 10., 11., 11., 11.])))
np.array([13., 11., 14., 14., 13., 11., 14., 13., 13., 13.])))


def test_get_region():
Expand Down

0 comments on commit f0ea82a

Please sign in to comment.