alpha = 1e-4 Lgain = 1e4 F = Field(N, size, wavelength) randomize.intensity(F) randomize.phase(1, F) SR = dict() for l in xrange(10): F.rectangular_aperture(w, w) F.l_amplify(alpha, Lgain, Isat) F.lens_fresnel(f1, L) F.l_amplify(alpha, Lgain, Isat) F.lens_fresnel(f2, L) SR[l] = F.get_strehl() F.interpolate(size, N) print 'Round trip {l} Strehl ratio= {s}'.format(l=l, s=SR[l]) F2 = F.copy() F2.rectangular_screen(w, w) imshow(abs(F2.value)**2) # plot intensity show() time.sleep(.3) F2.spherical_to_normal_coords() print 'SR: ', SR SR = SR.items() SR.sort(key=lambda v: v[0]) SR = array(SR)
""".format(*choices) choice = raw_input() if choice not in ['0','1','2','3']: break choice = int(choice) F = Field(N,size,wavelength) F.circular_aperture(R) if choice == 3: F.lens(f) else: k = choice F.zernike(nZ[k],mZ[k],RZ[k],AZ[k]) F.forvard(z1) F1 = F.copy() F1.value[:] *= Rplate F.value[:] *= (1 - Rplate) F.interpolate(size,N,D,D1) F.value[:] += F1.value Int = (F.value * F.value.conj()).real if im: im.set_array(Int) else: im = imshow(Int) title( choices[choice] ) draw()