slmsuite.holography.toolbox.phase.binary#

binary(grid, vector=(0, 0), shift=0, a=3.141592653589793, b=0, duty_cycle=0.5)[source]#

Returns a simple binary grating toward a given vector in \(k\)-space.

\[\begin{split}\phi(\vec{x}) = \left\{ \begin{array}{ll} a, & ( [2\pi \cdot \vec{k} \cdot \vec{x} + s] \,\,\,\,\text{mod}\,\,\,\, 2\pi ) < 2\pi*d \\ b, & \text{ otherwise}. \end{array} \right.\end{split}\]

Note

When parameters are chosen to produce integer period, this function uses speed optimizations (implementation incomplete). Otherwise, this function uses np.mod on top of blaze() to compute gratings.

Parameters:
  • grid ((array_like, array_like) OR SLM) – \(\vec{x}\). 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.

  • vector ((float, float)) – \(\vec{k}\). Blaze vector in normalized \(\frac{k_x}{k}\) units. See convert_vector()

  • shift (float) – Radians to laterally shift the period of the grating by.

  • a (float) – Value at one extreme of the binary grating.

  • b (float) – Value at the other extreme of the binary grating. Defaults to zero, in which case a is the amplitude.

  • duty_cycle (float) – Ratio of the period which is ‘on’.

Returns:

The phase for this function.

Return type:

numpy.ndarray