The BILINEAR function uses a bilinear interpolation algorithm to compute the value of a data array at each of a set of subscript values.

This routine is written in the IDL language. Its source code can be found in the file bilinear.pro in the lib subdirectory of the IDL distribution.

Examples


Create a 3 x 3 floating point array P:

P = FINDGEN(3,3)

Suppose we wish to find the value of a point half way between the first and second elements of the first row of P. Create the subscript arrays IX and JY:

; Define the X subscript.
IX = 0.5
 
; Define the Y subscript.
JY = 0.0 
 
; Interpolate.
Z = BILINEAR(P, IX, JY) 
 
; Print the value at the point IX,JY within P.
PRINT, Z 

IDL prints:

0.500000

Suppose we wish to find the values of a 2 x 2 array of points in P. Create the subscript arrays IX and JY:

;Define the X subscripts.
IX = [[0.5, 1.9], [1.1, 2.2]]
 
;Define the Y subscripts and interpolate.
JY = [[0.1, 0.9], [1.2, 1.8]]
Z = BILINEAR(P, IX, JY)
 
;Print the array of values.
PRINT, Z

IDL prints:

0.800000    4.60000
4.70000     7.40000

Syntax


Result = BILINEAR(P, IX, JY [, MISSING=value])

Return Value


This function returns a two-dimensional interpolated array of the same type as the input array.

Arguments


P

A two-dimensional data array.

IX and JY

Arrays containing the X and Y “virtual subscripts” of P for which to interpolate values. IX and JY can be either of the following:

  • One-dimensional, n-element floating-point arrays of subscripts to look up in P. One-dimensional arrays will be converted to two-dimensional arrays in such a way that IX contains n identical rows and JY contains n identical columns.
  • Two-dimensional, n-element floating-point arrays that uniquely specify the X subscripts (the IX array) and the Y subscripts (the JY array) of the points to be computed from the input array P.

Location points outside the bounds of the array P. Elements of the IX or IY arguments that are either less than zero or greater than the largest subscript in the corresponding dimension of P are interpolated to the closest value within the bounds of the array P.

It is better to use two-dimensional arrays for IX and JY because the algorithm is somewhat faster. If IX and JY are specified as one-dimensional, the returned two-dimensional arrays IX and JY can be re-used on subsequent calls to take advantage of the faster 2D algorithm.

Keywords


MISSING

The value to return for elements outside the bounds of P. The bounds of P are 0 to n-1 and 0 to m-1 where P is an n x m array.

If MISSING value is set to a complex number, IDL uses only the real part.

Version History


Original

Introduced

6.1

Added MISSING keyword

See Also


INTERPOL, INTERPOLATE, KRIG2D