Files
fourierOptics/scripts/off_axis_test.py
T

68 lines
2.0 KiB
Python

#!/usr/bin/env Python3
import numpy as np
from pdb import set_trace
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
from matplotlib.colors import LogNorm
import time
import sys
sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics')
from fourierOptics import *
def phaseTilt(x,y,tx,ty):
phaseTilt = x * np.tan(np.deg2rad(tx)) + y * np.tan(np.deg2rad(ty))
return phaseTilt
if __name__ == '__main__':
plt.rc('font', family='serif')
plt.rc('axes', labelsize='large')
# Start time counter
start = time.time()
lList = [30e-3, 32.5e-3, 35e-3, 37.5e-3, 40e-3]
Exyz_list = []
# Pick a wavelength
l = 30e-3
for l in lList:
# Initiate Fourier Optics
fou = FourierOptics(l=l)
# Pick sampling parameters
dpix = 1/20
n, m = 2001, 2001
print ('Your resolution is {}x{} with a pixel size of {}'.format(n,m,dpix))
# Initiate the profiles class and pick a profile (tophat, obscured tophat or spider)
prof = Profiles()
A = prof.top_hat(2.5, n, m, dpix=dpix, oversample=1)
# A = prof.ELT_pupil(n,m,dpix)
plt.imshow(np.abs(A))
# Create an input grid
x, y = np.meshgrid(np.linspace(-n/2*dpix, n/2*dpix, n), np.linspace(-m/2*dpix, m/2*dpix, m))
# Create a lens with a focal length ~100 mm, with a clear aperture radius of 4 mm and thickness of 1 mm.
L1 = SphericalLens('N-BK7', thickness=5, R1=100, R2=300, CA=5, name='L1')
print('Focal length of lens {} is {:.1f} mm.'.format(L1.name, L1.f))
# L1.add_wavefront_error(phaseTilt(x,y,tx=0,ty=2.5))
# Calculate the phase delay introduced by the lens
t_l = L1.phase_delay(x,y,l, paraxial=False)
U_in = A * t_l
# Performing the propagation using Fresnel approximation to the focal plane.
oC = [x.min(), x.max(), y.min(), y.max()]
# oC = [0,x.max(),0,y.max()]
savename = False
Exyz_og,_,_ = fou.fresnel_propagation(U_in, x, y, dz=L1.f, show=True, save=savename, outputCoordinates=oC)
Exyz_list.append(Exyz_og)
Exyz = np.asarray(Exyz_list).sum(axis=0)
plt.imshow(np.abs(Exyz), cmap='hot');plt.colorbar();plt.show()