
linint1_n
Interpolates from one series to another using piecewise linear interpolation across the given dimension.
Prototype
function linint1_n ( xi : numeric, fi : numeric, fiCyclic [1] : logical, xo [*] : numeric, foOption : integer, dim [1] : integer ) return_val : float or double
Arguments
xiAn array that specifies the X coordinates of the fi array. It must be strictly monotonically increasing or decreasing, and can be unequally spaced. If xi is multi-dimensional, then its dimensions must be the same size as fi's dimensions. If it is one-dimensional, its length (call it nxi) must be the same as the dim-th dimension of fi.
fiAn array of one or more dimensions. The dim-th dimension (nxi) is the dimension to be interpolated. If missing values are present, the attribute fi@_FillValue must be set appropriately.
fiCyclicAn option to indicate whether the dim-th dimension of fi is cyclic.
This should be set to True only if you have global data, but your longitude values don't quite wrap all the way around the globe. For example, if your longitude values go from, say, -179.75 to 179.75, or 0.5 to 359.5, then you would set this to True.
xoA one-dimensional array that specifies the X coordinates of the return array. It may be unequally spaced. It must be monotonically increasing or decreasing in the same manner as xi: if xi is monotonically increasing/decreasing, then xo must be monotonically increasing or decreasing.
foOptionReserved for future use. It is currently not used, but set it to 0.
dimA scalar integer indicating which dimension of fi to do the interpolation across. Dimension numbering starts at 0.
Return value
The returned value will have the same dimensions as fi, with the dim-th dimension replaced by the length of xo. The return type will be double if fi is double, and float otherwise.
Description
The linint1_n function uses piecewise linear interpolation to interpolate from one series to another, given the dimension to interpolate across. The series may be cyclic in the X direction.
If missing values are present, then linint1_n will perform the piecewise linear interpolation at all points possible, but will return missing values at coordinates which could not be used.
If any of the the output coordinates xo are outside those of the input coordinates xi, the fo values at those coordinates will be set to missing (i.e. no extrapolation is performed).
If xi is monotonically increasing/decreasing, then xo must be monotonically increasing/decreasing.
Use the linint1_n_Wrap function if metadata retention is desired. The interface is identical.
See Also
linint1_n_Wrap, linint2, linint2_points, linint1, linmsg, isMonotonic, ESMF_regrid
Examples
Example 1
Assume fi is a 1D array, xi is a 1D array with values from 30 to 80 (they don't have to be equally-spaced), and that the rightmost dimension of fi is not to be treated as cyclic. Further assume that the output grid, xo, also has values from 30 to 80. Then, to interpolate fi to the grid represented by xo:
fo = linint1_n (xi,fi, False, xo, 0, 0) ; Use linint1_n_Wrap if metadata retention is desired ; fo = linint1_n_Wrap (xi,fi, False, xo, 0, 0)
fo will be 1D and be the same size as xo.
Example 2
Assume fi is 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, levels, and latitudes will be interpolated and returned in a new array fo, dimensioned ntim x nlvl x nlat x 144:
lon = (0., 2.8125, .... , 357.0125) LON = (0., 2.5, ... , 357.5) ; length 144 fo = linint1_n (lonfi, fi, True, LON, 0, 3) ; Use linint1_n_Wrap if metadata retention is desired ; fo = linint1_n_Wrap (lonfi, fi, True, LON, 0, 3)
Example 3
Assume xi is dimensioned ntim x nlvl x nlat x mlon (ntim=100, nlvl=30, nlat=64, mlon=128) and has named dimensions "time", "lev", "lat", "lon" and coordinate variables of the same name. Further, assume the values of time range from 15 to 500.
To create new functional values at arbitrarily specified times, the following approach could be used:
tNew = (/15., 15.5,16.8,19.0, ...488.23 /) ; new times time = xi&time ; for clarity xo = linint1_n (time, x, False, tNew, 0, 0) ; Use linint1_n_Wrap if metadata retention is desired ; xo = linint1_n_Wrap (time, x, False, tNew, 0, 0)
In the above code snippet, the leftmost dimension is not to be treated as cyclic (fiCyclic=False).
The function will interpolate all levels, latitudes and longitudes to the user-specified times and return in a new array xo. If NTIM = dimsizes(tNew) (number of new time steps), then the returned array, xo, will be of size NTIM x nlvl x nlat x mlon.