lezargus.library.container.functionality.transform module

lezargus.library.container.functionality.transform module#

Transformation functions specifically tailored to Lezargus containers.

We implement geometric transformations (typically affine-like transformations) and their tailored implementation for Lezargus containers. Transformations are special in that the specific implementation is very container specific so care is needed in picking the right function.

We separate the logic for containers into functions which make it a little easier to understand. Moreover, these functions can also be used separately. The logic is similar to Numpy’s functions like py:func:numpy.mean and numpy.ndarray.mean; and other modules in lezargus.library.container.functionality.

lezargus.library.container.functionality.transform.transform_shear_cube_spectral(cube: hint.LezargusCube, x_shifts: hint.NDArray, y_shifts: hint.NDArray, mode: str = 'constant', constant: float = nan) hint.LezargusCube[source]#

Apply a shear transformation along a cube’s spectral axis.

We translate the spatial slices of a cube, shearing along the cube’s spectral axis. The other two (spatial) axes are not sheared across and remain non-transformed, just the data is translated; the shear is parallel to the spatial axes.

Parameters:
  • cube (LezargusCube) – The cube which we are going to apply a shear transformation along the spectral axis.

  • x_shifts (ndarray) – The amount of shift in the x-axis of the spatial axes, in pixels. The length of this array must match the cube’s spectral axis.

  • y_shifts (ndarray) – The amount of shift in the y-axis of the spatial axes, in pixels. The length of this array must match the cube’s spectral axis.

  • mode (str, default = "constant") – The padding mode of the shear translations. See lezargus.library.transform.translate_2d() for the avaliable options.

  • constant (float, default = np.nan) – If the mode is constant, the constant value used is this value.

Returns:

sheared_cube – The cube after the shear transformation was applied as instructed.

Return type:

LezargusCube