diff --git a/demonstration scripts/fixing_things.py b/demonstration scripts/fixing_things.py deleted file mode 100644 index 86dd445..0000000 --- a/demonstration scripts/fixing_things.py +++ /dev/null @@ -1,23 +0,0 @@ -import numpy as np -import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') -# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') -from fourierOptics import * - -if __name__ == '__main__': - # Initiate MICADO paraxial model - mcd = ParaxialMICADO() - # mcd.plot_ray_trace() - - print(mcd.platescale) - # Initiate WFE object - wfe = WavefrontError(mcd.n, mcd.m) - - # Generate PSD surfaces - psd = wfe.generate_height_map(200e-6, 2, 1) - - # Add it to ADC-P1 - mcd.ELT_ADC.p1.add_wavefront_error(psd) - - # Generate the PSF and plot it - E, x, y = mcd.propagate(l=1.35e-3,surface=-1, zoom=True, show=True) # image_output=[-.4,.4,-.4,.4] \ No newline at end of file diff --git a/demonstration scripts/generate_PSF_with_WFE.py b/demonstration scripts/generate_PSF_with_WFE.py index 745a763..d83ae60 100644 --- a/demonstration scripts/generate_PSF_with_WFE.py +++ b/demonstration scripts/generate_PSF_with_WFE.py @@ -1,8 +1,16 @@ import numpy as np import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * +''' + Description: + This script generates a point spread function of the MICADO optical model. + During the setup a wavefront error of 200 nm RMS is added to the first + prisms of the MICADO atmospheric dispersion corrector. +''' + + if __name__ == '__main__': # Initiate MICADO paraxial model mcd = ParaxialMICADO() diff --git a/demonstration scripts/generate_bahtinov_dispersion.py b/demonstration scripts/generate_bahtinov_dispersion.py index dbae72b..43ca057 100644 --- a/demonstration scripts/generate_bahtinov_dispersion.py +++ b/demonstration scripts/generate_bahtinov_dispersion.py @@ -1,9 +1,21 @@ import numpy as np import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * +''' + Description: + This script generates a point spread function of the MICADO optical model. + Here we apply a Bahtinov mask to the pupil and simulate a broadband PSF, + done through the summation of multiple (here: 15) wavelength slices. + When there is atmospheric dispersion, the diffraction speckles created by the + Bahtinov mask will start to point to a location outside the zeroth order + PSF core. + Here, atmospheric dispersion is modelled as a wavelength dependent phase + tilt. +''' + if __name__ == '__main__': # Initiate MICADO paraxial model mcd = ParaxialMICADO() diff --git a/demonstration scripts/generate_field.py b/demonstration scripts/generate_field.py index 5eb02c4..2c632eb 100644 --- a/demonstration scripts/generate_field.py +++ b/demonstration scripts/generate_field.py @@ -1,8 +1,17 @@ import numpy as np import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * -from pdb import set_trace + + +''' + Description: + This script generates nine points in a small field to illustrate the + most basic form of off-axis propagation. + For larger off-axis distances the hx and hy values should directly + be supplied to the propagate function. +''' + def field_angle(hx, hy): fx = hx * 0.0075 @@ -14,14 +23,6 @@ if __name__ == '__main__': # Initializing MICADO paraxial model mcd = ParaxialMICADO() wfe = WavefrontError(mcd.n, mcd.m) - - # Uncomment to load in WFE (coma) - # Problem here is that the field of view is too small to see - # a radial effect... - # xin, yin = load_variable('../adc_data_coordinates.pkl') - # adcObj = ADC_surfaces(xin,yin) - # zern = wfe.zernike_cartesian([0,0,0,0,0,0,0,100e-5], adcObj.xz, adcObj.yz, rescale=False) - # mcd.ELT_ADC.p1.add_wavefront_error(zern) # Setup l = 1.49e-3 diff --git a/demonstration scripts/generate_propagation_figures.py b/demonstration scripts/generate_propagation_figures.py index 922a09e..81a0a20 100644 --- a/demonstration scripts/generate_propagation_figures.py +++ b/demonstration scripts/generate_propagation_figures.py @@ -1,9 +1,14 @@ import numpy as np import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * import matplotlib.pyplot as plt -from pdb import set_trace + +''' + Description: + This script generates the amplitude and phase information of all surfaces + in the MICADO paraxial model in a nicely presented form. +''' if __name__ == '__main__': plt.rc('font', family='serif') diff --git a/demonstration scripts/thesis_propagation_figures.py b/demonstration scripts/thesis_propagation_figures.py index 5a2715c..7901698 100644 --- a/demonstration scripts/thesis_propagation_figures.py +++ b/demonstration scripts/thesis_propagation_figures.py @@ -1,10 +1,16 @@ import numpy as np import sys -# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * import matplotlib.pyplot as plt -from pdb import set_trace + +''' + Description: + This script generates the amplitude and phase information of all surfaces + in the MICADO paraxial model in a nicely presented form. +''' + + if __name__ == '__main__': plt.rc('font', family='serif') @@ -13,13 +19,9 @@ if __name__ == '__main__': # Initiate MICADO paraxial model mcd = ParaxialMICADO(n=3001, m=3001, dpix=50) - # Generate the PSF and plot it - # E, x, y = mcd.propagate(l=1.35e-3,surface=-1, zoom=True, show=True, save='all') - confList = [ ( 1, [-0.4, 0.4, -0.4, 0.4], '02_fourier_ELT-IFP.pdf'), ( 2, [-50, 50, -50, 50], '03_fourier_ELT-COL.pdf'), ( 4, [-50, 50, -50, 50], '04_fourier_ELT-MCD-ADC-P2.pdf'), - # (-1, [-1.2, 1.2, -1.2, 1.2], '05_fourier_ELT-MCD-DET.pdf')] (-1, [-1.2/2.669, 1.2/2.669, -1.2/2.669, 1.2/2.669], '05_fourier_ELT-MCD-DET.pdf')] @@ -50,4 +52,4 @@ if __name__ == '__main__': _fig.colorbar(_im2, ax=_ax2, label='Phase') plt.tight_layout() # plt.savefig('01_fourier_ELT-M1.pdf', bbox_inches='tight', transparent=True) - plt.close()#show() \ No newline at end of file + plt.show() \ No newline at end of file diff --git a/fourierOptics/__pycache__/optics.cpython-39.pyc b/fourierOptics/__pycache__/optics.cpython-39.pyc index 83ef3f5..143ed2f 100644 Binary files a/fourierOptics/__pycache__/optics.cpython-39.pyc and b/fourierOptics/__pycache__/optics.cpython-39.pyc differ diff --git a/scripts/ELT_off_axis_test.py b/scripts/ELT_off_axis_test.py index f45854d..0c5f959 100644 --- a/scripts/ELT_off_axis_test.py +++ b/scripts/ELT_off_axis_test.py @@ -1,18 +1,20 @@ #!/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') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' @ Author: Joost van den Born + @ Description: Testing a small phase tilt to create a PSF off-axis + Note on 2022-08-02: Doesn't seem to do much? Not sure about this script... ''' + def saveVariable(var, filename): # Saving the objects: with open(filename, 'wb') as f: # Python 3: open(..., 'wb') diff --git a/scripts/ELT_wfe_analysis.py b/scripts/ELT_wfe_analysis.py index 7742ef7..89bc779 100644 --- a/scripts/ELT_wfe_analysis.py +++ b/scripts/ELT_wfe_analysis.py @@ -1,17 +1,19 @@ #!/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') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' @ Author: Joost van den Born + @ Description: Script for analysing WFEs produced using either Zernike polynomials or + a PSD description. It also compares the shift in centroid position as the + complexity of the WFE increases through spatial frequency filtering. ''' def saveVariable(var, filename): # Saving the objects: @@ -80,7 +82,7 @@ if __name__ == '__main__': plt.imshow(np.abs(Exyz_og), cmap='hot');plt.colorbar();plt.show() - set_trace() + zernikeAnalysis = True PSDAnalysis = True @@ -97,7 +99,8 @@ if __name__ == '__main__': # and more modes. # Calculate the maximum mode that we want to fit the zernike modes to. - nmax, mmax = 80, 80 + # nmax, mmax = 80, 80 + nmax, mmax = 20,20 zernikeLimit = int((nmax*(nmax+2)+mmax)/2) # Fit the zernike coefficients for all modes up to zernikeLimit @@ -147,15 +150,15 @@ if __name__ == '__main__': eef_zern_list.append(eef_zern.tolist()) zernImageResponse.append(Exyz_zern) - saveVariable(x0zern, './data/x0zern.pck') - saveVariable(y0zern, './data/y0zern.pck') - saveVariable(x0zern_var, './data/x0zern_var.pck') - saveVariable(y0zern_var, './data/y0zern_var.pck') - saveVariable(zernCouplingList, './data/zernCouplingList.pck') - saveVariable(eef_zern_list, './data/eef_zern_list.pck') - saveVariable(zernImageResponse, './data/zernImageResponse.pck') - saveVariable(psd1d_list_zern, './data/psd1d_list_zern.pck') - saveVariable(zernikeCoefficients, './data/zernikeCoefficients.pcks') + # saveVariable(x0zern, './data/x0zern.pck') + # saveVariable(y0zern, './data/y0zern.pck') + # saveVariable(x0zern_var, './data/x0zern_var.pck') + # saveVariable(y0zern_var, './data/y0zern_var.pck') + # saveVariable(zernCouplingList, './data/zernCouplingList.pck') + # saveVariable(eef_zern_list, './data/eef_zern_list.pck') + # saveVariable(zernImageResponse, './data/zernImageResponse.pck') + # saveVariable(psd1d_list_zern, './data/psd1d_list_zern.pck') + # saveVariable(zernikeCoefficients, './data/zernikeCoefficients.pcks') if PSDAnalysis: # For each spatial frequency, perform the analysis @@ -208,14 +211,14 @@ if __name__ == '__main__': eef_psd_list.append(eef_psd) psdImageResponse.append(Exyz_psd) - saveVariable(x0psd, './data/x0psd.pck') - saveVariable(y0psd, './data/y0psd.pck') - saveVariable(x0psd_var, './data/x0psd_var.pck') - saveVariable(y0psd_var, './data/y0psd_var.pck') - saveVariable(psdCouplingList, './data/psdCouplingList.pck') - saveVariable(eef_psd_list, './data/eef_psd_list.pck') - saveVariable(psdImageResponse, './data/psdImageResponse.pck') - saveVariable(psd1d_list_psd, './data/psd1d_list_psd.pck') + # saveVariable(x0psd, './data/x0psd.pck') + # saveVariable(y0psd, './data/y0psd.pck') + # saveVariable(x0psd_var, './data/x0psd_var.pck') + # saveVariable(y0psd_var, './data/y0psd_var.pck') + # saveVariable(psdCouplingList, './data/psdCouplingList.pck') + # saveVariable(eef_psd_list, './data/eef_psd_list.pck') + # saveVariable(psdImageResponse, './data/psdImageResponse.pck') + # saveVariable(psd1d_list_psd, './data/psd1d_list_psd.pck') diff --git a/scripts/MICADO_ADC_with_WFE.py b/scripts/MICADO_ADC_with_WFE.py index 6e855ad..9268cd4 100644 --- a/scripts/MICADO_ADC_with_WFE.py +++ b/scripts/MICADO_ADC_with_WFE.py @@ -1,14 +1,13 @@ #!/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 * from scipy import interpolate +import sys +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') +from fourierOptics import * ''' This file simulates the paraxial optical model of the ELT-MICADO system @@ -16,6 +15,9 @@ from scipy import interpolate Surface form errors are added to the prisms to investigate the effect of WFEs on the PSF centroid. + NOTE: This file is outdated and not the most up to date model. + In particular, the plate scale will be wrong! + Author: Joost van den Born Contact: born@astron.nl ''' diff --git a/scripts/MICADO_paraxial_system_dispersion.py b/scripts/MICADO_paraxial_system_dispersion.py index 91595b9..d653567 100644 --- a/scripts/MICADO_paraxial_system_dispersion.py +++ b/scripts/MICADO_paraxial_system_dispersion.py @@ -1,14 +1,22 @@ #!/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 * from scipy import interpolate +import sys +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') +from fourierOptics import * + +''' + Description: + This early script simulates a dispersed PSF. By rotating the + ADC prisms we can inspect the change in the dispersion. + The theoretical best position of the ADC did not result in + an undispersed PSF, for some reason. +''' + def perform_padding(A, xs, ys): assert A.shape[0] <= xs and A.shape[1] <= ys, 'New size is smaller than array size.' @@ -101,10 +109,11 @@ if __name__ == '__main__': ELT_ADC = ADCObject() - # optAngle = ELT_ADC.find_optimum_angle(17.9, lList[0], lList[-1]) - # print(optAngle) + optAngle = ELT_ADC.find_optimum_angle(17.9, lList[0], lList[-1]) + print(optAngle) print('ADC angle now set to {:.4f}'.format(ELT_ADC.theta)) # ELT_ADC.set_orientation(180) + ELT_ADC.set_orientation(-optAngle+90) ELT_CAM = ParaxialLens(CA=89.2, f=4278.32701, name='MCD-CAM') @@ -147,8 +156,8 @@ if __name__ == '__main__': wf *= ELT_MIRROR.phase_delay(x,y,l, paraxial=True) Exyz, x, y = fou.fresnel_propagation(wf, xin, yin, dz=ELT_MIRROR.f, oversample=None, show=False, save=False)#, outputCoordinates=coordinatesList[0], apply_interpolation=False) - save_variable('./data/ELT_FP_{}.pkl'.format(l*1000), [Exyz, x, y]) - set_trace() + # save_variable('./data/ELT_FP_{}.pkl'.format(l*1000), [Exyz, x, y]) + # From ELT-FP to MCD-COL print('Propagating from ELT-IFP to MCD-COL', end='\r') Exyz2, x2, y2 = fou.fresnel_propagation(Exyz, x, y, dz=ELT_COL.f, oversample=None, @@ -245,9 +254,6 @@ if __name__ == '__main__': # plt.savefig(save, bbox_inches='tight', transparent=True) plt.show() - set_trace() - - diff --git a/scripts/SPIE/Thesis/generate_fp_wfe_phase_array.py b/scripts/SPIE/Thesis/generate_fp_wfe_phase_array.py index c42f628..b38ed74 100644 --- a/scripts/SPIE/Thesis/generate_fp_wfe_phase_array.py +++ b/scripts/SPIE/Thesis/generate_fp_wfe_phase_array.py @@ -1,11 +1,8 @@ import numpy as np import matplotlib.pyplot as plt import sys -# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') -# sys.path.insert(0, '/home/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * -from pdb import set_trace ''' @Author: Joost van den Born diff --git a/scripts/SPIE/Thesis/geometric_distortions.py b/scripts/SPIE/Thesis/geometric_distortions.py index cf5fd9e..25ebb0b 100644 --- a/scripts/SPIE/Thesis/geometric_distortions.py +++ b/scripts/SPIE/Thesis/geometric_distortions.py @@ -1,7 +1,5 @@ import numpy as np import sys -# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') -# sys.path.insert(0, '/home/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * diff --git a/scripts/SPIE/Thesis/geometric_distortions_fp_wfe.py b/scripts/SPIE/Thesis/geometric_distortions_fp_wfe.py index 9beb73f..b4691e0 100644 --- a/scripts/SPIE/Thesis/geometric_distortions_fp_wfe.py +++ b/scripts/SPIE/Thesis/geometric_distortions_fp_wfe.py @@ -1,7 +1,5 @@ import numpy as np import sys -# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') -# sys.path.insert(0, '/home/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * from pdb import set_trace @@ -17,14 +15,6 @@ from pdb import set_trace ''' def plot_distortions(xe, ye, xf, yf): - # Coordinates without WFEs - # xe = load_variable('../data/GD_IFP_zoom93_obscured_PSF_xcentroid_expected_zern_psd.pkl') - # ye = load_variable('../data/GD_IFP_zoom93_obscured_PSF_ycentroid_expected_zern_psd.pkl') - - # # Coordinates with WFEs - # xf = load_variable('../data/GD_IFP_zoom93_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl') - # yf = load_variable('../data/GD_IFP_zoom93_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl') - mcd = ParaxialMICADO(n=3001, m=3001, dpix=50, l=1.49e-3) n = xe.shape[0] diff --git a/scripts/SPIE/Thesis/geometric_distortions_fp_wfe_continuous.py b/scripts/SPIE/Thesis/geometric_distortions_fp_wfe_continuous.py index 0ff6178..822c2ad 100644 --- a/scripts/SPIE/Thesis/geometric_distortions_fp_wfe_continuous.py +++ b/scripts/SPIE/Thesis/geometric_distortions_fp_wfe_continuous.py @@ -1,7 +1,5 @@ import numpy as np import sys -# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') -# sys.path.insert(0, '/home/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * from pdb import set_trace diff --git a/scripts/SPIE/Thesis/geometric_distortions_incl_rotations.py b/scripts/SPIE/Thesis/geometric_distortions_incl_rotations.py index 8cef8b1..b1113e9 100644 --- a/scripts/SPIE/Thesis/geometric_distortions_incl_rotations.py +++ b/scripts/SPIE/Thesis/geometric_distortions_incl_rotations.py @@ -1,6 +1,5 @@ import numpy as np import sys -# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * diff --git a/scripts/SPIE/Thesis/plotting_detectors.py b/scripts/SPIE/Thesis/plotting_detectors.py index 66176c6..c63cc1f 100644 --- a/scripts/SPIE/Thesis/plotting_detectors.py +++ b/scripts/SPIE/Thesis/plotting_detectors.py @@ -8,7 +8,6 @@ import pandas as pd import sys sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * -from pdb import set_trace ''' Date: 2022-06-20 diff --git a/scripts/SPIE/Thesis/plotting_geometric_distortions_IFP.py b/scripts/SPIE/Thesis/plotting_geometric_distortions_IFP.py index 21142f3..dccd374 100644 --- a/scripts/SPIE/Thesis/plotting_geometric_distortions_IFP.py +++ b/scripts/SPIE/Thesis/plotting_geometric_distortions_IFP.py @@ -1,4 +1,3 @@ - import numpy as np import matplotlib.pyplot as plt import matplotlib.patches as patches @@ -8,7 +7,6 @@ import pandas as pd import sys sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * -from pdb import set_trace from matplotlib.colors import Normalize, LogNorm ''' diff --git a/scripts/SPIE/Thesis/plotting_geometric_distortions_IFP_zern.py b/scripts/SPIE/Thesis/plotting_geometric_distortions_IFP_zern.py index f3c83f4..9a2be18 100644 --- a/scripts/SPIE/Thesis/plotting_geometric_distortions_IFP_zern.py +++ b/scripts/SPIE/Thesis/plotting_geometric_distortions_IFP_zern.py @@ -8,7 +8,6 @@ import pandas as pd import sys sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * -from pdb import set_trace from matplotlib.colors import Normalize, LogNorm ''' diff --git a/scripts/SPIE/Thesis/retrieving_average_tilt.py b/scripts/SPIE/Thesis/retrieving_average_tilt.py index 76446ac..f26e6fb 100644 --- a/scripts/SPIE/Thesis/retrieving_average_tilt.py +++ b/scripts/SPIE/Thesis/retrieving_average_tilt.py @@ -4,7 +4,14 @@ from numpy.polynomial import polynomial import sys sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * -from pdb import set_trace + +''' + Description: This script loads the already generated WFEs and performs a + linear fit on them. This is then used to find the average tilt + over the beam footprint. + Used for the discussion section of Ch. 3 in my PhD Dissertation. +''' + def polyfit2d(x, y, z, deg): x = np.asarray(x) diff --git a/scripts/SPIE/centroid_shift_analysis.py b/scripts/SPIE/centroid_shift_analysis.py index 753f3c1..2da6c53 100644 --- a/scripts/SPIE/centroid_shift_analysis.py +++ b/scripts/SPIE/centroid_shift_analysis.py @@ -1,6 +1,6 @@ import numpy as np import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * diff --git a/scripts/SPIE/generate_ADC_footprint.py b/scripts/SPIE/generate_ADC_footprint.py index 47efc91..4359aa9 100644 --- a/scripts/SPIE/generate_ADC_footprint.py +++ b/scripts/SPIE/generate_ADC_footprint.py @@ -1,6 +1,6 @@ import numpy as np import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' diff --git a/scripts/SPIE/generate_ADC_input_field.py b/scripts/SPIE/generate_ADC_input_field.py index 3642aae..6f42591 100644 --- a/scripts/SPIE/generate_ADC_input_field.py +++ b/scripts/SPIE/generate_ADC_input_field.py @@ -1,6 +1,6 @@ import numpy as np import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' diff --git a/scripts/SPIE/generate_ray_trace_plot.py b/scripts/SPIE/generate_ray_trace_plot.py index 60face9..c77d8e6 100644 --- a/scripts/SPIE/generate_ray_trace_plot.py +++ b/scripts/SPIE/generate_ray_trace_plot.py @@ -1,6 +1,6 @@ import numpy as np import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' diff --git a/scripts/SPIE/generate_strehl_relation.py b/scripts/SPIE/generate_strehl_relation.py index f58f73b..d096a36 100644 --- a/scripts/SPIE/generate_strehl_relation.py +++ b/scripts/SPIE/generate_strehl_relation.py @@ -1,7 +1,7 @@ import numpy as np import os import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' diff --git a/scripts/SPIE/generate_wfe.py b/scripts/SPIE/generate_wfe.py index 06c1ff4..d6f9866 100644 --- a/scripts/SPIE/generate_wfe.py +++ b/scripts/SPIE/generate_wfe.py @@ -1,6 +1,5 @@ import numpy as np import sys -# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * from pdb import set_trace diff --git a/scripts/SPIE/geometric_distortions.py b/scripts/SPIE/geometric_distortions.py index 849feb6..ffc9115 100644 --- a/scripts/SPIE/geometric_distortions.py +++ b/scripts/SPIE/geometric_distortions.py @@ -1,7 +1,5 @@ import numpy as np import sys -# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') -# sys.path.insert(0, '/home/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * diff --git a/scripts/SPIE/geometric_distortions_incl_rotations.py b/scripts/SPIE/geometric_distortions_incl_rotations.py index 8cef8b1..b1113e9 100644 --- a/scripts/SPIE/geometric_distortions_incl_rotations.py +++ b/scripts/SPIE/geometric_distortions_incl_rotations.py @@ -1,6 +1,5 @@ import numpy as np import sys -# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * diff --git a/scripts/SPIE/plot_centroid_shift.py b/scripts/SPIE/plot_centroid_shift.py index 71856a7..3707caa 100644 --- a/scripts/SPIE/plot_centroid_shift.py +++ b/scripts/SPIE/plot_centroid_shift.py @@ -3,7 +3,7 @@ import os import sys import matplotlib.pyplot as plt import matplotlib.cm as cm -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * diff --git a/scripts/SPIE/plot_geometric_distortions.py b/scripts/SPIE/plot_geometric_distortions.py index 00ebb41..c1d7530 100644 --- a/scripts/SPIE/plot_geometric_distortions.py +++ b/scripts/SPIE/plot_geometric_distortions.py @@ -1,5 +1,5 @@ import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * diff --git a/scripts/SPIE/plot_strehl.py b/scripts/SPIE/plot_strehl.py index cab86b5..748579f 100644 --- a/scripts/SPIE/plot_strehl.py +++ b/scripts/SPIE/plot_strehl.py @@ -1,7 +1,7 @@ import numpy as np import os import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' diff --git a/scripts/SPIE/plot_wfe_analysis.py b/scripts/SPIE/plot_wfe_analysis.py index 6f0d82e..e6808ba 100644 --- a/scripts/SPIE/plot_wfe_analysis.py +++ b/scripts/SPIE/plot_wfe_analysis.py @@ -1,7 +1,7 @@ import numpy as np import os import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' diff --git a/scripts/SPIE/wavefront_error_frequency_analysis.py b/scripts/SPIE/wavefront_error_frequency_analysis.py index 8d123c4..54deb4e 100644 --- a/scripts/SPIE/wavefront_error_frequency_analysis.py +++ b/scripts/SPIE/wavefront_error_frequency_analysis.py @@ -1,7 +1,7 @@ import numpy as np import os import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' diff --git a/scripts/annular_mask_lens.py b/scripts/annular_mask_lens.py index 4e38f11..0b621e9 100644 --- a/scripts/annular_mask_lens.py +++ b/scripts/annular_mask_lens.py @@ -1,12 +1,21 @@ #!/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/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * +''' + Description: + This script looks how the PSF behaves for an annular lens. + Specifically at 30 microns. After plotting the PSF at the + focal length, a cross section of the intensity profile + at different distances from the lens is shown. +''' + if __name__ == '__main__': plt.rc('font', family='serif') plt.rc('axes', labelsize='large') @@ -27,30 +36,27 @@ if __name__ == '__main__': # Initiate the profiles class and pick a profile (tophat, obscured tophat or spider) prof = Profiles() - A = prof.obscured_top_hat(2.5, 2.3, n, m, dpix=dpix, oversample=1) + A = prof.obscured_top_hat(2.5, 2.3, n, m, dpix=dpix) plt.imshow(A); plt.show() # 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 = LensObject('N-BK7', 50, 1e99, 1, 4, name='L1') + L1 = SphericalLens('N-BK7', R1=50, R2=1e99, thickness=1, CA=8, name='L1') print('Focal length of lens {} is {:.1f} mm.'.format(L1.name, L1.f)) # Calculate the phase delay introduced by the lens t_l = L1.phase_delay(x,y,l, paraxial=True) U_in = A * t_l - + # Performing the propagation using Fresnel approximation to the focal plane. oC = [x.min(), x.max(), y.min(), y.max()] savename = False Exyz_og,_,_ = fou.fresnel_propagation(U_in, x, y, dz=L1.f, show=True, save=savename, outputCoordinates=oC) - - + # Plotting the Modulation Transfer Function of this lens system E1, fx1, fy1 = fou.modulation_transfer_function(np.abs(Exyz_og)**2, x,y,dpix) plt.figure() plt.plot(fx1[1000:], E1[1000, 1000:],'b-') diff --git a/scripts/artificial_speckles_test.py b/scripts/artificial_speckles_test.py index 8e0810e..421c0e5 100644 --- a/scripts/artificial_speckles_test.py +++ b/scripts/artificial_speckles_test.py @@ -1,13 +1,22 @@ #!/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 sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * +''' + Description: + This script was a first attempt at simulating the concept + described in Pathak et al., 2016. We apply a waffle pattern + to the incoming wavefront to create artificial speckles next + to the PSF core. If atmospheric dispersion is present for + a broadband observation, then these speckles will point to a + common intersection point outside of the PSF core. +''' + plt.rc('font', family='serif') plt.rc('axes', labelsize='large') diff --git a/scripts/gratama_seeing_limited_dispersion_test.py b/scripts/gratama_seeing_limited_dispersion_test.py index 81a7cbe..63e8044 100644 --- a/scripts/gratama_seeing_limited_dispersion_test.py +++ b/scripts/gratama_seeing_limited_dispersion_test.py @@ -1,97 +1,18 @@ import numpy as np import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * import scipy.special as spc -from pdb import set_trace + + ''' -def find_pixel_scale(x): - """ Calculate the pixel size from the x, y plane """ - _dpix = np.mean(np.diff(x.real)) - if _dpix < 1e-99: - _dpix = np.mean(np.diff((x.T).real)) - return _dpix - -def seeing(wvl, r0): - """ - Seeing value in arcsec at wavelength wvl - wvl in millimeter - r0 in meter - """ - wvl *= 1e-3 # convert wvl from mm to meter - return 3600*180/np.pi*0.976*wvl/r0 - -def fried_r0(wvl, seeing): - """ - Returns Fried's parameter value in meters - wvl in millimeter - """ - wvl *= 1e-3 # convert wvl from mm to meter - return 0.976*wvl/seeing*206264.8 - -def airmass(z): - """ - Converts zenith angle in degrees to airmass - """ - return 1/np.cos(np.deg2rad(z)) - -def spectrum(k, r0, L0=25): - """SPECTRUM Phase power spectrum density computes the phase power - spectrum density from the spatial frequency f and an - atmosphere object - - Normal value for L0 = 25. - """ - cte = (24*spc.gamma(6/5)/5)**(5/6)*(spc.gamma(11/6)**2./(2*np.pi**(11/3))) - return r0**(-5/3)*cte*(k**2 + 1/L0**2)**(-11/6) - -def add_seeing(wvl, sng, field_tuple): - """ - Computes the seeing limited PSF for a supplied amplitude - distribution. - - Parameters: - wvl - wavelength in mm - sng - seeing in arcseconds - field_tuple - tuple containing (amplitude array, x array, y array) - - Returns: - psf_seeing - - """ - r01 = fried_r0(wvl, seeing=sng) * 1e3 - A_psf, x_psf, y_psf = field_tuple - n,m = np.shape(x_psf) - fx = x_psf / (3200*wvl) - fy = y_psf / (3200*wvl) - dk = find_pixel_scale(fx) - - # von-Karman spectrum of the atmosphere for the given frequencies in k-space - psd = spectrum(np.hypot(fx.real, fy.real), r0=r01, L0=25*1e3) - psd[int(n/2),int(m/2)] = 0 - - # Compute the atmospheric OTF - # According to Roddier 1981, the atmospheric OTF can be derived from the phase structure function - # assuming that the phase is stationary accross the pupil and behaves as a Gaussian variable - Bphi = np.fft.fft2(np.fft.ifftshift(psd))*dk**2 - Dphi = np.fft.ifftshift((2 * (Bphi[0,0] - Bphi))) # ifftshift in Bphi en Dphi! - otf_atm = np.exp(-0.5*Dphi) - - # Compute the OTF of the supplied PSF - # We can derive the OTF from the inverse Fourier transform of the PSF - psf = np.abs(A_psf)**2 - otf_psf = np.fft.fftshift(np.fft.ifft2(np.fft.fftshift(psf))) - otf_psf = otf_psf/otf_psf.max() - - # Compute the seeing-limited PSF - # Multiplication of OTF and then Fourier transform - otf = otf_psf * otf_atm - psf_seeing = np.fft.fftshift(np.fft.ifft2(np.fft.ifftshift(otf))) - return psf_seeing + Description: + This script simulates the dispersed PSF of the small (40 cm) + Gratama telescope at the University of Groningen under 1.5 + arcsecond seeing. ''' - if __name__ == '__main__': l = 0.5e-3 # mm D_GT = 400 # mm diff --git a/scripts/high_contrast_imager.py b/scripts/high_contrast_imager.py index ca7ba15..90d0417 100644 --- a/scripts/high_contrast_imager.py +++ b/scripts/high_contrast_imager.py @@ -5,8 +5,16 @@ import matplotlib.pyplot as plt from matplotlib.ticker import FormatStrFormatter from matplotlib.colors import LogNorm import time -from fourierOptics import * +''' + Description: + An attempt at creating a classic lyot coronograph. + Not sure that it worked entirely as advertised... But + it does produce a reasonable result. + A bright star is blocked, while a faint companion, orbiting + on an elliptical orbit, is imaged as it goes through its + orbital phase. +''' def keplerIII_period_to_semimajor_axis(orbital_period): ######################################################### diff --git a/scripts/movie_atm_dispersion.py b/scripts/movie_atm_dispersion.py index 52fb935..6a3a7c8 100644 --- a/scripts/movie_atm_dispersion.py +++ b/scripts/movie_atm_dispersion.py @@ -1,17 +1,21 @@ #!/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') -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/atmosphere') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * -from atmosphericModel import * +from AstroAtmosphere import * from scipy import interpolate +''' + Script used to animate a changing PSF under changing amounts of + (atmospheric) dispersion. +''' + + def perform_padding(A, xs, ys): assert A.shape[0] <= xs and A.shape[1] <= ys, 'New size is smaller than array size.' x_margin = int((xs - A.shape[0])/2) @@ -281,8 +285,6 @@ if __name__ == '__main__': plt.savefig(save, bbox_inches='tight', transparent=True) plt.close()#show() - set_trace() - diff --git a/scripts/off_axis_test.py b/scripts/off_axis_test.py index 36524dc..c7b3842 100644 --- a/scripts/off_axis_test.py +++ b/scripts/off_axis_test.py @@ -6,9 +6,17 @@ 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') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * +''' + 2022-08-02: I don't understand the relation between the name of this script + and what happens within. It does seem to simulate a broadband PSF. And there's + also a phaseTilt function defined. Probably, I was testing out small phase tilts + to shift the PSF off-axis. +''' + + def phaseTilt(x,y,tx,ty): phaseTilt = x * np.tan(np.deg2rad(tx)) + y * np.tan(np.deg2rad(ty)) return phaseTilt diff --git a/scripts/planewave_rotation_test.py b/scripts/planewave_rotation_test.py index a3c91e8..0e8b289 100644 --- a/scripts/planewave_rotation_test.py +++ b/scripts/planewave_rotation_test.py @@ -1,6 +1,5 @@ #!/usr/bin/env Python3 import numpy as np -from pdb import set_trace import matplotlib.pyplot as plt from matplotlib import cm, colors from cmath import sqrt as csqrt @@ -16,9 +15,17 @@ import time from math import ceil import sys from mpl_toolkits import mplot3d -sys.path.insert(0, '../') +# sys.path.insert(0, '../') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') import fourierOptics as fouOpt +''' + Description: Old script when I was trying to make propagation to off-axis parabolic mirrors + work in 3D. This was based on papers by Matsushima (around 2004, I believe). + The script is currently broken. + If you get this to work, please do let me know! + Contact: born@astron.nl +''' class FourierOptics: diff --git a/scripts/planewave_rotation_test_2020.py b/scripts/planewave_rotation_test_2020.py index 12a90d9..1a30195 100644 --- a/scripts/planewave_rotation_test_2020.py +++ b/scripts/planewave_rotation_test_2020.py @@ -16,9 +16,19 @@ import time from math import ceil import sys from mpl_toolkits import mplot3d -sys.path.insert(0, '../../') +# sys.path.insert(0, '../../') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') import fourierOptics as fouOpt +''' + Description: Old script when I was trying to make propagation to off-axis parabolic mirrors + work in 3D. This was based on papers by Matsushima (around 2004, I believe). + The script is currently broken. + If you get this to work, please do let me know! + Contact: born@astron.nl +''' + + class FourierOptics: @@ -384,8 +394,8 @@ if __name__ == '__main__': U_in = A # sys.exit() - Exyz,x4l,y4l = fouOpt_norm.plane_wave_propagation(A, dz=4*l, dpix=dpix, oversample=None, show=True) - fou.coordinate_rotation(45,20) + # Exyz,x4l,y4l = fouOpt_norm.plane_wave_propagation(A, dz=4*l, dpix=dpix, oversample=None, show=True) + # fou.coordinate_rotation(45,20) # _E_res_abs = np.abs(A_at_z4l)/np.max(np.abs(A_at_z4l)) - np.abs(Exyz)/np.max(np.abs(Exyz)) # _E_res_ang = np.angle(A_at_z4l)/np.max(np.angle(A_at_z4l)) - np.angle(Exyz)/np.max(np.angle(Exyz)) @@ -409,7 +419,7 @@ if __name__ == '__main__': # # plt.show()/ # plt.close() - Erot2,x,y = fou.plane_wave_propagation_rotation(Exyz, dpix=dpix, Rx=45, Ry=20, oversample=None, show=True)#, save='p2p_gauss_Rx45_Ry45.png') + Erot2,x,y = fou.plane_wave_propagation_rotation(A, dpix=dpix, Rx=45, Ry=20, oversample=None, show=True)#, save='p2p_gauss_Rx45_Ry45.png') ''' # Compare phase to gaussian analysis. diff --git a/scripts/planewave_rotation_test_2020_2.py b/scripts/planewave_rotation_test_2020_2.py index 8d8d818..28ed316 100644 --- a/scripts/planewave_rotation_test_2020_2.py +++ b/scripts/planewave_rotation_test_2020_2.py @@ -16,10 +16,27 @@ import time from math import ceil import sys from mpl_toolkits import mplot3d -sys.path.insert(0, '../../') # where fourieroptics.py is located, so that it can be imported +# sys.path.insert(0, '../../') # where fourieroptics.py is located, so that it can be imported +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') import fourierOptics as fouOpt +''' + Description: Old script when I was trying to make propagation to off-axis parabolic mirrors + work in 3D. This was based on papers by Matsushima (around 2004, I believe). + This was about as far as I got with this. Here I also plot a 3D wireframe to + inspect the physical geometry that I'm trying to simulate. + + The end goal of having this propagation code on rotated surfaces work: + - Model the full 3D optical model of MICADO, including off-axis parabolas! + Likely, the off-axis parabola's would be modelled as flat mirrors, but + again with a phase transformation to provide the wavefront curvature. + + If you get this to work, please do let me know! + Contact: born@astron.nl +''' + + class FourierOptics: def __init__(self, l): diff --git a/scripts/psd_filtering_ELT_equiv.py b/scripts/psd_filtering_ELT_equiv.py index df80364..d03496c 100644 --- a/scripts/psd_filtering_ELT_equiv.py +++ b/scripts/psd_filtering_ELT_equiv.py @@ -5,13 +5,16 @@ import matplotlib.pyplot as plt from matplotlib.ticker import FormatStrFormatter from matplotlib.colors import LogNorm import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * +''' + Description: Script where I was working on filter the different spatial frequency + content from a WFE defined by a PSD - and inspecting how that worked. + 2022-08-02: Currently broken script. + Contact: born@astron.nl +''' -''' - @ Author: Joost van den Born -''' if __name__ == '__main__': @@ -72,7 +75,6 @@ if __name__ == '__main__': flist = [3, 6, 10, 15, 21, 28, 36, 45] print(flist) - set_trace() for fmax in flist: @@ -90,12 +92,10 @@ if __name__ == '__main__': # PSDSurface.set_bandpass_filter(flist[i], fmax) wfe.set_bandpass_filter(flist[i], fmax) - set_trace() newRMS = np.sqrt(np.mean(np.asarray(wfe.filteredData)**2))*1e6 wfe.scale_rms(wfe.rms*1e6/newRMS, filteredDataFlag=False) scal = wfe.scaledData - set_trace() # Adding the wavefront error M1.add_wavefront_error(scal) t_l = M1.phase_delay(x,y,l) diff --git a/scripts/psd_filtering_ELT_zernikes.py b/scripts/psd_filtering_ELT_zernikes.py index 71555b5..500bf57 100644 --- a/scripts/psd_filtering_ELT_zernikes.py +++ b/scripts/psd_filtering_ELT_zernikes.py @@ -5,13 +5,18 @@ import matplotlib.pyplot as plt from matplotlib.ticker import FormatStrFormatter from matplotlib.colors import LogNorm import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' - @ Author: Joost van den Born + @ Description: In this script I was applying a frequency filter on the WFEs and inspecting how + the different spatial frequency contents impact the PSF shift. This would form + the basis for one of the SPIE 2020 scripts. + @ Author: Joost van den Born ''' + + def scale_zernike(c, rms): # Scaling the coefficients to some total value rms_coeffic = np.sqrt(np.sum( np.asarray(c)**2)) diff --git a/scripts/psd_scaling_test.py b/scripts/psd_scaling_test.py index cb1a8b3..3d857fb 100644 --- a/scripts/psd_scaling_test.py +++ b/scripts/psd_scaling_test.py @@ -5,13 +5,15 @@ import matplotlib.pyplot as plt from matplotlib.ticker import FormatStrFormatter from matplotlib.colors import LogNorm import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' @ Author: Joost van den Born @ Desc.: Importing a grid sag file and scaling it appropriately + + 2022-08-02: Old script. Currently broken. ''' class surface: @@ -80,7 +82,7 @@ if __name__ == '__main__': oC = [x.min(), x.max(), y.min(), y.max()] # Add PSD wavefront error to the lens - wfe = WavefrontError() + wfe = WavefrontError(n,m) h_data = wfe.generate_height_map(1e-2, 2, 1, n, m) PSDSurface = surface(h_data) @@ -151,7 +153,7 @@ if __name__ == '__main__': r_moffat = np.sqrt(x0_moffat**2+y0_moffat**2) r_err_moffat = np.sqrt( (x0_moffat**2*x0_moffat_err**2+y0_moffat**2*y0_moffat_err**2) / (x0_moffat**2+y0_moffat**2)) - set_trace() + # set_trace() fig = plt.figure() ax1 = fig.add_subplot(121) diff --git a/scripts/psd_scaling_test_ELT_equiv.py b/scripts/psd_scaling_test_ELT_equiv.py index 48e32a8..67ec423 100644 --- a/scripts/psd_scaling_test_ELT_equiv.py +++ b/scripts/psd_scaling_test_ELT_equiv.py @@ -5,13 +5,14 @@ import matplotlib.pyplot as plt from matplotlib.ticker import FormatStrFormatter from matplotlib.colors import LogNorm import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * ''' @ Author: Joost van den Born @ Desc.: Importing a grid sag file and scaling it appropriately + 2022-08-02: Old script. Currently broken. ''' class surface: diff --git a/scripts/simple_lens_system.py b/scripts/simple_lens_system.py index ccee932..4bd1e5d 100644 --- a/scripts/simple_lens_system.py +++ b/scripts/simple_lens_system.py @@ -6,8 +6,16 @@ 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_new import * +# sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +# from fourierOptics_new import * +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') +from fourierOptics import * + +''' + 2022-08-02: + Description: Old script where I build a simple lens system and added WFEs to the lens surface. +''' + if __name__ == '__main__': plt.rc('font', family='serif') @@ -41,7 +49,7 @@ if __name__ == '__main__': # Create a lens with a focal length ~100 mm, with a clear aperture radius of 4 mm and thickness of 1 mm. - L1 = LensObject('N-BK7', 1, 4, name='L1') + L1 = LensObject(glass='N-BK7', thickness=1, CA=4, name='L1') L1.set_first_surface('EVEN ASPHERE', R=11.65, k=-1.10, a=[0.0, 3.69067205091E-5, -1.285461192617E-8, -1.400167659754E-10, -2.51311664812E-13, 5.01789877647E-16, 5.855871513042E-18, -1.127794407419E-20]) L1.set_second_surface('SPHERICAL', R=1e99) @@ -76,7 +84,7 @@ if __name__ == '__main__': zern2 = np.pad(zern, ((750,751),(750,751)), 'constant', constant_values=(0)) zern = zern2 * prof.top_hat(4, n,m, dpix) - L1 = LensObject('N-BK7', 1, 4, name='L1') + L1 = LensObject(glass='N-BK7', thickness=1, CA=4, name='L1') L1.set_first_surface('EVEN ASPHERE', R=11.65, k=-1.10, a=[0.0, 3.69067205091E-5, -1.285461192617E-8, -1.400167659754E-10, -2.51311664812E-13, 5.01789877647E-16, 5.855871513042E-18, -1.127794407419E-20]) L1.set_second_surface('SPHERICAL', R=1e99) @@ -107,14 +115,14 @@ if __name__ == '__main__': plt.xlim(-10,10) plt.ylim(-10,10) plt.colorbar() - plt.savefig('./figures/PSF_with_psd_error.png', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/PSF_with_psd_error.png', bbox_inches='tight', transparent=True) plt.close() # Wavefront error plt.figure() plt.imshow(h_data, cmap='jet') plt.colorbar() - plt.savefig('./figures/psd_error.png', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/psd_error.png', bbox_inches='tight', transparent=True) plt.close() # Original PSF @@ -123,7 +131,7 @@ if __name__ == '__main__': plt.xlim(-10,10) plt.ylim(-10,10) plt.colorbar() - plt.savefig('./figures/PSF_no_psd_error.png', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/PSF_no_psd_error.png', bbox_inches='tight', transparent=True) plt.close() # Zernike PSF (some coma and also astigmatism) @@ -132,7 +140,7 @@ if __name__ == '__main__': plt.xlim(-10,10) plt.ylim(-10,10) plt.colorbar() - plt.savefig('./figures/PSF_with_zernike_error.png', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/PSF_with_zernike_error.png', bbox_inches='tight', transparent=True) plt.close() # Wavefront error, zernike @@ -141,7 +149,7 @@ if __name__ == '__main__': plt.xlim(500,1500) plt.ylim(500,1500) plt.colorbar() - plt.savefig('./figures/zernike_error.png', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/zernike_error.png', bbox_inches='tight', transparent=True) plt.close() diff --git a/scripts/verify_strehl.py b/scripts/verify_strehl.py index 9183fe7..4c2a82c 100644 --- a/scripts/verify_strehl.py +++ b/scripts/verify_strehl.py @@ -1,14 +1,19 @@ #!/usr/bin/env Python3 import numpy as np -from pdb import set_trace import json import matplotlib.pyplot as plt from matplotlib.ticker import FormatStrFormatter from matplotlib.colors import LogNorm import sys -sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics') +sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Documents/Published/FourierOptics GitHub release/') from fourierOptics import * +''' + Description: Script that compares the Maréchal criterion to the Strehl of the PSF experiencing + a WFE with some RMS in the pupil. This script would form the basis for one of the + SPIE 2020 results. +''' + def saveVariableToTXT(variable, filename): variableFile = open(filename, 'w') @@ -110,7 +115,6 @@ if __name__ == '__main__': Exyz_zern,xp,yp = fou.fresnel_propagation(U_in, x, y, dz=M1.f, show=False, outputCoordinates=oC) Strehl_zern = np.abs(psf.get_coupling(Exyz_og, Exyz_zern))**2 - set_trace() StrehlList_zern.append(Strehl_zern) ####################################