odak.learn.wave.quadratic_phase_function¶
A definition to generate 2D quadratic phase function, which is typically use to represent lenses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nx |
int |
Size of the output along X. |
required |
ny |
int |
Size of the output along Y. |
required |
k |
odak.wave.wavenumber |
See odak.wave.wavenumber for more. |
required |
focal |
float |
Focal length of the quadratic phase function. |
0.4 |
dx |
float |
Pixel pitch. |
0.001 |
offset |
list |
Deviation from the center along X and Y axes. |
[0, 0] |
Returns:
Type | Description |
---|---|
torch.tensor |
Generated quadratic phase function. |
Source code in odak/learn/wave/lens.py
def quadratic_phase_function(nx, ny, k, focal=0.4, dx=0.001, offset=[0, 0]):
"""
A definition to generate 2D quadratic phase function, which is typically use to represent lenses.
Parameters
----------
nx : int
Size of the output along X.
ny : int
Size of the output along Y.
k : odak.wave.wavenumber
See odak.wave.wavenumber for more.
focal : float
Focal length of the quadratic phase function.
dx : float
Pixel pitch.
offset : list
Deviation from the center along X and Y axes.
Returns
-------
function : torch.tensor
Generated quadratic phase function.
"""
size = [nx, ny]
x = torch.linspace(-size[0]*dx/2, size[0]*dx/2, size[0])-offset[1]*dx
y = torch.linspace(-size[1]*dx/2, size[1]*dx/2, size[1])-offset[0]*dx
X, Y = torch.meshgrid(x, y, indexing='ij')
Z = X**2+Y**2
focal = torch.tensor([focal])
k = torch.tensor([k])
qwf = torch.exp(1j*k*0.5*torch.sin(Z/focal))
return qwf
Notes¶
Here is a short example on how to use this function:
from odak.learn.wave import wavenumber,quadratic_phase_function
wavelength = 0.5*pow(10,-6)
pixeltom = 6*pow(10,-6)
distance = 10.0
resolution = [1080,1920]
k = wavenumber(wavelength)
lens_field = quadratic_phase_function(
resolution[0],
resolution[1],
k,
focal=0.3,
dx=pixeltom
)