pyinterp.univariate_derivative

pyinterp.univariate_derivative#

pyinterp.univariate_derivative(grid, x, method='linear', *, bounds_error=False, num_threads=0, half_window_size=None, boundary_mode=None)[source]#

Calculate derivatives on a 1D grid.

Parameters:
  • grid (GridHolder) – The 1D grid containing data

  • x (NDArray1DNumeric) – X coordinates at which to calculate derivatives

  • method (windowed.Univariate | WindowedMethods) – Interpolation method (config object or string)

  • bounds_error (bool) – If True, raise error for out-of-bounds coordinates

  • num_threads (int) – Number of threads to use (0 = auto)

  • half_window_size (int | None) – Half window size for the derivative calculation

  • boundary_mode (BoundaryMode | None) – Boundary handling mode

Returns:

Derivative values

Return type:

NDArray1DFloat32 | NDArray1DFloat64

Examples

Simple usage:

>>> derivative = univariate_derivative(grid, x, "c_spline")
>>> derivative = univariate_derivative(grid, x, "akima", window_size=7)

Advanced usage with config objects:

>>> from pyinterp.core.config import windowed
>>> config = windowed.Univariate.c_spline().with_half_window_size(10)
>>> derivative = univariate_derivative(grid, x, config)