pyinterp.core.regrid.overlap_matrix

Contents

pyinterp.core.regrid.overlap_matrix#

pyinterp.core.regrid.overlap_matrix(source_bounds: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], target_bounds: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], period: float = 0.0) → tuple[numpy.ndarray[dtype=int64, shape=(*), order='C'], numpy.ndarray[dtype=int64, shape=(*), order='C'], numpy.ndarray[dtype=float64, shape=(*), order='C']]#

Compute the overlaps between the cells of two axes.

Parameters:
  • source_bounds – Bounds of the source cells, shape (n, 2). The cells must not overlap.

  • target_bounds – Bounds of the target cells, shape (m, 2).

  • period – Period of the axis (360 for longitudes), 0 if the axis is not periodic. The overlaps of a periodic axis are computed modulo the period.

Returns:

The sparse (m, n) overlap matrix in the CSR format (indptr, indices, weights): a weight is the length of the overlap divided by the length of the target cell.