opticspy / lightpipes

LightPipes for Python, "Pure Python version"
https://opticspy.github.io/lightpipes/
BSD 3-Clause "New" or "Revised" License
227 stars 52 forks source link

Support for astigmatic beams #52

Open jmmelko opened 3 years ago

jmmelko commented 3 years ago

As explained in A. Siegman, Lasers, the Hermite-Gaussian modes can be straightforwardly generalized to astigmatic beams: umn(x,y,z) = um(x,z) * un(y,z)

That would be cool if LightPipes could provide native support for that, at least in the GaussBeam class, with wx, wy as input parameters.

jmmelko commented 3 years ago

I have written this, but it is ugly:

def AstigGaussBeam(Fin, wx, wy, x_shift=0, y_shift=0, tx=0, ty=0):

    if wx == wy:
        return LightPipes.GaussBeam(Fin=Fin, w0=wx, x_shift=x_shift, y_shift=y_shift, tx=tx, ty=ty)    

    Ex = LightPipes.GaussBeam(Fin=Fin, w0=wx, x_shift=x_shift, y_shift=0, tx=tx, ty=0)
    Ey = LightPipes.GaussBeam(Fin=Fin, w0=wy, x_shift=0, y_shift=y_shift, tx=0, ty=ty)

    Ix = LightPipes.Intensity(Ex,0)
    Iy = LightPipes.Intensity(Ey,0)
    Phix = LightPipes.Phase(Ex)
    Phiy = LightPipes.Phase(Ey)

    (Nx, Ny) = Ix.shape
    nmidx = int(_np.round(Nx/2))
    nmidy = int(_np.round(Ny/2))

    Ix = Ix[nmidy,:]
    Ix = _np.tile(Ix, (Ny, 1))
    Iy = Iy[:,nmidx]
    Iy = _np.tile(Iy, (Nx, 1)).T

    Phix = Phix[nmidy,:]
    Phix = _np.tile(Phix, (Ny, 1))
    Phiy = Phiy[:,nmidx]
    Phiy = _np.tile(Phiy, (Nx, 1)).T    

    Eout = LightPipes.SubIntensity(Fin=Fin, Intens=sqrt(_np.multiply(Ix,Iy)))
    Eout = LightPipes.SubPhase(Fin=Eout, Phi=Phix+Phiy)

    return Eout
IvanOstr commented 3 years ago

Have you tried maybe using Zernike polynomials for this purpose? There is Zernike polynomials info in the manual.