pyinterp.reduced_gaussian.column_kernel#
- pyinterp.reduced_gaussian.column_kernel(n_out=1)[source]#
Compile a Python function into a native column kernel with numba.
The function is compiled in nopython mode and called once per point from the threads of
apply(), without the GIL: use it for computations that loop over the levels and do not vectorize over points. It receives numpy views and returns 0, or a non-zero code to report a failure (the point is then NaN). A kernel cannot raise: an exception is printed and lost, so report failures through the return code. The function, and any function it calls, is compiled with numba’serror_model="numpy": a division by zero givesinforNaNas in C; decorate the helpers it calls withnumba.njit(error_model="numpy")too:@column_kernel(n_out=1) def kernel(columns, widths, a, b, point, out): # columns: the fields concatenated, widths[k] values for field k # a, b: hybrid coefficients (empty if not given) # point: lon, lat, [time,] then the extra args, in order # out: the n_out values to compute out[0] = columns[0] * point[1] return 0
- Parameters:
n_out (int) – Number of values the kernel computes per point.
- Returns:
A decorator turning the function into a
ColumnKernel.- Raises:
ImportError – If numba is not installed.
- Return type:
Callable[[Callable[…, int]], ColumnKernel]