naginterfaces.library.interp.dimn_​grid

naginterfaces.library.interp.dimn_grid(narr, uniform, axis, v, point, method, k=1, wf=0.0)[source]

dimn_grid interpolates data at a point in -dimensional space, that is defined by a set of gridded data points. It offers three methods to interpolate the data: Linear Interpolation, Cubic Interpolation and Weighted Average.

For full information please refer to the NAG Library document for e01za

https://www.nag.com/numeric/nl/nagdoc_28.6/flhtml/e01/e01zaf.html

Parameters
narrint, array-like, shape

The number of data ordinates in each dimension, with , for .

uniformbool

States whether the data points are uniformly spaced.

The data points are uniformly spaced.

The data points are not uniformly spaced.

axisfloat, array-like, shape

Defines the axis. If the data points are uniformly spaced (see argument ) should contain the start and end of each dimension .

If the data points are not uniformly spaced, should contain all the data ordinates for each dimension .

vfloat, array-like, shape

Holds the values of the data points in such an order that the index of a data value with coordinates is

where e.g., .

pointfloat, array-like, shape

, the point at which the data value is to be interpolated.

methodint

The method to be used.

Weighted Average.

Linear Interpolation.

Cubic Interpolation.

kint, optional

If , controls the number of data points used in the Weighted Average method, with points used in each dimension, either side of the interpolation point. The total number of data points used for the interpolation will, therefore, be .

If , then is not referenced and need not be set.

wffloat, optional

The power used for the weighted average such that a high power will cause closer points to be more heavily weighted.

Returns
ansfloat

Holds the result of the interpolation.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, decreases in dimension .

Constraint: definition must be strictly increasing.

(errno )

On entry, , sum of .

Constraint: if , sum of .

(errno )

On entry, , .

Constraint: if , .

(errno )

On entry, .

Constraint: if , .

(errno )

On entry, and data range .

Constraint: must be within the data range.

(errno )

On entry, and .

Constraint: if , must be .

(errno )

On entry, .

Constraint: , or .

(errno )

On entry, .

Constraint: if , .

(errno )

Cubic Interpolation method does not have enough data surrounding ; interpolation not possible.

Warns
NagAlgorithmicWarning
(errno )

Warning: the size of has been reduced, due to too few data points around .

Notes

dimn_grid interpolates an -dimensional point within a set of gridded data points, , with corresponding data values where, for the th dimension, and is the number of ordinates in the th dimension.

A hypercube of data points , where and the corresponding data values are , around the given point, , is found and then used to interpolate using one of the following three methods.

  1. Weighted Average, that is a modification of Shepard’s method (Shepard (1968)) as used for scattered data in dimn_scat_shep(). This method interpolates the data with the weighted mean

    where , and , for a given value of .

  2. Linear Interpolation, which takes surrounding data points () and performs two one-dimensional linear interpolations in each dimension on data points and , reducing the dimension every iteration until it has reached an answer. The formula for linear interpolation in dimension is simply

    where and .

  3. Cubic Interpolation, based on cubic convolution (Keys (1981)). In a similar way to the Linear Interpolation method, it performs the interpolations in one dimension reducing it each time, however it requires four surrounding data points in each dimension (), two in each direction . The following is used to calculate the one-dimensional interpolant in dimension

    where and .

References

Keys, R, 1981, Cubic Convolution Interpolation for Digital Image Processing, IEEE Transactions on Acoutstics, Speech, and Signal Processing (Vol ASSP-29 No. 6), 1153–1160, http://hmi.stanford.edu/doc/Tech_Notes/HMI-TN-2004-004-Interpolation/Keys_cubic_interp.pdf

Shepard, D, 1968, A two-dimensional interpolation function for irregularly spaced data, Proc. 23rd Nat. Conf. ACM, 517–523, Brandon/Systems Press Inc., Princeton