Core Dimensions

Fundamental dimensions over which an operation is defined.

Why core dimensions?

  • apply_ufunc is used to create generalized operations on xarray data.
  • Core dimensions specifies which are the main dimensions the function will be operating with.
  • Core dimensions are moved to last index (transposed).

For example,

da.shape
# (2, 3, 4)
 
def func(d):
    print(d.shape)
    return d
 
xr.apply_ufunc(func, da, input_core_dims=["first_dim"]("first_dim"))
 
# (3, 4, 2)

Todo

Understand the use of core dimensions in case of vectorise=True

References

  1. https://tutorial.xarray.dev/advanced/apply_ufunc/core-dimensions.html