algebra#

Functions#

normalize(a[, dim])

Return vectors normalized along the dim dimension.

dnorm(a)

Calculate the norm along the direction dimension. All other dimensions are maintaned

dcross(a, b)

Generalized cross vector product in the dimension of direction.

ddot(a, b)

Dot product in the dimension of direction.

angle_(a, b)

Helper function to calculate the angle between the entries in a and b based on their coordinates in the direction dimension.

angle_cos_sin_(a, b)

Returns the cosine and sine of the angle between two vectors

normal(a, b, c)

Calculate normal vectors on the planes through corresponding points in a, b and c.

Module Contents#

normalize(a, dim='direction')#

Return vectors normalized along the dim dimension.

Parameters:

a (xr.DataArray | xr.Variable) – The data array to normalize along the dim dimension.

Returns:

Resulting DataArray after calculation of the noramlized vectors in the dimension dim.

Return type:

xr.DataArray | xr.Variable

dnorm(a)#

Calculate the norm along the direction dimension. All other dimensions are maintaned

Parameters:

a (xr.DataArray | xr.Variable) – The data array to perform the norming on

Returns:

Resulting dataarray after calculation of the norm in the dimension `direction.

Return type:

xr.DataArray | xr.Variable

dcross(a, b)#

Generalized cross vector product in the dimension of direction.

Parameters:
  • a (xr.DataArray | xr.Variable) – The first array to use for the binary operation

  • b (xr.DataArray | xr.Variable) – The second array to use for the binary operation

Returns:

The resulting array of the cross-product

Return type:

xr.DataArray | xr.Variable

ddot(a, b)#

Dot product in the dimension of direction.

Parameters:
  • a (xr.DataArray | xr.Variable) – The first array to use for the binary operation

  • b (xr.DataArray | xr.Variable) – The second array to use for the binary operation

Returns:

The resulting array of the dot-product still retaining all other dimensions except direction.

Return type:

xr.DataArray | xr.Variable

angle_(a, b)#

Helper function to calculate the angle between the entries in a and b based on their coordinates in the direction dimension.

Parameters:
  • a (xr.DataArray | xr.Variable) – The first array to use for the binary operation

  • b (xr.DataArray | xr.Variable) – The second array to use for the binary operation

Returns:

The resulting array of the angle calculation still retaining all other dimensions except direction.

Return type:

xr.DataArray | xr.Variable

angle_cos_sin_(a, b)#

Returns the cosine and sine of the angle between two vectors

Parameters:
  • a (DataArrayOrVar) – First vector

  • b (DataArrayOrVar) – Second vector

Returns:

First the vector of cosines, second the vector of sines.

Return type:

tuple[DataArrayOrVar, DataArrayOrVar]

normal(a, b, c)#

Calculate normal vectors on the planes through corresponding points in a, b and c.

The normal vector will be calculated based on the position in direction dimension.

Parameters:
  • a (xr.DataArray | xr.Variable) – The first array to use for the ternary operation

  • b (xr.DataArray | xr.Variable) – The second array to use for the ternary operation

  • c (xr.DataArray | xr.Variable) – The third array to use for the ternary operation

Returns:

An array with all dimensions equal to those of a, b, and c but holding normal vectors along the direction dimension.

Return type:

xr.DataArray | xr.Variable