from fGenerateLGBeam import Generate_LG_Beam
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt

sig = ('A', 'phi', 'I')
M, N = 512, 512
pixelsize = 16
lmda = 1.55
w0 = 1200

zR = np.pi * w0 * w0 / lmda  #Rayleigh_length
print('Rayleigh_length=', zR)
G_np = Generate_Gaussian_Beam(M, N, pixelsize, w0)
Gp_np = AngularSpectrumPropagation(G_np, M, N, pixelsize, zR, lmda)
LG_np = Generate_LG_Beam(2, M, N, pixelsize, w0)
LGp_np = AngularSpectrumPropagation(LG_np, M, N, pixelsize, zR, lmda)

################ASM##################
z = zR

x = np.array(list(range(M)))  #;x=1:M;
y = np.array(list(range(N)))  # # y=1:N

#
L0X = pixelsize * M  # L0X=pixelsize*M;
L0Y = pixelsize * N  # L0Y=pixelsize*N;
#
k = 2 * np.pi / lmda  # k=2*pi/lambda;
u = lmda * (-M / L0X / 2 + 1 / L0X * x)  # u=lambda*(-M/L0X/2+1/L0X*(x-1));
v = lmda * (-N / L0Y / 2 + 1 / L0Y * y)  # v=lambda*(-N/L0Y/2+1/L0Y*(y-1));
import tensorflow as tf
import numpy as np
from fGenerateLGBeam import Generate_LG_Beam
np.random.seed(1)
pixelsize = 512

U0 = tf.constant(Generate_LG_Beam(2, 8, 8, pixelsize, 1200),
                 dtype=tf.complex64)
L1 = tf.Variable(2 * np.pi * np.random.random(size=(16, 16)),
                 dtype=tf.float64)  #i.e.PM
F1 = tf.multiply(U0, tf.exp(1j * tf.cast(L1, tf.complex64)))

################ASM##################
lmda = 1.55
z = 1000
N, M = 16, 16  # [N,M]=size(U0);
x = np.array(list(range(16)))  #;x=1:M;
y = np.array(list(range(16)))  # # y=1:N

#
L0X = pixelsize * M  # L0X=pixelsize*M;
L0Y = pixelsize * N  # L0Y=pixelsize*N;
#
k = 2 * np.pi / lmda  # k=2*pi/lambda;
u = lmda * (-M / L0X / 2 + 1 / L0X * x)  # u=lambda*(-M/L0X/2+1/L0X*(x-1));
v = lmda * (-N / L0Y / 2 + 1 / L0Y * y)  # v=lambda*(-N/L0Y/2+1/L0Y*(y-1));

uu, vv = np.meshgrid(u, v)  # [uu,vv] = meshgrid(u,v);
K = 1 - np.multiply(uu, uu) - np.multiply(vv, vv) + 0j
#K[K<0]=0
Beispiel #3
0
M, N = 1024, 1024
pixelsize = 16
w0 = 1200
z1 = 30000
z2 = 5000
lmda = 1.55

s = ['0', '1', '2', '3', '4']
L = [
    np.loadtxt("E:/Tensorflow1/result/result21/L%s.csv" % i, delimiter=",")
    for i in s
]
P = []

for i in range(9):
    U = Generate_LG_Beam(i - 4, M, N, pixelsize, w0)
    U0 = np.multiply(U, np.exp(1j * L[0]))
    U1 = AngularSpectrumPropagation(U0, M, N, pixelsize, z2, lmda)
    U1 = np.multiply(U1, np.exp(1j * L[1]))
    U2 = AngularSpectrumPropagation(U1, M, N, pixelsize, z1, lmda)
    U2 = np.multiply(U2, np.exp(1j * L[2]))
    U3 = AngularSpectrumPropagation(U2, M, N, pixelsize, z2, lmda)
    U3 = np.multiply(U3, np.exp(1j * L[3]))
    Uz = AngularSpectrumPropagation(U3, M, N, pixelsize, z1, lmda)
    Px = np.abs(np.multiply(Uz, np.conj(Uz) * pixelsize * pixelsize))
    # plt.subplot(3,3,i+1)
    # plt.axis("off")
    # c0 = plt.pcolor(-Px[256:768,256:768],cmap=plt.cm.Greys)
    P.append(Px)
# plt.show()
P_center = [Px[0:1024, 0:1024] for Px in P]
Beispiel #4
0
lmda = 1.55
w0 = 1200

zR = np.pi * w0 * w0 / lmda  #Rayleigh_length
print('Rayleigh_length=', zR)
G_np = Generate_Gaussian_Beam(M, N, pixelsize, w0)
G_np_A = np.abs(G_np)
G_np_phi = np.angle(G_np)
G_np_I = np.abs(np.multiply(G_np, np.conj(G_np)))

Gp_np = AngularSpectrumPropagation(G_np, M, N, pixelsize, zR, lmda)
Gp_np_A = np.abs(Gp_np)
Gp_np_phi = np.angle(Gp_np)
Gp_np_I = np.abs(np.multiply(Gp_np, np.conj(Gp_np)))

LG_np = Generate_LG_Beam(2, M, N, pixelsize, w0)
LG_np_A = np.abs(LG_np)
LG_np_phi = np.angle(LG_np)
LG_np_I = np.abs(np.multiply(LG_np, np.conj(LG_np)))

LGp_np = AngularSpectrumPropagation(LG_np, M, N, pixelsize, zR, lmda)
LGp_np_A = np.abs(LGp_np)
LGp_np_phi = np.angle(LGp_np)
LGp_np_I = np.abs(np.multiply(LGp_np, np.conj(LGp_np)))

plt.figure(figsize=(9.2, 6.8))

plt.subplot(3, 4, 1)
plt.axis("off")
plt.pcolor(G_np_A)
plt.subplot(3, 4, 5)
from fGenerateLGBeam import Generate_LG_Beam
import numpy as np
import matplotlib.pyplot as plt

pixelsize = 16
LG = Generate_LG_Beam(8, 256, 256, 16, 1200)

I = np.abs(LG * np.conj(LG) * pixelsize * pixelsize)
phi = np.angle(LG)
I_sum = np.sum(I)

print("I_sum=", I_sum)

fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(10, 5))
c = ax0.pcolor(I)
ax0.set_title('Intensity')
ax0.set_axis_off()
c = ax1.pcolor(phi)
ax1.set_title('Phase')
ax1.set_axis_off()
fig.tight_layout()
plt.show()
Beispiel #6
0
import numpy as np
from fGenerateLGBeam import Generate_LG_Beam
from Prop import AngularSpectrumPropagation
import matplotlib.pyplot as plt
from BeamGenerator import LG_Beam

LG1 = LG_Beam(5, 3, 512, 512, 32, 1200, 1000, 1.55)
LG2 = Generate_LG_Beam(3, 512, 512, 32, 1200)
A = np.abs(LG1)
B = np.abs(LG2)
IA = np.multiply(LG1, np.conj(LG1)) * 32 * 32
IB = np.multiply(LG2, np.conj(LG2)) * 32 * 32

plt.figure(figsize=(9, 9))
plt.pcolor(A)
plt.figure(figsize=(9, 9))
plt.pcolor(B)
print(np.sum(IA), np.sum(IB))
plt.show()