xarray.align

xarray.align(*objects, join='inner', copy=True)

Given any number of Dataset and/or DataArray objects, returns new objects with aligned indexes.

Array from the aligned objects are suitable as input to mathematical operators, because along each dimension they have the same indexes.

Missing values (if join != 'inner') are filled with NaN.

Parameters:

*objects : Dataset or DataArray

Objects to align.

join : {‘outer’, ‘inner’, ‘left’, ‘right’}, optional

Method for joining the indexes of the passed objects along each dimension: - ‘outer’: use the union of object indexes - ‘inner’: use the intersection of object indexes - ‘left’: use indexes from the first object with each dimension - ‘right’: use indexes from the last object with each dimension

copy : bool, optional

If copy=True, data in the return values is always copied. If copy=False and reindexing is unnecessary, or can be performed with only slice operations, then the output may share memory with the input. In either case, new xarray objects are always returned.

exclude : sequence of str, optional

Dimensions that must be excluded from alignment

indexes : dict-like, optional

Any indexes explicitly provided with the indexes argument should be used in preference to the aligned indexes.

Returns:

aligned : same as *objects

Tuple of objects with aligned coordinates.