interpax.interp3d

interpax.interp3d(xq: Real[Array, 'Nq'] | Real[ndarray, 'Nq'], yq: Real[Array, 'Nq'] | Real[ndarray, 'Nq'], zq: Real[Array, 'Nq'] | Real[ndarray, 'Nq'], x: Real[Array, 'Nx'] | Real[ndarray, 'Nx'], y: Real[Array, 'Ny'] | Real[ndarray, 'Ny'], z: Real[Array, 'Nz'] | Real[ndarray, 'Nz'], f: Num[Array, 'Nx Ny Nz ...'] | Num[ndarray, 'Nx Ny Nz ...'], method: str = 'cubic', derivative: int | tuple = 0, extrap: bool | float | tuple = False, period: None | float | tuple = None, even_spacing: bool | None | tuple = False, **kwargs) → Inexact[Array, 'Nq ...']Source

Interpolate a 3d function.

Parameters:
  • xq (ndarray, shape(Nq,)) – x query points where interpolation is desired

  • yq (ndarray, shape(Nq,)) – y query points where interpolation is desired

  • zq (ndarray, shape(Nq,)) – z query points where interpolation is desired

  • x (ndarray, shape(Nx,)) – x coordinates of known function values (“knots”)

  • y (ndarray, shape(Ny,)) – y coordinates of known function values (“knots”)

  • z (ndarray, shape(Nz,)) – z coordinates of known function values (“knots”)

  • f (ndarray, shape(Nx,Ny,Nz,...)) – function values to interpolate

  • method (str) –

    method of interpolation

    • 'nearest': nearest neighbor interpolation

    • 'linear': linear interpolation

    • 'cubic': C1 cubic splines (aka local splines)

    • 'cubic2': C2 cubic splines (aka natural splines)

    • 'catmull-rom': C1 cubic centripetal “tension” splines

    • 'cardinal': C1 cubic general tension splines. If used, can also pass keyword parameter c in float[0,1] to specify tension

    • 'monotonic': C1 cubic splines that attempt to preserve monotonicity in the data, and will not introduce new extrema in the interpolated points

    • 'monotonic-0': same as 'monotonic' but with 0 first derivatives at both endpoints

    • 'akima': C1 cubic splines that appear smooth and natural

  • derivative (int >= 0, array-like, shape(3,)) – derivative order to calculate in x,y,z directions. Use a single value for the same in all directions.

  • extrap (bool, float, array-like) – whether to extrapolate values beyond knots (True) or return nan (False), or a specified value to return for query points outside the bounds. Can also be passed as an array or tuple to specify different conditions for [[xlow, xhigh],[ylow,yhigh],[zlow,zhigh]]

  • period (float > 0, None, array-like, shape(3,)) – periodicity of the function in x, y, z directions. None denotes no periodicity, otherwise function is assumed to be periodic on the interval [0,period]. Use a single value for the same in all directions.

  • even_spacing (bool, None, tuple) – Whether the knots along each axis are evenly spaced, which allows a faster lookup of the cell containing each query point. If None, this is checked on each call. True skips the check, and gives incorrect results if the knots are not evenly spaced. False always uses a binary search. Defaults to False. Use a single value for the same in all directions. Along periodic axes, even spacing requires the knots to cover one full period without the endpoint, e.g. np.linspace(0, period, N, endpoint=False).

  • fx (ndarray, optional) – derivatives df/dx, df/dy, df/dz, d2f/dxdy, d2f/dxdz, d2f/dydz, d3f/dxdydz at the knots. For cubic methods, any that are given are used in place of the derivatives approximated by method.

  • fy (ndarray, optional) – derivatives df/dx, df/dy, df/dz, d2f/dxdy, d2f/dxdz, d2f/dydz, d3f/dxdydz at the knots. For cubic methods, any that are given are used in place of the derivatives approximated by method.

  • fz (ndarray, optional) – derivatives df/dx, df/dy, df/dz, d2f/dxdy, d2f/dxdz, d2f/dydz, d3f/dxdydz at the knots. For cubic methods, any that are given are used in place of the derivatives approximated by method.

  • fxy (ndarray, optional) – derivatives df/dx, df/dy, df/dz, d2f/dxdy, d2f/dxdz, d2f/dydz, d3f/dxdydz at the knots. For cubic methods, any that are given are used in place of the derivatives approximated by method.

  • fxz (ndarray, optional) – derivatives df/dx, df/dy, df/dz, d2f/dxdy, d2f/dxdz, d2f/dydz, d3f/dxdydz at the knots. For cubic methods, any that are given are used in place of the derivatives approximated by method.

  • fyz (ndarray, optional) – derivatives df/dx, df/dy, df/dz, d2f/dxdy, d2f/dxdz, d2f/dydz, d3f/dxdydz at the knots. For cubic methods, any that are given are used in place of the derivatives approximated by method.

  • fxyz (ndarray, optional) – derivatives df/dx, df/dy, df/dz, d2f/dxdy, d2f/dxdz, d2f/dydz, d3f/dxdydz at the knots. For cubic methods, any that are given are used in place of the derivatives approximated by method.

  • axis (tuple of int, shape(3,), optional) – axes of f along which x, y and z vary. Default is (0, 1, 2). The output has the remaining axes of f in their original order, with the query shape inserted at position min(axis).

Returns:

fq (ndarray, shape(Nq,…)) – function value at query points

Notes

For repeated interpolation given the same x, y, z, f data, recommend using Interpolator3D which caches the calculation of the derivatives and spline coefficients.