pado.optical_element.PolarizedSLM

class PolarizedSLM(dim, pitch, wvl, device)[source]
Parameters:
__init__(dim, pitch, wvl, device)[source]

SLM which can control phase & amplitude of each polarization component.

Parameters:
  • dim (tuple) – Field dimensions (B, 1, R, C) for batch, channels, rows, cols

  • pitch (float) – Pixel pitch in meters

  • wvl (float) – Wavelength in meters

  • device (str) – Device for computation (‘cpu’, ‘cuda:0’, etc.)

Examples

>>> slm = PolarizedSLM(dim=(1,1,1024,1024), pitch=6.4e-6, wvl=633e-9, device='cuda:0')
set_amplitude_change(amplitude, wvl)[source]

Set amplitude change for both polarization components.

Parameters:
  • amplitude (torch.Tensor) – Amplitude change [B, 1, R, C, 2] in polar representation

  • wvl (float) – Wavelength in meters

Return type:

None

Examples

>>> amp = torch.ones((1,1,1024,1024,2)) * 0.8  # 80% transmission for both polarizations
>>> slm.set_amplitude_change(amp, wvl=633e-9)
set_phase_change(phase_change, wvl)[source]

Set phase change for both polarization components.

Parameters:
  • phase_change (torch.Tensor) – Phase change [B, 1, R, C, 2] in polar representation

  • wvl (float) – Wavelength in meters

Return type:

None

Examples

>>> phase = torch.ones((1,1,1024,1024,2)) * np.pi  # π phase shift for both polarizations
>>> slm.set_phase_change(phase, wvl=633e-9)
set_amplitudeX_change(amplitude, wvl)[source]

Set amplitude change for X polarization component.

Parameters:
  • amplitude (torch.Tensor) – Amplitude change [B, 1, R, C] for X component

  • wvl (float) – Wavelength in meters

Return type:

None

Examples

>>> ampX = torch.ones((1,1,1024,1024)) * 0.8  # 80% transmission for X polarization
>>> slm.set_amplitudeX_change(ampX, wvl=633e-9)
set_amplitudeY_change(amplitude, wvl)[source]

Set amplitude change for Y polarization component.

Parameters:
  • amplitude (torch.Tensor) – Amplitude change [B, 1, R, C] for Y component

  • wvl (float) – Wavelength in meters

Return type:

None

Examples

>>> ampY = torch.ones((1,1,1024,1024)) * 0.6  # 60% transmission for Y polarization
>>> slm.set_amplitudeY_change(ampY, wvl=633e-9)
set_phaseX_change(phase_change, wvl)[source]

Set phase change for X polarization component.

Parameters:
  • phase_change (torch.Tensor) – Phase change [B, 1, R, C] for X component

  • wvl (float) – Wavelength in meters

Return type:

None

Examples

>>> phaseX = torch.ones((1,1,1024,1024)) * np.pi/2  # π/2 phase shift for X polarization
>>> slm.set_phaseX_change(phaseX, wvl=633e-9)
set_phaseY_change(phase_change, wvl)[source]

Set phase change for Y polarization component.

Parameters:
  • phase_change (torch.Tensor) – Phase change [B, 1, R, C] for Y component

  • wvl (float) – Wavelength in meters

Return type:

None

Examples

>>> phaseY = torch.ones((1,1,1024,1024)) * np.pi  # π phase shift for Y polarization
>>> slm.set_phaseY_change(phaseY, wvl=633e-9)
get_phase_changeX()[source]

Return phase change for X polarization component.

Returns:

Phase change [B, 1, R, C] for X component

Return type:

torch.Tensor

Examples

>>> phaseX = slm.get_phase_changeX()  # Get X polarization phase profile
get_phase_changeY()[source]

Return phase change for Y polarization component.

Returns:

Phase change [B, 1, R, C] for Y component

Return type:

torch.Tensor

Examples

>>> phaseY = slm.get_phase_changeY()  # Get Y polarization phase profile
get_amplitude_changeX()[source]

Return amplitude change for X polarization component.

Returns:

Amplitude change [B, 1, R, C] for X component

Return type:

torch.Tensor

Examples

>>> ampX = slm.get_amplitude_changeX()  # Get X polarization amplitude profile
get_amplitude_changeY()[source]

Return amplitude change for Y polarization component.

Returns:

Amplitude change [B, 1, R, C] for Y component

Return type:

torch.Tensor

Examples

>>> ampY = slm.get_amplitude_changeY()  # Get Y polarization amplitude profile
forward(light, interp_mode='nearest')[source]

Apply polarization-dependent modulation to input light.

Parameters:
  • light (Light) – Input light field

  • interp_mode (str) – Interpolation mode for resizing (‘nearest’, ‘bilinear’, etc.)

Returns:

Modulated light field

Return type:

Light

Examples

>>> modulated_light = slm.forward(input_light)  # Apply polarization modulation
>>> modulated_light = slm.forward(input_light, interp_mode='bilinear')  # Use bilinear interpolation
pad(pad_width, padval=0)[source]

Pad amplitude and phase changes with constant value.

Parameters:
  • pad_width (tuple) – Padding dimensions (left, right, top, bottom)

  • padval (int) – Padding value (only 0 supported)

Return type:

None

Examples

>>> slm.pad((16,16,16,16))  # Add 16 pixels padding on all sides
visualize(b=0)[source]

Visualize amplitude and phase modulation for both polarizations.

Parameters:

b (int) – Batch index to visualize, default 0

Return type:

None

Examples

>>> slm.visualize()  # Visualize first batch
>>> slm.visualize(b=1)  # Visualize second batch