slmsuite.holography.toolbox.transform_grid#

transform_grid(grid, transform=None, shift=None, direction='fwd')[source]#

Returns a copy of a coordinate basis grid with a given shift and transformation. These can be the \(\vec{b}\) and \(M\) of a standard affine transformation as used elsewhere in the package. Such grids are used as arguments for phase patterns, such as those in slmsuite.holography.toolbox.phase.

Parameters:
  • grid ((array_like, array_like) OR SLM) – Meshgrids of normalized \(\frac{x}{\lambda}\) coordinates corresponding to SLM pixels, in (x_grid, y_grid) form. These are precalculated and stored in any SLM, so such a class can be passed instead of the grids directly.

  • transform (float OR ((float, float), (float, float)) OR None) – If a scalar is passed, this is the angle to rotate the basis of the lens by. Defaults to zero if None. If a 2x2 matrix is passed, transforms the \(x\) and \(y\) grids according to \(x' = M_{00}x + M_{01}y\), \(y' = M_{10}y + M_{11}y\).

  • shift ((float, float) OR None OR True) – Translational shift of the grid in normalized \(\frac{x}{\lambda}\) coordinates (“fwd” direction). Defaults to no shift if None. If True, shifts the grid to be centered upon itself.

  • direction (str in {"fwd", "rev"}) – Defines the direction of the transform: forward ("fwd") transforms then shifts; reverse ("rev") undoes the shift then applies the inverse transform. For standard affine transforms, forward (reverse) mode transforms "kxy" to "ij" ("ij" to "kxy").

Returns:

grid – The shifted grid. In the case where the transform is the identity, a copy is returned not the original grids.

Return type:

(array_like, array_like)