lair.air.bin_polar#
- lair.air.bin_polar(data, x='ws', wd='wd', xbins=30)[source]#
Bin data into polar coordinates.
- Parameters:
data (pd.DataFrame) – Data to bin.
x (str, optional) – Variable to bin. Default is ‘ws’.
wd (str, optional) – Wind direction column name. Default is ‘wd’.
xbins (int | list, optional) – Bin edges for x. An int is the number of evenly spaced edges from the minimum to the maximum of x (so
xbins - 1bins); a list gives the edges explicitly. Default is 30.
- Returns:
pd.DataFrame – A copy of
datawith binned wind direction and speed added aswd_bin(compass sector),radian_binandx_bin. The caller’s frame is not modified.- Return type:
See also
WIND_SECTORSThe sectors.
sector_radiansThe sectors in radians, the
radian_binvalues.circularize_radial_dataCloses the circle of the aggregated bins for a plot.
lair.plotter.polarPlotDraws the binned data.
Examples
A wind at 350 and one at 10 degrees are both in the N sector; the speed is put in the bin whose upper edge is given:
>>> import pandas as pd >>> from lair.air import bin_polar >>> df = pd.DataFrame({"ws": [1.0, 2.5, 4.0], "wd": [350.0, 10.0, 95.0]}) >>> binned = bin_polar(df, xbins=[0, 2, 4]) >>> binned[["wd_bin", "x_bin"]].astype(str) wd_bin x_bin 0 N 2 1 N 4 2 E 4