watex.utils.interpolate_grid#

watex.utils.interpolate_grid(arr, /, method='cubic', fill_value='auto', view=False)[source]#

Interpolate data containing missing values.

Parameters:
  • arr (ArrayLike2D) – Two dimensional array for interpolation

  • method (str, default='cubic') – kind of interpolation. It could be [‘nearest’|’linear’|’cubic’].

  • fill_value (float, str, default='auto') – Fill the interpolated grid at the egdes or surrounding NaN with a filled value. The auto uses the forward and backward fill strategy.

  • view (bool, default=False,) – Quick visualize the interpolated grid.

Changed in version 0.2.8: One-dimensional array is henceforth possible. Error no longer raises.

Returns:

arri – Interpolated 2D grid.

Return type:

ArrayLike2d

See also

spi.griddata

Scipy interpolate Grid data

fillNaN

Fill missing data strategy.

Examples

>>> import numpy as np
>>> from watex.utils.funcutils import interpolate_grid
>>> x = [28, np.nan, 50, 60] ; y = [np.nan, 1000, 2000, 3000]
>>> xy = np.vstack ((x, y)).T
>>> xyi = interpolate_grid (xy, view=True )
>>> xyi
array([[  28.        ,   28.        ],
       [  22.78880663, 1000.        ],
       [  50.        , 2000.        ],
       [  60.        , 3000.        ]])