Polar plots

Module for polar plots

This module collects all functions necessary for polar plots, ranging from the gridding for angles and wind speeds into an array (NX2.polar.grid()) to the plotting (NX2.polar.plot()). This also includes some of the filters that are mainly used for polar plots (e.g. NX2.polar.sail()).

NX2.polar.grid(angle, wind, bsp, speedbins, anglebins, fig=None)

Plot a grid of data in bins according to wind angle and wind speed.

The makes a grid of plots showing the distribution of the BSP in each angle and wind bin.

Parameters:
  • angle (np.ndarry) – Wind angles in degrees
  • wind (np.ndarray) – wind speed in kn
  • bsp (np.ndarray) – Boat speed in kn
  • speedbins (ndarray) – bin boundaries for speed binning
  • anglebins (ndarray) – bin boundaries for angle binning. Make sure that 180. is included in last bin and not on the boundary.
  • fig (matplotlib.figure instance) – If None, a new figure instance is created.
NX2.polar.group(angle, wind, bsp, speedbins, anglebins, fct=<function median>)

Group data in bins according to wind angle and wind speed.

Parameters:
  • angle (np.ndarry) – Wind angles in degrees
  • wind (np.ndarray) – wind speed in kn
  • bsp (np.ndarray) – Boat speed in kn
  • speedbins (ndarray) – bin boundaries for speed binning
  • anglebins (ndarray) – bin boundaries for angle binning. Make sure that 180. is included in last bin and not on the boundary.
  • fct (function) – Given all bsp values in one (speedbin,anglebin) select on value to be used. Common examples are np.median or np.mean
Returns:

polar – This contains the data array with one speed for each (speedbin, anglebin)

Return type:

ndarray([len(speedbins)+1, len(anglebins)])

NX2.polar.near_const(arr, max_diff=0.01)

mark regions with small gradiant in arr

This is esssentially np.abs(np.diff(arr)) < max_diff with one element added, so that input and output have the same number of elements.

Parameters:
  • arr (1-dim array) –
  • max_diff (np.float) – maximum allowed gradiant between two elements
NX2.polar.plot(ax, polardata, speedbins, anglebins, color=['r', 'g', 'b', 'y', 'k', 'c', 'orange'])

Make a polar plot and label it for data in bins.

Parameters:
  • ax (matplotlib.axis instance) – axis were the plot should be added. Will usually be a polar axis.
  • polardata (ndarray([len(speedbins)+1, len(anglebins)])) – Array with the values to be plotted in individual bins.
  • speedbins (ndarray) – bin boundaries for speed binning
  • anglebins (ndarray) – bin boundaries for angle binning in deg Make sure that 180. is included in last bin and not on the boundary.
  • color (array) – matplotlib colors used for plotting the line in the diagram
NX2.polar.plot_half_circle(ax, theta, r, **kwargs)

extends theta and r to touch the final bin boundaries, then plots

Parameters:
  • ax (mpl.Axis instance) –
  • theta (np.ndarray) – angles in degrees
  • r (np.ndarray) – radius values for plot
  • plt.plot for a list of accepted keyword arguments. (See) –
NX2.polar.sail(data)

mark sailing only regions

This function determines times with the sail up and no rowing. It also cut off the very beginning and end of each sailing phase, because in those times the sail was not set perfectly anyway.

Parameters:data (NX2 data) –
Returns:sail – True, if vessel was sailing AND not rowing.
Return type:array of boolean
NX2.polar.setup_plot(fig, axtuple=111, maxr=5.0, returnall=False)

setup a polar plot (axis, labels etc.)

Parameters:
  • fig (matplotlib figure instance) –
  • axtuple (string or number) – defines how the ax containes is placed in fig
  • returnall (boolean) – If true, return additional output
Returns:

  • aux_ax1 (matplotlib) – Plot in this auxiliary axis (angle in degrees)
  • ax (matplot.axis instance)