INTERPOLATE Function

Standard Library function that interpolates scattered data at scattered locations.

Usage

    result = INTERPOLATE(d, x)

Input Parameters

d—An (m, n+1) array of m datapoints in n independent variables and one dependent variable; d(*,n) is the dependent variable.

x—A (p,n) array specifying p interpolation points.

Returned Value

result—A 1D array of values of the dependent variable at points x.

Keywords

r—A scalar specifying the order of the weighting function. The dependent variable at an interpolation point is computed as a weighted average of the variable over all datapoints. The weighting function is 1/er where e is the Euclidean distance between the interpolation point and the datapoint. r defaults to 2

Example

INTERPOLATE uses a fast but memory-intensive algorithm and if the array of points at which to interpolate (intrppts in the example) is large, memory can be exhausted. If such a situation arises, this array can be broken up into smaller arrays as the algorithm for computing an interpolated point does not use values computed at other interpolated points. If you had an array of 1e8 interpolation points you could call INTERPOLATE ten times with the array of 1e8 points broken up into ten 1e7 sized arrays.

data = [[RANDOMU(L,300)], [2*!Pi*RANDOMU(l,300)]]
data = [[data(*,0)*COS(data(*,1))], [data(*,0)*SIN(data(*,1))],$
   [SQRT(1-data(*,0)^2)]]
intrppts = [ [0.8*RANDOMU(L,100)], [2*!Pi*RANDOMU(l,100)] ]
intrppts = [ [intrppts(*,0)*COS(intrppts(*,1))], $
   [intrppts(*,0)*SIN(intrppts(*,1))] ]
intrpdata = INTERPOLATE(data, intrppts, R=3)
x = REFORM(data(*,0), 6, 50)
y = REFORM(data(*,1), 6, 50)
z = REFORM(data(*,2), 6, 50)
SURFACE, z, x, y, /Save, /Nodata
intrpdata = TRANSPOSE([ [intrppts], [intrpdata] ])
data = TRANSPOSE(data)
TEK_COLOR
PLOTS, data, Psym=2, /T3d
PLOTS, intrpdata, Psym=2, Color=WoColorConvert(2), /T3d
XYOUTS, .2, .95, 'White is real data', /Normal
XYOUTS, .2, .90, 'Red is interpolated data', $
   Color=WoColorConvert(2), /Normal

See Also

GRIDN