@exporter.export
def laplacian(f, **kwargs):
    'Calculate the laplacian of a grid of values.\n\n    Works for both regularly-spaced data, and grids with varying spacing.\n\n    Either `coordinates` or `deltas` must be specified, or `f` must be given as an\n    `xarray.DataArray` with  attached coordinate and projection information. If `f` is an\n    `xarray.DataArray`, and `coordinates` or `deltas` are given, `f` will be converted to a\n    `pint.Quantity` and the gradient returned as a tuple of `pint.Quantity`, otherwise, if\n    neither `coordinates` nor `deltas` are given, the attached coordinate information belonging\n    to `axis` will be used and the gradient will be returned as a tuple of `xarray.DataArray`.\n\n    Parameters\n    ----------\n    f : array-like\n        Array of values of which to calculate the derivative\n    coordinates : array-like, optional\n        The coordinate values corresponding to the grid points in `f`\n    deltas : array-like, optional\n        Spacing between the grid points in `f`. There should be one item less than the size\n        of `f` along the applicable axis.\n    axes : sequence, optional\n        Sequence of strings (if `f` is a `xarray.DataArray` and implicit conversion to\n        `pint.Quantity` is not used) or integers that specify the array axes along which to\n        take the derivatives. Defaults to all axes of `f`. If given, and used with\n        `coordinates` or `deltas`, its length must be less than or equal to that of the\n        `coordinates` or `deltas` given.\n\n    Returns\n    -------\n    array-like\n        The laplacian\n\n    See Also\n    --------\n    gradient, second_derivative\n\n    Notes\n    -----\n    If this function is used without the `axes` parameter, the length of `coordinates` or\n    `deltas` (as applicable) should match the number of dimensions of `f`.\n\n    '
    (pos_kwarg, positions, axes) = _process_gradient_args(f, kwargs)
    derivs = [second_derivative(f, axis=axis, **{pos_kwarg: positions[ind]}) for (ind, axis) in enumerate(axes)]
    laplac = sum(derivs)
    if isinstance(derivs[0], xr.DataArray):
        laplac.attrs['units'] = derivs[0].attrs['units']
    return laplac
Calculate the laplacian of a grid of values.

Works for both regularly-spaced data, and grids with varying spacing.

Either `coordinates` or `deltas` must be specified, or `f` must be given as an
`xarray.DataArray` with  attached coordinate and projection information. If `f` is an
`xarray.DataArray`, and `coordinates` or `deltas` are given, `f` will be converted to a
`pint.Quantity` and the gradient returned as a tuple of `pint.Quantity`, otherwise, if
neither `coordinates` nor `deltas` are given, the attached coordinate information belonging
to `axis` will be used and the gradient will be returned as a tuple of `xarray.DataArray`.

Parameters
----------
f : array-like
    Array of values of which to calculate the derivative
coordinates : array-like, optional
    The coordinate values corresponding to the grid points in `f`
deltas : array-like, optional
    Spacing between the grid points in `f`. There should be one item less than the size
    of `f` along the applicable axis.
axes : sequence, optional
    Sequence of strings (if `f` is a `xarray.DataArray` and implicit conversion to
    `pint.Quantity` is not used) or integers that specify the array axes along which to
    take the derivatives. Defaults to all axes of `f`. If given, and used with
    `coordinates` or `deltas`, its length must be less than or equal to that of the
    `coordinates` or `deltas` given.

Returns
-------
array-like
    The laplacian

See Also
--------
gradient, second_derivative

Notes
-----
If this function is used without the `axes` parameter, the length of `coordinates` or
`deltas` (as applicable) should match the number of dimensions of `f`.
@exporter.export
def laplacian(f, **kwargs):
    'Calculate the laplacian of a grid of values.\n\n    Works for both regularly-spaced data, and grids with varying spacing.\n\n    Either `coordinates` or `deltas` must be specified, or `f` must be given as an\n    `xarray.DataArray` with  attached coordinate and projection information. If `f` is an\n    `xarray.DataArray`, and `coordinates` or `deltas` are given, `f` will be converted to a\n    `pint.Quantity` and the gradient returned as a tuple of `pint.Quantity`, otherwise, if\n    neither `coordinates` nor `deltas` are given, the attached coordinate information belonging\n    to `axis` will be used and the gradient will be returned as a tuple of `xarray.DataArray`.\n\n    Parameters\n    ----------\n    f : array-like\n        Array of values of which to calculate the derivative\n    coordinates : array-like, optional\n        The coordinate values corresponding to the grid points in `f`\n    deltas : array-like, optional\n        Spacing between the grid points in `f`. There should be one item less than the size\n        of `f` along the applicable axis.\n    axes : sequence, optional\n        Sequence of strings (if `f` is a `xarray.DataArray` and implicit conversion to\n        `pint.Quantity` is not used) or integers that specify the array axes along which to\n        take the derivatives. Defaults to all axes of `f`. If given, and used with\n        `coordinates` or `deltas`, its length must be less than or equal to that of the\n        `coordinates` or `deltas` given.\n\n    Returns\n    -------\n    array-like\n        The laplacian\n\n    See Also\n    --------\n    gradient, second_derivative\n\n    Notes\n    -----\n    If this function is used without the `axes` parameter, the length of `coordinates` or\n    `deltas` (as applicable) should match the number of dimensions of `f`.\n\n    '
    (pos_kwarg, positions, axes) = _process_gradient_args(f, kwargs)
    derivs = [second_derivative(f, axis=axis, **{pos_kwarg: positions[ind]}) for (ind, axis) in enumerate(axes)]
    laplac = sum(derivs)
    if isinstance(derivs[0], xr.DataArray):
        laplac.attrs['units'] = derivs[0].attrs['units']
    return laplac