bin

typhon.math.stats.bin(x, y, bins)[source]

Bin/bucket y according to values of x.

Returns list of arrays, one element with values for bin. Digitising happens with numpy.digitize.

You can use this for geographical data, but if your x and y are in lat/lons the bins will be equirectangular (if you want equal-area bins you will have to reproject / change coordinates).

Parameters:
  • x (ndarray) – Coordinate that y is binned along

  • y (ndarray) – Data to be binned. First dimension must match length of x. All subsequent dimensions are left untouched.

  • bins (ndarray) – Bins according to which sort data.

Returns:

List of arrays, one element per bin.