lair.air.circularize_radial_data#

lair.air.circularize_radial_data(agg)[source]#

Circularize radial data for polar plots.

The rows must be evenly spaced in theta and cover the full circle (e.g. all 16 sectors of sector_radians()); the first row is repeated one step past the last to close the circle.

Parameters:

agg (pd.DataFrame) – Aggregated data. Index is theta, columns are r.

Returns:

tuple[np.ndarray, np.ndarray, np.ndarray] – Theta, r, and c for polar

See also

bin_polar

Bins the data the aggregate comes from.

sector_radians

The theta values of the 16 sectors.

lair.plotter.polarPlot

Does this for a contour plot.

Examples

One value per sector (rows) and per speed (columns): the result has one more row, a copy of the first, so the plotted contour closes:

>>> import numpy as np
>>> import pandas as pd
>>> from lair.air import circularize_radial_data, sector_radians
>>> agg = pd.DataFrame(
...     np.arange(32).reshape(16, 2), index=sector_radians(), columns=[2.0, 4.0]
... )
>>> theta, r, c = circularize_radial_data(agg)
>>> c.shape
(17, 2)
>>> bool((c[-1] == c[0]).all())
True