geocat.comp._ncomp._linint2

geocat.comp._ncomp._linint2(ndarray xi, ndarray yi, ndarray fi, ndarray xo, ndarray yo, int icycx, msg=None)

Interpolates a regular grid to a rectilinear one using bi-linear interpolation.

linint2 uses bilinear interpolation to interpolate from one rectilinear grid to another. The input grid may be cyclic in the x direction. The interpolation is first performed in the x direction, and then in the y direction.

Parameters
  • xi (numpy.ndarray) –

    An 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.

  • yi (numpy.ndarray) –

    An 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.

  • fi (numpy.ndarray) –

    An array of two or more dimensions. If xi is passed in as an argument, then the size of the rightmost dimension of fi must match the rightmost dimension of xi. Similarly, if yi is passed in as an argument, then the size of the second- rightmost dimension of fi must match the rightmost dimension of yi.

    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.

  • xo (numpy.ndarray) –

    A 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.

    If the output coordinates (xo) are outside those of the input coordinates (xi), then the fo values at those coordinates will be set to missing (i.e. no extrapolation is performed).

  • yo (numpy.ndarray) –

    A 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.

    If the output coordinates (yo) are outside those of the input coordinates (yi), then the fo values at those coordinates will be set to missing (i.e. no extrapolation is performed).

  • icycx (bool) – An option to indicate whether the rightmost 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.

  • msg (numpy.number) – A numpy scalar value that represent a missing value in fi. This argument allows a user to use a missing value scheme other than NaN or masked arrays, similar to what NCL allows.

Returns

The interpolated grid. 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.

Return type

numpy.ndarray