pado.light.PolarizedLight¶
- class PolarizedLight(dim, pitch, wvl, fieldX=None, fieldY=None, device='cuda:0')[source]¶
Light wave with polarized complex field wavefront.
Represent a light wave with X and Y polarization components that can be manipulated through various optical operations.
- Parameters:
- __init__(dim, pitch, wvl, fieldX=None, fieldY=None, device='cuda:0')[source]¶
Create polarized light wave instance with X and Y field components.
- Parameters:
dim (tuple) – Field dimensions (B, Ch, R, C) for batch, channels, rows, cols
pitch (float) – Pixel pitch in meters
wvl (float) – Wavelength in meters
fieldX (torch.Tensor, optional) – Initial X-polarized field [B, Ch, R, C]
fieldY (torch.Tensor, optional) – Initial Y-polarized field [B, Ch, R, C]
device (str) – Device for computation (‘cpu’, ‘cuda:0’, etc.)
- Return type:
None
Examples
>>> light = PolarizedLight(dim=(1, 1, 1024, 1024), pitch=6.4e-6, wvl=633e-9) >>> light = PolarizedLight(dim=(2, 1, 512, 512), pitch=2e-6, wvl=532e-9, ... fieldX=torch.ones(2,1,512,512), ... fieldY=torch.zeros(2,1,512,512))
- clone()[source]¶
Create deep copy of polarized light instance.
- Returns:
New polarized light instance with copied attributes
- Return type:
Examples
>>> light_copy = light.clone()
- get_amplitude()[source]¶
Return total amplitude of polarized field.
- Returns:
Total amplitude
- Return type:
- get_amplitudeX()[source]¶
Return amplitude of X-polarized field.
- Returns:
Amplitude of X-polarized field
- Return type:
- get_amplitudeY()[source]¶
Return amplitude of Y-polarized field.
- Returns:
Amplitude of Y-polarized field
- Return type:
- get_field()[source]¶
Return complex field.
- Returns:
Complex field values for X and Y components
- Return type:
Examples
>>> field = light.get_field()
- get_fieldX()[source]¶
Return X-polarized field component.
- Returns:
Complex field tensor for X polarization
- Return type:
Examples
>>> x_field = light.get_fieldX()
- get_fieldY()[source]¶
Return Y-polarized field component.
- Returns:
Complex field tensor for Y polarization
- Return type:
Examples
>>> y_field = light.get_fieldY()
- get_imag()[source]¶
Get imaginary part of field for both components.
- Returns:
Imaginary part values for X and Y components
- Return type:
Examples
>>> imag_parts = light.get_imag()
- get_intensity()[source]¶
Return total intensity of polarized field.
- Returns:
Total intensity
- Return type:
- get_intensityX()[source]¶
Return intensity of X-polarized field.
- Returns:
Intensity of X-polarized field
- Return type:
- get_intensityY()[source]¶
Return intensity of Y-polarized field.
- Returns:
Intensity of Y-polarized field
- Return type:
- get_lightX()[source]¶
Return X-polarized Light instance.
- Returns:
Light instance for X component
- Return type:
Examples
>>> x_light = light.get_lightX()
- get_lightY()[source]¶
Return Y-polarized Light instance.
- Returns:
Light instance for Y component
- Return type:
Examples
>>> y_light = light.get_lightY()
- get_phase()[source]¶
Return phase of field.
- Returns:
Phase values for X and Y components
- Return type:
Examples
>>> phase = light.get_phase()
- get_phaseX()[source]¶
Return phase of X-polarized field.
- Returns:
Phase of X-polarized field
- Return type:
- get_phaseY()[source]¶
Return phase of Y-polarized field.
- Returns:
Phase of Y-polarized field
- Return type:
- get_real()[source]¶
Get real part of field for both components.
- Returns:
Real part values for X and Y components
- Return type:
Examples
>>> real_parts = light.get_real()
- magnify(scale_factor, interp_mode='nearest')[source]¶
Change wavefront resolution without changing pixel pitch.
- Parameters:
- Return type:
Examples
>>> light.magnify(2.0, 'bilinear')
- pad(pad_width, padval=0)[source]¶
Pad light field.
- Parameters:
- Return type:
Examples
>>> light.pad((10, 10, 10, 10))
- resize(new_pitch, interp_mode='nearest')[source]¶
Resize light field to match new pixel pitch.
- Parameters:
- Return type:
Examples
>>> light.resize(8e-6)
- set_amplitude(amplitude)[source]¶
Set amplitude for both X and Y components.
- Parameters:
amplitude (torch.Tensor or tuple) – Amplitude values for both components or tuple of (amplitudeX, amplitudeY)
- Return type:
Examples
>>> light.set_amplitude(torch.ones(1,1,512,512)) >>> light.set_amplitude((x_amplitude, y_amplitude))
- set_amplitudeX(amplitude)[source]¶
Set amplitude for X component.
- Parameters:
amplitude (torch.Tensor) – Amplitude values for X component
- Return type:
Examples
>>> light.set_amplitudeX(torch.ones(1,1,512,512))
- set_amplitudeY(amplitude)[source]¶
Set amplitude for Y component.
- Parameters:
amplitude (torch.Tensor) – Amplitude values for Y component
- Return type:
Examples
>>> light.set_amplitudeY(torch.ones(1,1,512,512))
- set_field(field)[source]¶
Set both X and Y field components.
Examples
>>> light.set_field((x_field, y_field))
- set_fieldX(field)[source]¶
Set X-polarized field.
- Parameters:
field (torch.Tensor) – Complex field values
- Return type:
Examples
>>> light.set_fieldX(torch.ones(1,1,512,512, dtype=torch.cfloat))
- set_fieldY(field)[source]¶
Set Y-polarized field.
- Parameters:
field (torch.Tensor) – Complex field values
- Return type:
Examples
>>> light.set_fieldY(torch.ones(1,1,512,512, dtype=torch.cfloat))
- set_imag(imag)[source]¶
Set imaginary part for both X and Y components.
- Parameters:
imag (torch.Tensor or tuple) – Imaginary values for both components or tuple of (imagX, imagY)
- Return type:
Examples
>>> light.set_imag(torch.zeros(1,1,512,512)) >>> light.set_imag((x_imag, y_imag))
- set_imagX(imag)[source]¶
Set imaginary part of X-polarized field.
- Parameters:
imag (torch.Tensor) – Imaginary component values
- Return type:
Examples
>>> light.set_imagX(torch.zeros(1,1,512,512))
- set_imagY(imag)[source]¶
Set imaginary part of Y-polarized field.
- Parameters:
imag (torch.Tensor) – Imaginary component values
- Return type:
Examples
>>> light.set_imagY(torch.zeros(1,1,512,512))
- set_phase(phase)[source]¶
Set phase for both X and Y components.
- Parameters:
phase (torch.Tensor or tuple) – Phase values for both components or tuple of (phaseX, phaseY)
- Return type:
Examples
>>> light.set_phase(torch.zeros(1,1,512,512)) >>> light.set_phase((x_phase, y_phase))
- set_phaseX(phase)[source]¶
Set phase of X-polarized field.
- Parameters:
phase (torch.Tensor) – Phase values in radians
- Return type:
Examples
>>> light.set_phaseX(torch.zeros(1,1,512,512))
- set_phaseY(phase)[source]¶
Set phase of Y-polarized field.
- Parameters:
phase (torch.Tensor) – Phase values in radians
- Return type:
Examples
>>> light.set_phaseY(torch.zeros(1,1,512,512))
- set_plane_light()[source]¶
Set plane wave with unit amplitude and zero phase. :rtype:
None
Examples
>>> light.set_plane_light()
- Return type:
None
- set_real(real)[source]¶
Set real part for both X and Y components.
- Parameters:
real (torch.Tensor or tuple) – Real values for both components or tuple of (realX, realY)
- Return type:
Examples
>>> light.set_real(torch.ones(1,1,512,512)) >>> light.set_real((x_real, y_real))
- set_realX(real)[source]¶
Set real part of X-polarized field.
- Parameters:
real (torch.Tensor) – Real component values
- Return type:
Examples
>>> light.set_realX(torch.ones(1,1,512,512))
- set_realY(real)[source]¶
Set real part of Y-polarized field.
- Parameters:
real (torch.Tensor) – Real component values
- Return type:
Examples
>>> light.set_realY(torch.ones(1,1,512,512))
- set_spherical_light(z, dx=0, dy=0)[source]¶
Set spherical wavefront from point source.
- Parameters:
- Return type:
Examples
>>> light.set_spherical_light(0.1, dx=1e-3)