Exemplo n.º 1
0
 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')        
Exemplo n.º 2
0
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()))
Exemplo n.º 3
0
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()))
Exemplo n.º 4
0
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')
Exemplo n.º 5
0
 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))
Exemplo n.º 6
0
 def setUp(self):
     self.gb = GaussianBeam((8.0, -50.0), 2*np.pi/3.0)