pyinterp.reduced_gaussian.apply#
- pyinterp.reduced_gaussian.apply(source, callback, lon, lat, time=None, *, args=None, fields=None, n_out=None, blend='columns', chunk_size=65536, time_method='linear', interval=None, max_step_gap=None, bounds_error=False, num_threads=0)[source]#
Compute values per point from the interpolated columns of the fields.
The columns are interpolated in C++, in parallel and without the GIL. Two kinds of callbacks consume them:
A Python callable, called on blocks of
chunk_sizepoints ascallback(columns, points, a, b):columnsmaps each field to its interpolated values (asinterpolate()returns them),pointsholdslon,lat,time(for a series) and the arrays ofargs,aandbare the hybrid coefficients of the half levels (or None). It returns an array of shape(block,)or(block, n_out). Write it with numpy operations over the block.A
ColumnKernelmade withcolumn_kernel(): a numba function called for each point from several threads, without the GIL, for computations that do not vectorize over points.
- Parameters:
source (Grid | Series) – A
Grid, or aSeriesof grids in time.callback (Callable[..., ArrayLike] | ColumnKernel) – The function applied to the columns.
lon (ArrayLike) – Longitudes of the points, in degrees.
lat (ArrayLike) – Latitudes of the points, in degrees.
time (ArrayLike | None) – Dates of the points, required for a series.
args (Mapping[str, ArrayLike] | None) – Extra values per point, passed to the callback by name (in this order in the
pointarray of a kernel).fields (Sequence[str] | None) – Names of the fields given to the callback; all by default.
n_out (int | None) – Number of values computed per point; by default that of the kernel, or 1.
blend (Blend) – For a series,
"columns"blends the columns of the two steps then calls the callback once;"results"calls it on the columns of each step and blends its results, which costs twice as much: it interpolates in time the result rather than the fields, which differs for a callback nonlinear in them.chunk_size (int) – Number of points per call of a Python callable.
time_method (TimeMethod) – See
interpolate().interval (Duration) – See
interpolate().max_step_gap (Duration) – See
interpolate().bounds_error (bool) – Raise instead of returning NaN for a point that cannot be interpolated, or for which a kernel returns a non-zero code.
num_threads (int) – Number of threads; 0 uses all the cores.
- Returns:
The values, shape
(n,)ifn_outis 1, else(n, n_out); NaN where a point cannot be interpolated.- Return type:
NDArray[np.float64]