magpack.rotations.transform_field#

transform_field(vector_field, rot_matrix)#

Rotates each element in the vector field according to the provided rotation matrix.

The vector field must have the form (n, x, y, …, z) where n indexes the component.

Parameters:
vector_fieldnp.ndarray

N-dim vector field, shaped (n, x, y, …, z).

rot_matrixnp.ndarray

Rotation matrix, shape (m, n).

Returns:
np.ndarray

Rotated N-dimensional vector field, shape (m, x, y, …, z).