scipp.spatial.affine_transforms#

scipp.spatial.affine_transforms(*, dims, unit=Unit(1), values)#

Initializes affine transformations from the provided affine matrix coefficients.

Parameters:
  • dims (Sequence[str]) – The dimensions of the variable.

  • unit (Unit | str, default: Unit(1)) – The unit of the affine transformation’s translation component.

  • values (ndarray[tuple[Any, ...], dtype[TypeVar(_Float, bound= float64 | float32, covariant=True)]] | Sequence[Any]) – An array of 4x4 matrices of affine coefficients.

Returns:

Variable – An array variable of dtype affine_transform3.

See also

scipp.spatial.affine_transform

Create a single affine transformation.

Examples

Create multiple affine transformations:

>>> import numpy as np
>>> import scipp as sc
>>> affine_matrices = np.array([
...     [[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],
...     [[1, 0, 0, 0], [0, 1, 0, 2], [0, 0, 1, 0], [0, 0, 0, 1]]
... ])
>>> affines = sc.spatial.affine_transforms(dims=['affine'], values=affine_matrices, unit='m')
>>> affines
<scipp.Variable> (affine: 2)  affine_transform3              [m]  [...]