linint2
Interpolates from a rectilinear grid to another rectilinear grid using bilinear interpolation.
Prototype
function linint2 ( xi : numeric, yi : numeric, fi : numeric, fiCyclicX [1] : logical, xo [*] : numeric, yo [*] : numeric, foOption [1] : integer ) return_val : float or double
Arguments
xiAn array that specifies the X coordinates of the fi array. Most frequently, this is a 1D strictly monotonically increasing array that may be unequally spaced. In some cases, xi can be a multi-dimensional array (see next paragraph). The rightmost dimension (call it nxi) must have at least two elements, and is the last (fastest varying) dimension of fi.
If xi is a multi-dimensional array, then each nxi subsection of xi must be strictly monotonically increasing, but may be unequally spaced. All but its rightmost dimension must be the same size as all but fi's rightmost two dimensions.
For geo-referenced data, xi is generally the longitude array.
yiAn array that specifies the Y coordinates of the fi array. Most frequently, this is a 1D strictly monotonically increasing array that may be unequally spaced. In some cases, yi can be a multi-dimensional array (see next paragraph). The rightmost dimension (call it nyi) must have at least two elements, and is the second-to-last dimension of fi.
If yi is a multi-dimensional array, then each nyi subsection of yi must be strictly monotonically increasing, but may be unequally spaced. All but its rightmost dimension must be the same size as all but fi's rightmost two dimensions.
For geo-referenced data, yi is generally the latitude array.
fiAn array of two or more dimensions. The two rightmost dimensions must of size nyi x nxi, and are the dimensions used in the interpolation. If missing values are present, the attribute fi@_FillValue must be set appropriately.
fiCyclicXAn option to indicate whether the rightmost dimension of fi is cyclic. Set to True if fi should be treated as cyclic and doesn't already have the cyclic point added. Set to False otherwise.
xoA one-dimensional array that specifies the X coordinates of the return array. It must be strictly monotonically increasing, but may be unequally spaced.
For geo-referenced data, xo is generally the longitude array.
yoA one-dimensional array that specifies the Y coordinates of the return array. It must be strictly monotonically increasing, but may be unequally spaced.
For geo-referenced data, yo is generally the latitude array.
foOptionReserved for future use. Currently not used, but set it to 0.
Return value
The returned value will have the same dimensions as fi, except for the rightmost two dimensions which will have the same dimension sizes as the lengths of yo and xo. The return type will be double if fi is double, and float otherwise.
Description
linint2 uses bilinear interpolation to interpolate
from one
If missing values are present, then linint2 will perform the bilinear interpolation at all points possible, but will return missing values at coordinates which could not be used.
If the output coordinates (xo,yo) are outside those of the input coordinates (xi,yi), then the fo values at those coordinates will be set to missing (i.e. no extrapolation is performed).
linint2 differs from linint2_points in that the former is designed to interpolate from grid-to-grid, while the latter is designed to interpolate from a grid to specified locations.
Use linint2_Wrap if retention of metadata is desired.
See Also
linint2_Wrap, area_conserve_remap, area_conserve_remap_Wrap, linint1, linint2_points, linmsg area_hi2lores, area_hi2lores_Wrap,
Examples
Example 1
Assume fi is dimensioned niy x nix (30 x 80), and that the rightmost dimension is not to be treated as cyclic. The returned array will be of size noy x nox, where noy and nox are the sizes of the one-dimensional arrays xo and yo:
xi = (30,33,35,39,....., 80) [does not have to be equally spaced] yi = (0,1,2,3,....,28,29) xo = (any coordinates between 30 and 80) [inclusive] yo = (any coordinates between 0 and 29) [inclusive] fo = linint2 (xi,yi,fi, False, xo,yo, 0)
Example 2
Assume fi is a 4D array dimensioned ntim x nlvl x nlat x mlon (ntim=50, nlvl=30, nlat=64, mlon=128), and that the rightmost dimension is to be treated as cyclic (the user should not add a cyclic point for the rightmost dimension).
All times and levels will be interpolated and returned in a new array fo dimensioned ntim x nlvl x 73 x 144:
lon = (0., 2.8125, .... , 357,0125) lat = (-87.8638, ... ,87.8638) LON = (0., 2.5, ... , 357.5) ; length 144 LAT = (-90.,87.5,...90.) ; length 73 fo = linint2 (lon,lat,fi, True, LON,LAT, 0)