weights#

named_arrays.regridding.weights(coordinates_input, coordinates_output, axis_input=None, axis_output=None, weights_input=None, method='multilinear', perturb=None)#

Save the results of a regridding operation as a sequence of weights, which can be used in subsequent regridding operations on the same grid.

The results of this function are designed to be used by regrid_from_weights()

This function returns a tuple containing a ragged array of weights, the shape of the input coordinates, and the shape of the output coordinates.

Parameters:
  • coordinates_input (AbstractScalar | AbstractVectorArray) – Coordinates of the input grid.

  • coordinates_output (AbstractScalar | AbstractVectorArray) – Coordinates of the output grid. Should have the same number of coordinates as the input grid.

  • axis_input (None | str | Sequence[str]) – Logical axes of the input grid to resample. If None, resample all the axes of the input grid. The number of axes should be equal to the number of coordinates in the input grid.

  • axis_output (None | str | Sequence[str]) – Logical axes of the output grid corresponding to the resampled axes of the input grid. If None, all the axes of the output grid correspond to resampled axes in the input grid. The number of axes should be equal to the number of coordinates in the output grid.

  • weights_input (None | AbstractScalar) – Weights applied to the values of the input grid before resampling.

  • method (Literal['multilinear', 'conservative']) – The type of regridding to use.

  • perturb (None | bool) – Whether to perturb coordinates_output by a small value to avoid degenerate grids. This is helpful for some methods, like conservative, which sometimes cannot handle degenerate grids. If None (the default), no perturbation is applied unless method is conservative and the dimensions of the grid are 2D or higher. If True, each point is perturbed using a normal distribution with standard deviation equal to 1e-9 of the grid width.

Return type:

tuple[AbstractScalar, dict[str, int], dict[str, int]]

See also

regridding.weights()

An equivalent function for instances of numpy.ndarray.

regrid_from_weights()

A function designed to use the outputs of this function.

regrid()

Resample an array without saving the weights