odak.learn.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 |
torch.cfloat |
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 |
bits |
int |
Quantization bits. |
8 |
default_range |
float |
Default range of phase only SLM. |
6.28 |
illumination |
torch.tensor |
Spatial illumination distribution. |
None |
Returns:
Type | Description |
---|---|
torch.cfloat |
Adjusted phase only pattern. |
Source code in odak/learn/wave/util.py
def produce_phase_only_slm_pattern(hologram, slm_range, 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 : torch.cfloat
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.
bits : int
Quantization bits.
default_range : float
Default range of phase only SLM.
illumination : torch.tensor
Spatial illumination distribution.
Returns
-------
pattern : torch.cfloat
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_digital = hologram_phase.detach().clone()
hologram_phase = torch.ceil(hologram_phase)
hologram_phase *= slm_range/2**bits
if type(illumination) == type(None):
A = torch.tensor([1.]).to(hologram_phase.device)
else:
A = illumination
return A*torch.cos(hologram_phase)+A*1j*torch.sin(hologram_phase), hologram_digital
Notes¶
Regarding usage of this definition, you can find use cases in the engineering notes, specifically at Optimizing holograms using Odak
.