xarray.dot¶
-
xarray.
dot
(*arrays, dims=None)¶ Generalized dot product for xarray objects. Like np.einsum, but provides a simpler interface based on array dimensions.
Parameters: - arrays: DataArray (or Variable) objects
Arrays to compute.
- dims: str or tuple of strings, optional
Which dimensions to sum over. If not speciified, then all the common dimensions are summed over.
- **kwargs: dict
Additional keyword arguments passed to numpy.einsum or dask.array.einsum
Returns: - dot: DataArray
Examples
>>> da_a = xr.DataArray(np.arange(3 * 4).reshape(3, 4), dims=['a', 'b']) >>> da_b = xr.DataArray(np.arange(3 * 4 * 5).reshape(3, 4, 5), >>> dims=['a', 'b', 'c']) >>> da_c = xr.DataArray(np.arange(5 * 6).reshape(5, 6), dims=['c', 'd']) >>> >>> xr.dot(da_a, da_b, dims=['a', 'b']).dims ('c', ) >>> xr.dot(da_a, da_b, dims=['a']).dims ('b', 'c') >>> xr.dot(da_a, da_b, da_c, dims=['b', 'c']).dims ('a', 'd')