Skip to content

Commit

Permalink
iss #317 added min_speed to plot ti by_speed
Browse files Browse the repository at this point in the history
  • Loading branch information
BiancaMorandi committed Jan 9, 2023
1 parent 09768f6 commit 90bb8e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion brightwind/analyse/analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,8 @@ class give as input a pandas.DataFrame having first column name as 'windspeed' a

ti_dist.index.rename('Speed Bin', inplace=True)
ti_dist.index = [i.mid for i in ti_dist.index]
graph_ti_dist_by_speed = bw_plt.plot_TI_by_speed(wspd, wspd_std, ti_dist, IEC_class=IEC_class)
graph_ti_dist_by_speed = bw_plt.plot_TI_by_speed(wspd, wspd_std, ti_dist, min_speed=min_speed,
IEC_class=IEC_class)

# replace index of ti_dist with input speed_bin_labels only after generating the plot
if speed_bin_labels:
Expand Down
12 changes: 9 additions & 3 deletions brightwind/analyse/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ def plot_rose_with_gradient(freq_table, percent_symbol=True, plot_bins=None, plo
return ax.get_figure()


def plot_TI_by_speed(wspd, wspd_std, ti, IEC_class=None):
def plot_TI_by_speed(wspd, wspd_std, ti, min_speed=3, IEC_class=None):
"""
Plot turbulence intensity graphs alongside with IEC standards
Expand All @@ -1412,6 +1412,8 @@ def plot_TI_by_speed(wspd, wspd_std, ti, IEC_class=None):
a pandas.DataFrame having first column name as 'windspeed' and other columns reporting the
results of applying the IEC class formula for a range of wind speeds. See format as shown in
example usage.
:param min_speed: Set the minimum wind speed. Default is 3 m/s.
:type min_speed: integer or float
:type IEC_class: None or pandas.DataFrame
:return: Plots scatter plot of turbulence intensity (TI) & distribution of TI by speed bins
derived as for statistics below and the IEC Class curves defined as for IEC_class input.
Expand All @@ -1429,6 +1431,10 @@ def plot_TI_by_speed(wspd, wspd_std, ti, IEC_class=None):
_ , ti_dist = bw.TI.by_speed(data.Spd80mN, data.Spd80mNStd, return_data=True)
bw.analyse.plot.plot_TI_by_speed(data.Spd80mN, data.Spd80mNStd, ti_dist, IEC_class=None)
# set min speed for plot
_ , ti_dist = bw.TI.by_speed(data.Spd80mN, data.Spd80mNStd, return_data=True)
bw.analyse.plot.plot_TI_by_speed(data.Spd80mN, data.Spd80mNStd, ti_dist, min_speed=0, IEC_class=None)
# Plot TI distribution by speed bins and give as input custom IEC_class pandas.DataFrame
IEC_class = pd.DataFrame({'windspeed': list(range(0,26)),
'IEC Class A': list(0.16 * (0.75 + (5.6 / np.array(range(0,26)))))}
Expand Down Expand Up @@ -1462,9 +1468,9 @@ def plot_TI_by_speed(wspd, wspd_std, ti, IEC_class=None):
ax.plot(IEC_class.iloc[:, 0], IEC_class.iloc[:, icol], color=COLOR_PALETTE.color_list[1+icol],
linestyle='dashed', label=IEC_class.columns[icol])

ax.set_xlim(3, 25)
ax.set_xlim(min_speed, 25)
ax.set_ylim(0, 0.6)
ax.set_xticks(np.arange(3, 26, 1))
ax.set_xticks(np.arange(min_speed, 26, 1))
ax.set_xlabel('Wind speed [m/s]')
ax.set_ylabel('Turbulence Intensity')
ax.grid(True)
Expand Down

0 comments on commit 90bb8e9

Please sign in to comment.