brightwind.analyse.analyse.freq_table¶
-
brightwind.analyse.analyse.
freq_table
(var_series, direction_series, var_bin_array=array([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 30.5, 31.5, 32.5, 33.5, 34.5, 35.5, 36.5, 37.5, 38.5, 39.5, 40.5]), var_bin_labels=None, sectors=12, direction_bin_array=None, direction_bin_labels=None, freq_as_percentage=True, plot_bins=None, plot_labels=None, return_data=False)¶ Accepts a variable series and direction series and computes a frequency table of percentages. Both variable and direction are binned
- Parameters
var_series (pandas.Series) – Series of variable to be binned
direction_series (pandas.Series) – Series of wind directions between [0-360]
var_bin_array (list) – List of numbers where adjacent elements of array form a bin. For instance, for bins [0,3),[3,8),[8,10) the list will be [0, 3, 8, 10]. By default it is [-0.5, 0.5), [0.5, 1.5], …., [39.5, 40.5)
var_bin_labels (list) – Optional, an array of labels to use for variable bins
sectors (int) – Number of sectors to bin direction to. The first sector is centered at 0 by default. To change that behaviour specify direction_bin_array, it overwrites sectors
direction_bin_array (list) – To add custom bins for direction sectors, overwrites sectors. For instance, for direction bins [0,120), [120, 215), [215, 360) the list would be [0, 120, 215, 360]
direction_bin_labels (list(float), list(str)) – Optional, you can specify an array of labels to be used for the bins. uses string labels of the format ‘30-90’ by default
freq_as_percentage (bool) – Optional, True by default. Returns the frequency as percentages. To return just the count, set to False
return_data (bool) – Set to True if you want to return the frequency table too.
plot_bins (list) – Bins to use for gradient in the rose. Different bins will be plotted with different color. Chooses six bins to plot by default ‘0-3 m/s’, ‘4-6 m/s’, ‘7-9 m/s’, ‘10-12 m/s’, ‘13-15 m/s’ and ‘15+ m/s’. If you change var_bin_array this should be changed in accordance with it.
plot_labels (list(str), list(float)) – (Optional) Labels to use for different colors in the rose. By default chooses the end points of bin
- Returns
A wind rose plot with gradients in the rose. Also returns a frequency table if return_data is True
- Return type
plot or tuple(plot, pandas.DataFrame)
Example usage
import brightwind as bw df = bw.load_campbell_scientific(bw.datasets.demo_campbell_scientific_site_data) #Simple use rose, freq_table = bw.freq_table(df.Spd40mN, df.Dir38mS, return_data=True) #To use 3 bins for wind speed [0,8), [8, 14), [14, 41) and label them as ['low', 'mid', 'high']. Can be used for #variabes other than wind speed too rose, freq_table = bw.freq_table(df.Spd40mN, df.Dir38mS, var_bin_array=[0,8,14,41], var_bin_labels=['low', 'mid', 'high'], plot_bins=[0,8,14,41], return_data=True) #Use custom direction bins rose, freq_table = bw.freq_table(df.Spd40mN, df.Dir38mS, direction_bin_array=[0,90,130,200,360], direction_bin_labels=['northerly','easterly','southerly','westerly'], return_data=True) #Can also combine custom direction and variable_bins rose, tab = bw.freq_table(df.Spd40mN, df.Dir38mS, direction_bin_array=[0,90,130,200,360], direction_bin_labels=['northerly','easterly','southerly','westerly'], plot_bins=None, plot_labels=None, return_data=True)