Module for 2D interpolation over a rectangular mesh
This module:
See end of this file for documentation of the mathematical derivation used.
Check inputs for interpolate2d function
Fundamental 2D interpolation routine
x: 1D array of x-coordinates of the mesh on which to interpolate
y: 1D array of y-coordinates of the mesh on which to interpolate
Z: 2D array of values for each x, y pair
points: Nx2 array of coordinates where interpolated values are sought
mode: Determines the interpolation order. Options are
‘constant’ - piecewise constant nearest neighbour interpolation
- ‘linear’ - bilinear interpolation using the four
nearest neighbours (default)
will be raised when interpolated values are requested outside the domain of the input data. If False, nan is returned for those values
Raises: Exception, BoundsError (see note about bounds_error)
Input coordinates x and y are assumed to be monotonically increasing, but need not be equidistantly spaced. No such assumption regarding ordering of points is made.
Z is assumed to have dimension M x N, where M = len(x) and N = len(y). In other words it is assumed that the x values follow the first (vertical) axis downwards and y values the second (horizontal) axis from left to right.
If this routine is to be used for interpolation of raster grids where data is typically organised with longitudes (x) going from left to right and latitudes (y) from left to right then user interpolate_raster in this module
2D interpolation of raster data
It is assumed that data is organised in matrix Z as latitudes from bottom up along the first dimension and longitudes from west to east along the second dimension.
Further it is assumed that x is the vector of longitudes and y the vector of latitudes.
See interpolate2d for details of the interpolation routine
This module forms part of the InaSAFE tool.