pyinterp.core.regrid.conservative#
- pyinterp.core.regrid.conservative(data: numpy.ndarray[dtype=float32, shape=(*, *), writable=False], source_x_bounds: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], source_y_bounds: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], target_x_bounds: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], target_y_bounds: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], *, geodetic: bool = True, spheroid: pyinterp.core.geometry.geographic.Spheroid | None = None, min_valid_fraction: float = 0.0, normalize: bool = True, num_threads: int = 0) numpy.ndarray[dtype=float32, shape=(*, *), order='C']#
- pyinterp.core.regrid.conservative(data: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], source_x_bounds: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], source_y_bounds: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], target_x_bounds: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], target_y_bounds: numpy.ndarray[dtype=float64, shape=(*, *), writable=False], *, geodetic: bool = True, spheroid: pyinterp.core.geometry.geographic.Spheroid | None = None, min_valid_fraction: float = 0.0, normalize: bool = True, num_threads: int = 0) numpy.ndarray[dtype=float64, shape=(*, *), order='C']
First order conservative regridding between rectilinear grids.
Each target cell receives the mean of the source values weighted by the area of their overlap with the target cell.
- Parameters:
data – Fields to regrid, a C-contiguous array of shape (fields × nx, ny): the fields follow each other, each one being a (nx, ny) matrix.
source_x_bounds – Bounds of the source cells along the first axis, shape (nx, 2).
source_y_bounds – Bounds of the source cells along the second axis, shape (ny, 2).
target_x_bounds – Bounds of the target cells along the first axis, shape (mx, 2).
target_y_bounds – Bounds of the target cells along the second axis, shape (my, 2).
geodetic – If true, the first axis is a longitude, periodic with a period of 360 degrees, and the second axis a latitude, in degrees. Otherwise, the axes are Cartesian.
spheroid – Ellipsoid of a geodetic grid. Defaults to a sphere.
min_valid_fraction – Minimum fraction of the target cell covered by defined source values; below, the result is NaN.
normalize – If true, undefined source values are ignored: the result is the mean of the defined values. Otherwise, the weighted sum is divided by the area of the whole target cell, as if they were zero.
num_threads – Number of threads, 0 for all CPUs.
- Returns:
The regridded fields, an array of shape (fields × mx, my).