xhealpixify.interpolation.bilinear.bilinear_interpolation_weights

xhealpixify.interpolation.bilinear.bilinear_interpolation_weights#

xhealpixify.interpolation.bilinear.bilinear_interpolation_weights(source_grid, target_grid, *, n_neighbors=6, metric='euclidean', coords=['longitude', 'latitude'], mask=None, min_vertices=3)#

xarray-aware bilinear interpolation weights computation

Parameters:
  • source_grid (xarray.Dataset) – The source grid. Has to have the coordinates specified by coords.

  • target_grid (xarray.Dataset) – The target grid. Has to have the coordinates specified by coords.

  • n_neighbors (int, default: 6) – How many neighbors the to search for each target point. Minimum is 4, but with 6 the surrounding vertices are found more accurately.

  • metric (str, default: "euclidean") – The metric to use when find the nearest neighbors. Look at the value of BallTree.valid_metrics for the full list of metrics. Note that choosing metrics other than "euclidean" affects the neighbors search, but so far the weights computation itself happens in a euclidean space.

  • coords (list of str, default: [``”longitude”, ``"latitude"]) – The names of the spatial coordinates in both the source and target grids.

  • mask (str or xarray.DataArray, optional) – If given, set the weight of input grid cells where the mask is False to 0. If a str, the variable of that name will be pulled from the source grid. If a xarray.DataArray, has to have the same dimensions as the source grid.

Returns:

weights (xarray.DataArray) – The computed weights as a sparse matrix.