Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions brightwind/analyse/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1921,7 +1921,7 @@ def plot_TI_by_sector(turbulence, wdir, ti):
return ax.get_figure()


def plot_shear_by_sector(scale_variable, wind_rose_data, calc_method='power_law'):
def plot_shear_by_sector(scale_variable, wind_rose_data, calc_method='power_law', direction_bin_array=None):
"""
Plot shear by directional sectors and wind rose.

Expand Down Expand Up @@ -1974,9 +1974,19 @@ def plot_shear_by_sector(scale_variable, wind_rose_data, calc_method='power_law'
ax.set_theta_direction(-1)
bin_edges = pd.Series([], dtype='float64')
for i in range(sectors):
bin_edges[i] = float(re.findall(r"[-+]?\d*\.\d+|\d+", wind_rose_data.index[i])[0])
if i == sectors - 1:
bin_edges[i + 1] = abs(float(re.findall(r"[-+]?\d*\.\d+|\d+", wind_rose_data.index[i])[1]))
nums = re.findall(r"[-+]?\d*\.\d+|\d+", wind_rose_data.index[i])
if len(nums) >= 2:
bin_edges[i] = float(nums[0])
if i == sectors - 1:
bin_edges[i + 1] = abs(float(nums[1]))
elif direction_bin_array is not None:
bin_edges[i] = float(direction_bin_array[i])
if i == sectors - 1:
bin_edges[i + 1] = abs(float(direction_bin_array[i + 1]))
else:
raise ValueError(f"Cannot parse bin edge from label '{wind_rose_data.index[i]}'. "
"Please pass direction_bin_array to plot_shear_by_sector or use "
"numeric direction_bin_labels.")
label = ''
if calc_method == 'power_law':
label = 'Mean_Shear'
Expand Down
4 changes: 2 additions & 2 deletions brightwind/analyse/shear.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ def __init__(self, wspds, heights, wdir, min_speed=3, calc_method='power_law', s
self._alpha = pd.Series(alpha, name='alpha')
clear_output()
self.plot = bw_plt.plot_shear_by_sector(scale_variable=alpha, wind_rose_data=wind_rose_dist,
calc_method=calc_method)
calc_method=calc_method, direction_bin_array=direction_bin_array)

elif calc_method == 'log_law':

Expand All @@ -688,7 +688,7 @@ def __init__(self, wspds, heights, wdir, min_speed=3, calc_method='power_law', s
self._roughness = pd.Series(roughness, name='roughness_coefficient')
clear_output()
self.plot = bw_plt.plot_shear_by_sector(scale_variable=roughness, wind_rose_data=wind_rose_dist,
calc_method=calc_method)
calc_method=calc_method, direction_bin_array=direction_bin_array)

else:
raise ValueError("Please enter a valid calculation method, either 'power_law' or 'log_law'.")
Expand Down