interpax.Interpolator2D

class interpax.Interpolator2D(x: Real[Array, 'Nx'] | Real[ndarray, 'Nx'], y: Real[Array, 'Ny'] | Real[ndarray, 'Ny'], f: Num[Array, 'Nx Ny ...'] | Num[ndarray, 'Nx Ny ...'], method: str = 'cubic', extrap: bool | float | tuple = False, period: None | float | tuple = None, **kwargs)Source

Convenience class for representing a 2D interpolated function.

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

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

  • f (ndarray, shape(Nx,Ny,...)) – 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

  • 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 [[xlow, xhigh],[ylow,yhigh]]

  • period (float > 0, None, array-like, shape(2,)) – periodicity of the function in x, y 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 both directions.

Methods

__call__(xq, yq[, dx, dy])

Evaluate the interpolated function or its derivatives.

Attributes

x

y

f

derivs

method

extrap

period

axis