#!/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 pickle import sys sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') from fourierOptics import * ''' @ Author: Joost van den Born ''' def saveVariable(var, filename): # Saving the objects: with open(filename, 'wb') as f: # Python 3: open(..., 'wb') pickle.dump(var, f) def loadVariable(filename): # Getting back the objects: with open(filename, 'rb') as f: # Python 3: open(..., 'rb') obj = pickle.load(f) return obj def phaseTilt(x,y,tx,ty): n,m = x.shape y,x = np.mgrid[-1:1:n*1j,-1:1:m*1j] 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') lList = np.linspace(1.49e-3, 1.78e-3, 29) Exyz_list = [] # Pick a wavelength l = 1.35e-3 # Pick sampling parameters dpix = 160 n, m = 1001, 1001 # oC = [-.75, .75, -.75, .75] # oC = [-1.65, -0.15,-1.65, -0.15] oC = [-3,3,-3,3] # Initiate the profiles class and pick a profile (tophat, obscured tophat or spider) prof = Profiles() A = prof.ELT_pupil(n,m,dpix) # 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)) # M1 = ParaxialLens(f=6.84022e5, CA=38854, name='ELT-paraxial') M1 = ParabolicMirror(dx=0, dy=0, name='ELT-paraxial', CA=38854, f=6.84022e5) M1.add_wavefront_error(phaseTilt(x,y,tx=7.5e-3, ty=7.5e-3)) for l in lList: print(l) # Initiate Fourier Optics fou = FourierOptics(l=l) print ('Your resolution is {}x{} with a pixel size of {}'.format(n,m,dpix)) # Create a lens with a focal length ~100 mm, with a clear aperture radius of 4 mm and thickness of 1 mm. t_l = M1.phase_delay(x,y,l) U_in = A * t_l # Propagating the original, unperturbed, system and calculating encircled energy Exyz_og,xp,yp = fou.fresnel_propagation(U_in, x, y, dz=M1.f, show=False, 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()