inverse_distance_to_grid#

metpy.interpolate.inverse_distance_to_grid(xp, yp, variable, grid_x, grid_y, r, gamma=None, kappa=None, min_neighbors=3, kind='cressman')[source]#

Generate an inverse distance interpolation of the given points to a regular grid.

Values are assigned to the given grid using inverse distance weighting based on either [Cressman1959] or [Barnes1964]. The Barnes implementation used here based on [Koch1983].

Parameters:
  • xp ((N, ) numpy.ndarray) – x-coordinates of observations.

  • yp ((N, ) numpy.ndarray) – y-coordinates of observations.

  • variable ((N, ) numpy.ndarray) – observation values associated with (xp, yp) pairs. IE, variable[i] is a unique observation at (xp[i], yp[i]).

  • grid_x ((M, 2) numpy.ndarray) – Meshgrid associated with x dimension.

  • grid_y ((M, 2) numpy.ndarray) – Meshgrid associated with y dimension.

  • r (float) – Radius from grid center, within which observations are considered and weighted.

  • gamma (float) – Adjustable smoothing parameter for the barnes interpolation. Default None.

  • kappa (float) – Response parameter for barnes interpolation. Default None.

  • min_neighbors (int) – Minimum number of neighbors needed to perform barnes or cressman interpolation for a point. Default is 3.

  • kind (str) – Specify what inverse distance weighting interpolation to use. Options: ‘cressman’ or ‘barnes’. Default ‘cressman’

Returns:

img ((M, N) numpy.ndarray) – Interpolated values on a 2-dimensional grid