lightpipes icon indicating copy to clipboard operation
lightpipes copied to clipboard

LensFarfield in lenses.py but not in __init__.py and documentation

Open kicklop opened this issue 2 years ago • 2 comments

I found a function LensFarfield in lenses.py, but I got the error NameError: name 'LensFarfield' is not defined, when I tried to call it. It also is not in the documentation.

I added LensFarfield into the all list in init.py and was able to call the function.

kicklop avatar Jul 14 '23 10:07 kicklop

This command is still in a development state. That is why it is not available. Please check for correctness and report.

FredvanGoor avatar Jul 14 '23 21:07 FredvanGoor

I checked the LensFarfield function against Goodman's Introduction to Fourier Optics, where the equation for field propagate to the focal plane of the lens is this: $U_f(u, v)= \frac{\exp \left[j \frac{k}{2 f}\left(u^2+v^2\right)\right]}{j \lambda f} \times \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} U_l(x, y) \exp \left[-j \frac{2 \pi}{\lambda f}(x u+y v)\right] d x d y.$

The scaling of the size of the Field in the LensFarfield function is correct. However, element in front of the Fourier transform is omitted.

EDIT: The field should also be ifftshifted before doing fft2. EDIT2: Missed constant phase factor (exp(jkf))

The function should look like this:

def LensFarfield(Fin, f ):
    Fout = Field.copy(Fin)
    dx = Fout.dx
    lam = Fout.lam
    L_prime = lam * f / dx
    focusfield = _np.fft.fftshift(_np.fft.fft2(_np.fft.ifftshift(Fout.field))) #added ifftshift
    Fout.field = focusfield / (1j*lam*f) *  _np.exp(1j*k*f) #changed line
    Fout.siz = L_prime
    Fout = Lens(Fout, -f) #new line
    Fout._IsGauss=False
    return Fout

kicklop avatar Aug 12 '23 12:08 kicklop