pyinterp.Binning2D

Contents

pyinterp.Binning2D#

pyinterp.Binning2D(x: pyinterp.core.Axis, y: pyinterp.core.Axis, spheroid: pyinterp.core.geometry.geographic.Spheroid | None = None, dtype: object | None = None) object#

Create a 2D binning for grouping values into bins on a grid.

Group a number of more or less continuous values into a smaller number of “bins” located on a grid.

Parameters:
  • x – Definition of the bin centers for the X axis of the grid.

  • y – Definition of the bin centers for the Y axis of the grid.

  • spheroid – Spheroid of the coordinate system used to manipulate geographic coordinates. If this parameter is not set, the handled coordinates will be considered as Cartesian coordinates. Otherwise, x and y are considered to represents the longitudes and latitudes.

  • dtype – Data type for internal storage, either ‘float32’ or ‘float64’. Determines precision and memory usage. Defaults to ‘float64’.

Examples

>>> import pyinterp
>>> import numpy as np
>>> x = pyinterp.Axis(np.arange(0, 360, 1), is_circle=True)
>>> y = pyinterp.Axis(np.arange(-90, 90, 1))
>>> binning = pyinterp.Binning2D(x, y)

Create with float32 for reduced memory usage

>>> binning = pyinterp.Binning2D(x, y, dtype='float32')
Returns:

Binning2D instance with the specified dtype.