def testTelescope2(self): # import matplotlib # matplotlib.use('AGG') # import matplotlib.mlab as ml # import pylab as pl # import time w0 = 1.0 k = 1000 * 2 * np.pi / 1.064 gb = GaussianBeam(w0, k) lens = ThinLens(50, 50) gb2 = lens * gb # self.assertAlmostEqual(gb2._z0, gb._z0 + 2*151.0) lens2 = ThinLens(100, 160) gb3 = lens2 * gb2 # self.assertAlmostEqual(gb3._z0, gb2._z0 + 2*300.0) # self.assertAlmostEqual(gb._w0, gb3._w0/2.0) lens3 = ThinLens(18.58, 380) gb4 = lens3 * gb3 z = np.arange(0, 50) z2 = np.arange(50, 160) z3 = np.arange(160, 380) z4 = np.arange(380, 450) pl.plot(z, gb.w(z, k), "g", z2, gb2.w(z2, k), "g", z3, gb3.w(z3, k), "g", z4, gb4.w(z4, k), "g") # pl.grid() w_0 = min(gb4.w(z4, k)) z_0 = [i for i, x in enumerate(gb4.w(z4, k)) if x == w_0] pl.title("Example of brilliant optical design!" + "w_0 = " + str(w_0) + " z_0 = " + str(z_0[0] + 380)) pl.xlabel("z") pl.ylabel("w") pl.savefig("testTelescope2.png") time.sleep(0.1) pl.close("all")
def testTelescope(self): import matplotlib matplotlib.use('AGG') import matplotlib.mlab as ml import pylab as pl import time w0 = 8.0 k = 2*np.pi/3.0 gb = GaussianBeam(w0, k) lens = ThinLens(150, 150) gb2 = lens*gb self.assertAlmostEqual(gb2._z0, gb._z0 + 2*150.0) lens2 = ThinLens(300, 600) gb3 = lens2*gb2 self.assertAlmostEqual(gb3._z0, gb2._z0 + 2*300.0) self.assertAlmostEqual(gb._w0, gb3._w0/2.0) z = np.arange(0, 150) z2 = np.arange(150, 600) z3 = np.arange(600, 900) pl.plot(z, gb.w(z, k), z2, gb2.w(z2, k), z3, gb3.w(z3, k)) pl.grid() pl.xlabel('z') pl.ylabel('w') pl.savefig('testTelescope1.png') time.sleep(0.1) pl.close('all')
def width_plot(): # This function creates a plot of the beam width through the lens system if wavelength.get() and power.get() and div.get() and dist.get() and foc.get() and z.get(): beam = GaussianBeam.GaussianBeam(float(wavelength.get())*1e-9, float(power.get())*1e-3, float(div.get()), 0) distances = list(map(float, dist.get().split(','))) focal_lengths = list(map(float, foc.get().split(','))) beam.thinLensPlot(distances, focal_lengths, 0, float(z.get()))
def testClasses(self): w0 = 8.0 lam = 3.0 k = 2*np.pi/lam zc = confocalDistance(w0, k) z = np.array([0, zc]) q = complexBeamParameter(zc, z) #print "Testing GaussianBeam class" gb = GaussianBeam(beamWaist(q[0], k), k) (R,Z)= pl.meshgrid(np.arange(-24,24), np.arange(0,100)) #if not dryTest: pl.figure(); pl.imshow(abs(gb.field(R, Z))) d = 10.0 q = gb.q(0) abcd = np.matrix([[1, d],[0, 1]], dtype=float) qo = abcd*q self.assertEqual(qo, gb.q(d)) #print "Testing ParaxialElement class" el = ParaxialElement(abcd, 0) gb2 = el*gb #print gb2.q(0) #print gb.q(d) self.assertEqual(gb2.q(0), gb.q(d))
def intensity_plot(): # This function creates a plot of the intensity at the specified distance through the system if wavelength.get() and power.get() and div.get() and dist.get() and foc.get() and z.get(): beam = GaussianBeam.GaussianBeam(float(wavelength.get())*1e-9, float(power.get())*1e-3, float(div.get())) distances = list(map(float, dist.get().split(','))) focal_lengths = list(map(float, foc.get().split(','))) if xw.get() and not yw.get(): beam.lensSystemIntensity(distances, focal_lengths, float(z.get()), xw=float(xw.get())/100) elif not xw.get() and yw.get(): beam.lensSystemIntensity(distances, focal_lengths, float(z.get()), yw=float(yw.get())/100) elif xw.get() and yw.get(): beam.lensSystemIntensity(distances, focal_lengths, float(z.get()), xw=float(xw.get())/100, yw=float(yw.get())/100) else: beam.lensSystemIntensity(distances, focal_lengths, float(z.get()))
def update(): # This function updates the labels to give the user the parameters if wavelength.get() and power.get() and div.get() and dist.get() and foc.get() and z.get(): beam = GaussianBeam.GaussianBeam(float(wavelength.get())*1e-9, float(power.get())*1e-3, float(div.get()), 0) distances = list(map(float, dist.get().split(','))) focal_lengths = list(map(float, foc.get().split(','))) width = beam.thinLensFunction(distances, focal_lengths)(float(z.get())) for i in range(len(distances)): beam = beam.thinLens(distances[i], focal_lengths[i]) angle = beam.divergence PR = beam.squareAperturePower(float(z.get()), float(xw.get())/100, float(yw.get())/100) W.set('Beam Diameter: ' + np.format_float_scientific(200*width, 3) + ' cm') theta.set('Beam Divergence: ' + np.format_float_scientific(angle, 3) + ' degrees') power_R.set('Power Recieved: ' + np.format_float_scientific(1000*PR, 3) + ' mW')
def setUp(self): self.gb = GaussianBeam((8.0, -50.0), 2*np.pi/3.0)
AtomicDen_RingVec = np.vectorize(AtomicDen_Ring) # %% 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)
P = 350 # Total power in beam[mW] PP_offset = 0 # Vertical shift of the phase plate[mm] PP_tilt = 0 # Phase plate [degrees] # focal lengths of Cylindrical lenses ######################################### f_cyX1 = 600 # Focal length of first lens [mm] # Focal length of second lens [mm] f_cyY1 = 40 # Focal length of first lens [mm] f_cyY2 = 600 # Focal length of second lens [mm] f_sph = 400 # Focal length of second lens [mm] # Array Parameters ############################################################ Nx = 2**7 Ny = 2**7 Nz = 5 # %% Derived Values ########################################################### k = 2 * np.pi * 10**(3) / lamda # wave number [um-1] zmin = -4 * GB.RayleighLength(k, w0) zmax = 4 * GB.RayleighLength(k, w0) x = np.linspace(-10 * w0, 10 * w0, Nx) y = np.linspace(-10 * w0, 10 * w0, Ny) z = np.linspace(zmin, zmax, Nz) [X, Y, Z] = np.meshgrid(x, y, z) R = np.sqrt(X**2 + Y**2) THETA = np.arctan2(Y, X) # %% Common Functions ############################################## def plotGaussianBeam(num, X, Y, I, I_fit, params, alpha_X, alpha_Y): # Plot a gaussian beam # Inputs: # num: figure number
f1 = +300 # Focal length of first lens [mm] Ap_rad = 1 # radius of aperture [mm] f2 = +300 # Focal length of second lens [mm] sigma = 3 * (589 * 10**-9)**2 / ( 2 * np.pi) * 10**12 # Absorption cross section [um^2] # Atomic Distribution Properties ============================================== RingRad = 100 # Radius of atomic ring [um] RingThk = 20 # Radius of atomic ring [um] N = 100e+3 # Number of atoms # Array Parameters ============================================================ Nx = 2**8 # No. of point in X Ny = 2**8 # No. of point in Y Nz = 5 # No. of point in Z # %% Derived Values ########################################################### k = 2 * np.pi * 10**(3) / lamda # Wave number [um-1] zmin = -4 * GB.RayleighLength(k, w0) # Min Z value [um] zmax = 4 * GB.RayleighLength(k, w0) # Max Z value [um] # Larger Array ============================================================== ROI_rad_L = 50 # radius of ROI, defines small ROI [mm] x = np.linspace(-10 * w0, 10 * w0, Nx) y = np.linspace(-10 * w0, 10 * w0, Ny) z = np.linspace(zmin, zmax, Nz) [X_L, Y_L, Z_L] = np.meshgrid(x, y, z) R_L = np.sqrt(X_L**2 + Y_L**2) THETA_L = np.arctan2(Y_L, X_L) # Smaller Array =============================================================== ROI_rad_S = 500 # radius of ROI, defines small ROI [um] x = np.linspace(-ROI_rad_S, ROI_rad_S, Nx) y = np.linspace(-ROI_rad_S, ROI_rad_S, Ny) z = np.linspace(zmin, zmax, Nz) [X_S, Y_S, Z_S] = np.meshgrid(x, y, z)
def testTelescope2(lamda, lamdared, d, dred, L, DM, f1, f2, l, fred, finfra, index, nr): # import matplotlib # matplotlib.use('AGG') # import matplotlib.mlab as ml # import pylab as pl # import time w0 = d / 2 w0_red = dred / 2 k = 1000000 * 2 * np.pi / lamda kred = 1000000 * 2 * np.pi / lamdared gb = GaussianBeam(w0, k) gbred = GaussianBeam(w0_red, kred) lens = ThinLens(f1, 10) gb2 = lens * gb # self.assertAlmostEqual(gb2._z0, gb._z0 + 2*151.0) lens2 = ThinLens(f2, f1 + f2 + l + 10) gb3 = lens2 * gb2 # self.assertAlmostEqual(gb3._z0, gb2._z0 + 2*300.0) # self.assertAlmostEqual(gb._w0, gb3._w0/2.0) lens3 = ThinLens(finfra, L) lensred = ThinLens(fred, L) gb4 = lens3 * gb3 gbred2 = lensred * gbred z = np.arange(0, 10) z2 = np.arange(10, f1 + f2 + l + 10) z3 = np.arange(f1 + f2 + l + 10, L) z4 = np.arange(L, L * 1.2, 0.01) zred = np.arange(0, L) zred2 = np.arange(L, L * 1.2, 0.01) zl = np.array([10, f1 + f2 + l + 10, DM, L]) ffinfrared = np.array([f1, f2, float("inf"), finfra]) names = ["L1", "L2", "DM", "IL"] for i in range(np.size(zl)): add_lens(zl[i], ffinfrared[i], w0_red * 1.1, L, names[i], 0.4) # "L"+str(i)) for i in range(nr + 1): factor = i * 1.0 / nr pl.plot( z, gb.w(z, k) * factor, "g", z2, gb2.w(z2, k) * factor, "g", z3, gb3.w(z3, k) * factor, "g", z4, gb4.w(z4, k) * factor, "g", ) pl.plot( z, -gb.w(z, k) * factor, "g", z2, -gb2.w(z2, k) * factor, "g", z3, -gb3.w(z3, k) * factor, "g", z4, -gb4.w(z4, k) * factor, "g", ) pl.plot(zred, gbred.w(zred, kred) * factor, "r", zred2, gbred2.w(zred2, kred) * factor, "r") pl.plot(zred, -gbred.w(zred, kred) * factor, "r", zred2, -gbred2.w(zred2, kred) * factor, "r") # pl.plot(z, gb.w(z, k), 'g', z2, gb2.w(z2, k), 'g', z3, gb3.w(z3, k), 'g', z4, gb4.w(z4, k), 'g') # pl.plot(z, -gb.w(z, k), 'g', z2, -gb2.w(z2, k), 'g', z3, -gb3.w(z3, k), 'g', z4, -gb4.w(z4, k), 'g') # pl.plot(zred, gbred.w(zred, kred), 'r', zred2, gbred2.w(zred2, kred), 'r') # pl.plot(zred, -gbred.w(zred, kred), 'r', zred2, -gbred2.w(zred2, kred), 'r') # pl.grid() w_0 = min(gb4.w(z4, k)) z_0 = [i for i, x in enumerate(gb4.w(z4, k)) if x == w_0] w_0red = min(gbred2.w(zred2, kred)) z_0red = [i for i, x in enumerate(gbred2.w(zred2, kred)) if x == w_0red] if z_0[0] * 0.01 + np.size(zred) < z_0red[0] * 0.01 + np.size(zred): NA = (gb4.w(np.size(zred), k) + gb4.w(z_0red[0] * 0.01 + np.size(zred), k)) / (z_0red[0] * 0.01) else: NA = (gb4.w(np.size(zred), k) - gb4.w(z_0red[0] * 0.01 + np.size(zred), k)) / (z_0red[0] * 0.01) if z_0[0] == 0: NA = 1000 else: NA = gb4.w(np.size(zred), k) / (z_0[0] * 0.01) pl.title( "$w_0^{red}$ = " + str(w_0red * 2000) + "$\mu m \quad z_0^{red}$ = " + str(z_0red[0] * 0.01 + np.size(zred)) + "$\ z_0$ = " + str(z_0[0] * 0.01 + np.size(zred)) + "\nbeamsize($z_0^{red}$) = " + str(gb4.w(z_0red[0] * 0.01 + np.size(zred), k) * 2000) + "$\mu m$ NA = " + str(NA) ) # "z(waist red) = " + str(z_0[0]*0.01+np.size(zred)) +) pl.xlabel("z") pl.ylabel("w") pl.axis([0, L + finfra * 1.5, -w0_red * 4, w0_red * 4]) pl.savefig("testTelescope" + str(index) + ".png") add_lens(z_0red[0] * 0.01 + np.size(zred), float("inf"), gb4.w(z_0red[0] * 0.01 + np.size(zred), k), L, "", 1.0) pl.axis([L + finfra * 0.8, L + finfra * 1.3, -0.2, 0.2]) pl.savefig("testTelescope_zoom" + str(index) + ".png") time.sleep(0.1) pl.close("all") # result = [2*w_0,z_0[0], 2*w_0red,z_0red[0], 2*gb4.w(z_0red[0],k), abs(z_0[0] - z_0red[0]), 2*gb4.w(z_0red[0]*0.01+np.size(zred),k)] result = [ abs(2 * gb4.w(z_0red[0] * 0.01 + np.size(zred), k) - 2 * w_0red), (gb4.w(np.size(zred), k) - gb4.w(z_0red[0] * 0.01 + np.size(zred), k)) / (z_0red[0] * 0.01), w0_red / (z_0red[0] * 0.01), ] # result = gb4.w return result