Пример #1
0
# %%  Derived Values  #########################################################
k = 2 * np.pi * 10**(3) / lamda  # Wave number [um-1]

# %%  Input Field: Point Object Field #########################################
# Define Array ================================================================
ROI_rad = 1.5 * max(w0, Rad_airy)  # radius of ROI, defines small ROI [um]
x = np.linspace(-ROI_rad, ROI_rad, Nx)
y = np.linspace(-ROI_rad, ROI_rad, Ny)
[X1, Y1] = np.meshgrid(x, y)
R1 = np.sqrt(X1**2 + Y1**2)
# Generating Data =============================================================
E1 = GB.PointSourceVec(1, R1[:, :], 0, w0, k)
I1 = GB.BeamInt(E1, P)
# Generating the PSF, ASF = sqrt(PSF) and generating the Image ================
ASF = OE.ASF(X1, Y1, Rad_airy, kind='airy')


def func(x):
    return np.sum(OE.ImageViaPSF(X1, Y1, E1, ASF, norm=x)) - np.sum(I1)


norm = optimize.fsolve(func, 1 / np.sum(ASF))
I1_blur = OE.ImageViaPSF(X1, Y1, E1, ASF, norm=norm)

figure = plotAll3(11, X1, Y1, I1, (norm * ASF), I1_blur, ROI_rad, 1, 1, NA=NA)
cwd = os.getcwd()
os.chdir(startUp.saveDir)
figure.set_size_inches(10, 5)
figure.savefig('ImageBlur_uniformDisk.png')
os.chdir(cwd)
Пример #2
0
def func(x):
    return np.sum(OE.ImageViaPSF(X1, Y1, E1, ASF, norm=x)) - np.sum(I1)
Пример #3
0
p0 = [np.max(I1), 0, 0, w0, w0]
[params1, _] = optimize.curve_fit(GB.GaussBeamFit, [X1, Y1], I1.ravel(), p0=p0)
I1_fit = GB.GaussBeamFit([X1, Y1], *params1).reshape(Ny, Nx)
figure = plotGaussianBeam(1, X1, Y1, I1, I1_fit, params1, 1, 1)
cwd = os.getcwd()
os.chdir(startUp.saveDir)
figure.set_size_inches(10, 7)
figure.savefig('GS_inputBeam.png')
os.chdir(cwd)

# %% Cylindrical Lens f_cyY1 #################################################
# Generating Data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[E2, X2, Y2] = OE.CylLensAction(E1,
                                X1,
                                Y1,
                                k,
                                f_cyY1,
                                FocusingAxis='Y',
                                FocusedAxis='None')
I2 = GB.BeamInt(E2, P)
# Generating Fits %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I2 = I2.astype(float)
p0 = [np.max(I2), 0, 0, w0, 10]
[params2, _] = optimize.curve_fit(GB.GaussBeamFit, [X2, Y2], I2.ravel(), p0=p0)
I2_fit = GB.GaussBeamFit((X2, Y2), *params2).reshape(Ny, Nx)
plotGaussianBeam(2, X2, Y2, I2, I2_fit, params2, 1, 0.07)

# %% Cylindrical Lens f_cyY2  #################################################
# Generating Data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[E3, X3, Y3] = OE.CylLensAction(E2,
                                X2,
Пример #4
0
I1 = GB.BeamInt(E1,P)
# Generating Fit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I1 = I1.astype(float)
p0 = [np.max(I1),0,0,w0,w0]
[params1,_] = optimize.curve_fit(GB.GaussBeamFit, [X1,Y1], I1.ravel(), p0=p0)
I1_fit = GB.GaussBeamFit([X1,Y1],*params1).reshape(Ny,Nx)
figure = plotGaussianBeam(1,X1,Y1,I1,I1_fit,params1,1,1)
cwd = os.getcwd()
os.chdir(startUp.saveDir)
figure.set_size_inches(10, 7)
figure.savefig('GS_inputBeam.png')
os.chdir(cwd)

# %% Cylindrical Lens f1 = -40 mm #############################################
# Generating Data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[E2, X2, Y2] = OE.CylLensAction(E1,X1,Y1,k,f1,FocusingAxis = 'Y')
I2 = GB.BeamInt(E2,P)
# Generating Fits %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I2 = I2.astype(float)
p0 = [np.max(I2),0,0,w0,10]
[params2,_] = optimize.curve_fit(GB.GaussBeamFit, [X2,Y2], I2.ravel(),p0 = p0)
I2_fit = GB.GaussBeamFit((X2,Y2),*params2).reshape(Ny,Nx)
plotGaussianBeam(2,X2,Y2,I2,I2_fit,params2,0.5,0.5)

# %% Spherical lens f2 = +300 mm ##############################################
# Generating Data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                             
[E3, X3, Y3] = OE.SphLensAction(E2,X2,Y2,k,f2,FocussedAxis ='Y')
I3 = GB.BeamInt(E3,P)
# Generating Fits %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I3 = I3.astype(float)
p0 = [np.max(I3),0,0,100,w0]
Пример #5
0
import OpticalElements as ope
import matplotlib.pyplot as plt
import numpy as np

# Define point source
rays = [ope.ray(th, 0) for th in np.linspace(-10, 10, 10)]

# Initialize elements
fs1 = ope.free_space(10)
fs2 = ope.free_space(20)
L1 = ope.lens(10)
L2 = ope.lens(20)

# Create optical path
P = ope.path(fs1, L1, fs1, fs2, L2, fs2)

# Calculate ray coordinates along the path, P
coords_list = [P.calc_coords(r) for r in rays]

# Plot rays and lenses
fig, ax = plt.subplots()
for x, y in coords_list:
    ax.plot(x, y, color='C0')
P.plot_lenses(ax)

ax.grid(True)
ax.set_aspect('equal')
plt.show()
Пример #6
0
import OpticalElements as ope
import matplotlib.pyplot as plt
import numpy as np

# Initialize elements
fs = ope.free_space(10)
L = ope.lens(10)

# Define ray 0mm above the optic axis at an angle of 10deg
ray = ope.ray(0, 10*np.pi/180)

# Create optical path
P = ope.path(fs, L, fs)

# Calculate ray coordinates along the path, P
x_coords, y_coords = P.calc_coords(ray)

# Plot rays and lenses
fig, ax = plt.subplots()
ax.plot(x_coords, y_coords, color='C0')
P.plot_lenses(ax)

ax.grid(True)
ax.set_aspect('equal')
plt.show()
Пример #7
0
p0 = [np.max(I1), 0, 0, w0, w0]
[params1, _] = optimize.curve_fit(GB.GaussBeamFit, [X1, Y1], I1.ravel(), p0=p0)
I1_fit = GB.GaussBeamFit([X1, Y1], *params1).reshape(Ny, Nx)
plotGaussianBeam(1,
                 X1,
                 Y1,
                 I1,
                 ROI_rad_L,
                 1.5,
                 1.5,
                 Fit=I1_fit,
                 params=params1)

# %% PROBE Field Evolution through the 4F SYSTEM ##############################
# Generating Data =============================================================
[E2, X2, Y2] = OE.SphLensAction(E1, X1, Y1, k, f1, FocussedAxis='NONE')
I2 = GB.BeamInt(E2, P)
E2_ap = CircularAperture(E2, X2, Y2, Ap_rad, 0, 0)
I2_ap = GB.BeamInt(E2_ap, P)
[E3, X3, Y3] = OE.SphLensAction(E2_ap, X2, Y2, k, f2, FocussedAxis='XY')
I3 = GB.BeamInt(E3, P)
#Generating Fits ==============================================================
I2 = I2.astype(float)
p0 = [np.max(I2), 0, 0, 1, 1]
[params2, _] = optimize.curve_fit(GB.GaussBeamFit, (X2, Y2), I2.ravel(), p0=p0)
I2_fit = GB.GaussBeamFit((X2, Y2), *params2).reshape(Nx, Ny)
plotGaussianBeam(2,
                 X2,
                 Y2,
                 I2,
                 ROI_rad_L,