Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kicklop opened this issue Jul 14, 2023 · 2 comments
Open

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

kicklop opened this issue Jul 14, 2023 · 2 comments

Comments

@kicklop
Copy link

kicklop commented Jul 14, 2023

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.

@FredvanGoor
Copy link
Member

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

@kicklop
Copy link
Author

kicklop commented Aug 12, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants