Skip to content

odak.wave.produce_phase_only_slm_pattern

Definition for producing a pattern for a phase only Spatial Light Modulator (SLM) using a given field.

Parameters:

Name Type Description Default
hologram np.complex64

Input holographic field.

required
slm_range float

Range of the phase only SLM in radians for a working wavelength (i.e. two pi). See odak.wave.adjust_phase_only_slm_range() for more.

required
filename str

Optional variable, if provided the patterns will be save to given location.

None
bits int

Quantization bits.

8
default_range float

Default range of phase only SLM.

6.28
illumination np.ndarray

Spatial illumination distribution.

None

Returns:

Type Description
np.complex64

Adjusted phase only pattern.

Source code in odak/wave/__init__.py
def produce_phase_only_slm_pattern(hologram, slm_range, filename=None, bits=8, default_range=6.28, illumination=None):
    """
    Definition for producing a pattern for a phase only Spatial Light Modulator (SLM) using a given field.

    Parameters
    ----------
    hologram           : np.complex64
                         Input holographic field.
    slm_range          : float
                         Range of the phase only SLM in radians for a working wavelength (i.e. two pi). See odak.wave.adjust_phase_only_slm_range() for more.
    filename           : str
                         Optional variable, if provided the patterns will be save to given location.
    bits               : int
                         Quantization bits.
    default_range      : float 
                         Default range of phase only SLM.
    illumination       : np.ndarray
                         Spatial illumination distribution.

    Returns
    -------
    pattern            : np.complex64
                         Adjusted phase only pattern.
    hologram_digital   : np.int
                         Digital representation of the hologram.
    """
    #hologram_phase   = calculate_phase(hologram) % default_range
    hologram_phase = calculate_phase(hologram)
    hologram_phase = hologram_phase % slm_range
    hologram_phase /= slm_range
    hologram_phase *= 2**bits
    hologram_phase = hologram_phase.astype(np.int)
    hologram_digital = np.copy(hologram_phase)
    if type(filename) != type(None):
        save_image(
            filename,
            hologram_phase,
            cmin=0,
            cmax=2**bits
        )
    hologram_phase = hologram_phase.astype(np.float)
    hologram_phase *= slm_range/2**bits
    if type(illumination) == type(None):
        A = 1.
    else:
        A = illumination
    return A*np.cos(hologram_phase)+A*1j*np.sin(hologram_phase), hologram_digital

See also