convert_to_unit#

movement.utils.vector.convert_to_unit(data)[source]#

Convert the vectors along the spatial dimension into unit vectors.

A unit vector is a vector pointing in the same direction as the original vector but with norm = 1.

Parameters:

data (xarray.DataArray) – The input data array containing either space or space_pol as a dimension.

Returns:

A data array holding the unit vectors of the input data array (all input dimensions are preserved).

Return type:

xarray.DataArray

Notes

Note that the unit vector for the null vector is undefined, since the null vector has 0 norm and no direction associated with it.