diff --git a/fourierOptics/fourier.py b/fourierOptics/fourier.py index 3c21a64..a8eff42 100644 --- a/fourierOptics/fourier.py +++ b/fourierOptics/fourier.py @@ -6,6 +6,7 @@ from scipy.optimize import leastsq from matplotlib.ticker import FormatStrFormatter from matplotlib.colors import LogNorm import pyfftw +import os from .misc import find_pixel_scale class FourierOptics: @@ -68,7 +69,7 @@ class FourierOptics: _E_xy0[:] = np.fft.ifftshift(A) # use ifftshift to shift origin to start array _IntensityNormFactor = np.sum(np.abs(_E_xy0)**2) # Factor to scale the intensity after the FFTs _Az0 = pyfftw.empty_aligned((_n,_m), dtype='complex128') - _FFTW_Obj = pyfftw.FFTW( _E_xy0, _Az0, axes=(0,1), direction='FFTW_BACKWARD', threads=6, flags=('FFTW_ESTIMATE',)) + _FFTW_Obj = pyfftw.FFTW( _E_xy0, _Az0, axes=(0,1), direction='FFTW_BACKWARD', threads=os.cpu_count(), flags=('FFTW_ESTIMATE',)) _FFTW_Obj() # E-field at z=dz is the fourier transform of A(z=0)*e^(-ikz) @@ -86,7 +87,7 @@ class FourierOptics: _A_in = pyfftw.empty_aligned((_n,_m), dtype='complex128') _A_in[:] = _Az0 * _phaseFactor - _FFTW_Obj2 = pyfftw.FFTW( _A_in, _E_xyz, axes=(0,1), direction='FFTW_FORWARD', threads=6, flags=('FFTW_ESTIMATE',)) + _FFTW_Obj2 = pyfftw.FFTW( _A_in, _E_xyz, axes=(0,1), direction='FFTW_FORWARD', threads=os.cpu_count(), flags=('FFTW_ESTIMATE',)) _FFTW_Obj2() _E_xyz = np.fft.fftshift(_E_xyz) # use fftshift to move the origin from edge to center _E_xyz /= np.sqrt(_IntensityNormFactor) # Normalization back to initial energy. @@ -213,7 +214,7 @@ class FourierOptics: # Output of the FFT evaluated at frequency fx = x / (lambda * z) _U_out = pyfftw.empty_aligned((_n,_m), dtype='complex128') - _FFTW_Obj = pyfftw.FFTW( np.fft.ifftshift(_U_in), _U_out, axes=(0,1), direction='FFTW_FORWARD', threads=6, flags=('FFTW_ESTIMATE',)) + _FFTW_Obj = pyfftw.FFTW( np.fft.ifftshift(_U_in), _U_out, axes=(0,1), direction='FFTW_FORWARD', threads=os.cpu_count(), flags=('FFTW_ESTIMATE',)) _FFTW_Obj() _U_out = np.fft.fftshift(_U_out) @@ -365,7 +366,7 @@ class FourierOptics: # Output of the FFT _A_out = pyfftw.empty_aligned(PSF.shape, dtype='complex128') - _FFTW_Obj = pyfftw.FFTW( np.fft.ifftshift(_A_in), _A_out, axes=(0,1), direction='FFTW_FORWARD', threads=6, flags=('FFTW_ESTIMATE',)) + _FFTW_Obj = pyfftw.FFTW( np.fft.ifftshift(_A_in), _A_out, axes=(0,1), direction='FFTW_FORWARD', threads=os.cpu_count(), flags=('FFTW_ESTIMATE',)) _FFTW_Obj() _A_out = np.fft.fftshift(_A_out) diff --git a/scripts/SPIE/figures adapted for thesis/huh_ADC_tWFE_p1_psd_25nm_2.png b/scripts/SPIE/figures adapted for thesis/huh_ADC_tWFE_p1_psd_25nm_2.png new file mode 100644 index 0000000..ebc5d6d Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/huh_ADC_tWFE_p1_psd_25nm_2.png differ diff --git a/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_psd_25nm_2.afdesign b/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_psd_25nm_2.afdesign new file mode 100644 index 0000000..8528ee6 Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_psd_25nm_2.afdesign differ diff --git a/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_psd_25nm_2.pdf b/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_psd_25nm_2.pdf new file mode 100644 index 0000000..5b06cec Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_psd_25nm_2.pdf differ diff --git a/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_psd_25nm_2.png b/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_psd_25nm_2.png new file mode 100644 index 0000000..ad0bc1c Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_psd_25nm_2.png differ diff --git a/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_zern_20nm_psd_15nm.pdf b/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_zern_20nm_psd_15nm.pdf new file mode 100644 index 0000000..e45b9bb Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_zern_20nm_psd_15nm.pdf differ diff --git a/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_zern_20nm_psd_15nm.png b/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_zern_20nm_psd_15nm.png new file mode 100644 index 0000000..4960869 Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_ADC_tWFE_p1_zern_20nm_psd_15nm.png differ diff --git a/scripts/SPIE/figures adapted for thesis/new_SR_relation_WFE_on_ADC_p1_obscured.pdf b/scripts/SPIE/figures adapted for thesis/new_SR_relation_WFE_on_ADC_p1_obscured.pdf new file mode 100644 index 0000000..13f5e1a Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_SR_relation_WFE_on_ADC_p1_obscured.pdf differ diff --git a/scripts/SPIE/figures adapted for thesis/new_SR_relation_WFE_on_ADC_p1_obscured.png b/scripts/SPIE/figures adapted for thesis/new_SR_relation_WFE_on_ADC_p1_obscured.png new file mode 100644 index 0000000..1147638 Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_SR_relation_WFE_on_ADC_p1_obscured.png differ diff --git a/scripts/SPIE/figures adapted for thesis/new_WFE_scaling_relation_obscured_airy.pdf b/scripts/SPIE/figures adapted for thesis/new_WFE_scaling_relation_obscured_airy.pdf new file mode 100644 index 0000000..4d5b9d0 Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_WFE_scaling_relation_obscured_airy.pdf differ diff --git a/scripts/SPIE/figures adapted for thesis/new_WFE_scaling_relation_obscured_airy.png b/scripts/SPIE/figures adapted for thesis/new_WFE_scaling_relation_obscured_airy.png new file mode 100644 index 0000000..9b72a5b Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_WFE_scaling_relation_obscured_airy.png differ diff --git a/scripts/SPIE/figures adapted for thesis/new_bandpass_spatial_freq_distance.pdf b/scripts/SPIE/figures adapted for thesis/new_bandpass_spatial_freq_distance.pdf new file mode 100644 index 0000000..2ae41c0 Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_bandpass_spatial_freq_distance.pdf differ diff --git a/scripts/SPIE/figures adapted for thesis/new_bandpass_spatial_freq_distance.png b/scripts/SPIE/figures adapted for thesis/new_bandpass_spatial_freq_distance.png new file mode 100644 index 0000000..a212812 Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_bandpass_spatial_freq_distance.png differ diff --git a/scripts/SPIE/figures adapted for thesis/new_lowpass_spatial_freq_distance.pdf b/scripts/SPIE/figures adapted for thesis/new_lowpass_spatial_freq_distance.pdf new file mode 100644 index 0000000..15fa131 Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_lowpass_spatial_freq_distance.pdf differ diff --git a/scripts/SPIE/figures adapted for thesis/new_lowpass_spatial_freq_distance.png b/scripts/SPIE/figures adapted for thesis/new_lowpass_spatial_freq_distance.png new file mode 100644 index 0000000..2b86497 Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_lowpass_spatial_freq_distance.png differ diff --git a/scripts/SPIE/figures adapted for thesis/new_wfe_figure.pdf b/scripts/SPIE/figures adapted for thesis/new_wfe_figure.pdf new file mode 100644 index 0000000..561f402 Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_wfe_figure.pdf differ diff --git a/scripts/SPIE/figures adapted for thesis/new_wfe_figure.png b/scripts/SPIE/figures adapted for thesis/new_wfe_figure.png new file mode 100644 index 0000000..46834ea Binary files /dev/null and b/scripts/SPIE/figures adapted for thesis/new_wfe_figure.png differ diff --git a/scripts/SPIE/plot_centroid_shift.py b/scripts/SPIE/plot_centroid_shift.py index 3582c11..71856a7 100644 --- a/scripts/SPIE/plot_centroid_shift.py +++ b/scripts/SPIE/plot_centroid_shift.py @@ -32,10 +32,11 @@ def plot_colourline(x,y,c, ax): if __name__ == '__main__': plt.rc('font', family='serif') plt.rc('text', usetex=True) + plt.rc('axes', labelsize='large') # Load in the results from centroid_shift_analysis.py - rms_zern_nm, r_airy_zern_mas, r_err_zern_airy_mas, strehl_list_zern = load_variable('./data/centroid_shift_zernikes.pkl') - rms_psd_nm, r_airy_psd_mas, r_err_psd_airy_mas, strehl_list_psd = load_variable('./data/centroid_shift_psd.pkl') + rms_zern_nm, r_airy_zern_mas, r_err_zern_airy_mas, strehl_list_zern = load_variable('./data/WFE frequency analysis/centroid_shift_zernikes.pkl') + rms_psd_nm, r_airy_psd_mas, r_err_psd_airy_mas, strehl_list_psd = load_variable('./data/WFE frequency analysis/centroid_shift_psd.pkl') # Convert the errors to logarithmic space, assuming small errors. log_err_zern_airy_mas = 0.434 * r_err_zern_airy_mas / r_airy_zern_mas @@ -43,7 +44,7 @@ if __name__ == '__main__': # Plot the resulting WFE scaling relation - fig = plt.figure(figsize=(9,7)) + fig = plt.figure(figsize=(6.4,4.8)) ax1 = fig.add_subplot(111) ax1.errorbar((0.8138)*rms_zern_nm, r_airy_zern_mas, yerr=log_err_zern_airy_mas, color='k', linestyle='none', capsize=3, @@ -66,13 +67,23 @@ if __name__ == '__main__': ax1.legend(fontsize=18) ax1.grid(True, alpha=0.3, which='major') ax1.grid(True, alpha=0.1, which='minor') - ax1.tick_params(labelsize=18) + ax1.tick_params(axis='both', which='both', direction='in', labelsize=16, zorder=-1,) cb = fig.colorbar(im, ax=ax1) cb.set_label(label='Strehl', size=18) cb.ax.tick_params(labelsize=18) - plt.savefig('./figures/WFE_scaling_relation_obscured_airy.png', bbox_inches='tight', transparent=True) - plt.savefig('./figures/WFE_scaling_relation_obscured_airy.pdf', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/WFE_scaling_relation_obscured_airy.png', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/WFE_scaling_relation_obscured_airy.pdf', bbox_inches='tight', transparent=True) plt.tight_layout() + figtitle = 'new_WFE_scaling_relation_obscured_airy' + if figtitle: + plt.savefig('{}.pdf'.format(figtitle), + bbox_inches='tight', + transparent=False, + facecolor=(1, 1, 0, 0.0)) + plt.savefig('{}.png'.format(figtitle), + bbox_inches='tight', + transparent=False, + facecolor=(1, 1, 0, 0.0)) plt.show() \ No newline at end of file diff --git a/scripts/SPIE/plot_strehl.py b/scripts/SPIE/plot_strehl.py index 83eb40a..cab86b5 100644 --- a/scripts/SPIE/plot_strehl.py +++ b/scripts/SPIE/plot_strehl.py @@ -25,7 +25,7 @@ def append_to_existing_data(A, filename): def plot_some_stuff(): - fig = plt.figure(figsize=(9,7)) + fig = plt.figure(figsize=(6.4,4.8)) ax = fig.add_subplot(111) ax2 = ax.twiny() @@ -52,11 +52,21 @@ def plot_some_stuff(): ax2.set_xlabel('$\\sigma/\\lambda$', fontsize=18) ax.legend(fontsize=18) ax.grid(True, alpha=0.3) - ax.tick_params(labelsize=18) - ax2.tick_params(labelsize=18) + ax.tick_params(axis='both', which='both', direction='in', labelsize=16, zorder=-1,) + ax2.tick_params(axis='both', which='both', direction='in', labelsize=16, zorder=-1,) plt.tight_layout() - plt.savefig('./figures/SR_relation_WFE_on_ADC_p1_obscured.png', bbox_inches='tight', transparent=True) - plt.savefig('./figures/SR_relation_WFE_on_ADC_p1_obscured.pdf', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/SR_relation_WFE_on_ADC_p1_obscured.png', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/SR_relation_WFE_on_ADC_p1_obscured.pdf', bbox_inches='tight', transparent=True) + figtitle = 'new_SR_relation_WFE_on_ADC_p1_obscured' + if figtitle: + plt.savefig('{}.pdf'.format(figtitle), + bbox_inches='tight', + transparent=False, + facecolor=(1, 1, 0, 0.0)) + plt.savefig('{}.png'.format(figtitle), + bbox_inches='tight', + transparent=False, + facecolor=(1, 1, 0, 0.0)) plt.show() if __name__ == '__main__': @@ -65,11 +75,11 @@ if __name__ == '__main__': plt.rc('axes', labelsize='large') l = 1.49e-3 - rmsList = load_variable('./data/SR_RMS_values_obscured.pkl') - strehl_zern_complete = load_variable('./data/SR_strehl_zern_obscured.pkl') - strehl_psd_complete = load_variable('./data/SR_strehl_psd_obscured.pkl') - rms_zern_list_complete = load_variable('./data/SR_rms_zern_complete_obscured.pkl') - rms_psd_list_complete = load_variable('./data/SR_rms_psd_complete_obscured.pkl') + rmsList = load_variable('./data/Strehl relation analysis/SR_RMS_values_obscured.pkl') + strehl_zern_complete = load_variable('./data/Strehl relation analysis/SR_strehl_zern_obscured.pkl') + strehl_psd_complete = load_variable('./data/Strehl relation analysis/SR_strehl_psd_obscured.pkl') + rms_zern_list_complete = load_variable('./data/Strehl relation analysis/SR_rms_zern_complete_obscured.pkl') + rms_psd_list_complete = load_variable('./data/Strehl relation analysis/SR_rms_psd_complete_obscured.pkl') mean_strehl_zern = np.mean(strehl_zern_complete, axis=0) err_strehl_zern = np.std(strehl_zern_complete, axis=0) diff --git a/scripts/SPIE/plot_wfe_analysis.py b/scripts/SPIE/plot_wfe_analysis.py index 21156a1..6f0d82e 100644 --- a/scripts/SPIE/plot_wfe_analysis.py +++ b/scripts/SPIE/plot_wfe_analysis.py @@ -27,8 +27,8 @@ if __name__ == '__main__': ############################### # Load in the data - r_airy, r_err_airy = load_variable('./data/lowpass_frequency_filter_airy_distance.pkl') - x0_airy, y0_airy, x0_airy_err, y0_airy_err = load_variable('./data/lowpass_frequency_filter_airy_locations.pkl') + r_airy, r_err_airy = load_variable('./data/WFE frequency analysis/lowpass_frequency_filter_airy_distance.pkl') + x0_airy, y0_airy, x0_airy_err, y0_airy_err = load_variable('./data/WFE frequency analysis/lowpass_frequency_filter_airy_locations.pkl') central_frequencies = np.asarray([0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 200, 220, 250, 280, 310, 340, 370, 400, 450, 500]) @@ -37,19 +37,30 @@ if __name__ == '__main__': r_err_airy_mas = r_err_airy * platescale # Plotting the centroid shift for all bandpasses - fig = plt.figure(figsize=(9,7)) + fig = plt.figure(figsize=(6.4,4.8)) ax1 = fig.add_subplot(111) ax1.scatter(central_frequencies, r_airy_mas, edgecolor='k', facecolors='none', alpha=0.7) ax1.set_xscale('log') ax1.set_xlabel('Cut-off Frequency of the lowpass filter ($\\rho/\\rho_c$)', fontsize=18) ax1.set_ylabel('Centroid shift (mas)', fontsize=18) - ax1.tick_params(labelsize=18) + ax1.tick_params(axis='both', which='both', direction='in', labelsize=16, zorder=-1,) ax1.grid(True, alpha=0.3, which='major') ax1.grid(True, alpha=0.1, which='minor') ax1.set_xlim([0.3,550]) plt.tight_layout() - plt.savefig('./figures/wfe_frequency_analysis/lowpass_spatial_freq_distance.png', bbox_inches='tight', transparent=True) - plt.savefig('./figures/wfe_frequency_analysis/lowpass_spatial_freq_distance.pdf', bbox_inches='tight', transparent=True) + figtitle = 'new_lowpass_spatial_freq_distance' + if figtitle: + plt.savefig('{}.pdf'.format(figtitle), + bbox_inches='tight', + transparent=False, + facecolor=(1, 1, 0, 0.0)) + plt.savefig('{}.png'.format(figtitle), + bbox_inches='tight', + transparent=False, + facecolor=(1, 1, 0, 0.0)) + plt.show() + # plt.savefig('./figures/wfe_frequency_analysis/lowpass_spatial_freq_distance.png', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/wfe_frequency_analysis/lowpass_spatial_freq_distance.pdf', bbox_inches='tight', transparent=True) @@ -60,9 +71,9 @@ if __name__ == '__main__': ################################ # Load in the data - r_airy, r_err_airy = load_variable('./data/bandpass_frequency_filter_airy_distance.pkl') - x0_airy, y0_airy, x0_airy_err, y0_airy_err = load_variable('./data/bandpass_frequency_filter_airy_locations.pkl') - central_frequencies = load_variable('./data/bandpass_frequency_filter_central_frequencies.pkl') + r_airy, r_err_airy = load_variable('./data/WFE frequency analysis/bandpass_frequency_filter_airy_distance.pkl') + x0_airy, y0_airy, x0_airy_err, y0_airy_err = load_variable('./data/WFE frequency analysis/bandpass_frequency_filter_airy_locations.pkl') + central_frequencies = load_variable('./data/WFE frequency analysis/bandpass_frequency_filter_central_frequencies.pkl') print(central_frequencies, len(central_frequencies), len(r_airy)) r_airy_mas = r_airy * platescale r_err_airy_mas = r_err_airy * platescale @@ -77,7 +88,7 @@ if __name__ == '__main__': # Plotting the centroid shift for all bandpasses - fig = plt.figure(figsize=(9,7)) + fig = plt.figure(figsize=(6.4,4.8)) ax1 = fig.add_subplot(111) ax1.scatter(central_frequencies, r_airy_mas, edgecolor='k', facecolors='none', alpha=0.7) ax1.plot(central_frequencies[2:], 10**best_fit_y[2:], 'b-', alpha=0.5, label='Best fit: $y = 0.030 x^{-0.602}$') @@ -85,13 +96,23 @@ if __name__ == '__main__': ax1.set_yscale('log') ax1.set_xlabel('Central Frequency of the bandpass filter ($\\rho/\\rho_c$)', fontsize=18) ax1.set_ylabel('Centroid shift (mas)', fontsize=18) - ax1.tick_params(labelsize=18) + ax1.tick_params(axis='both', which='both', direction='in', labelsize=16, zorder=-1,) ax1.grid(True, alpha=0.3, which='major') ax1.grid(True, alpha=0.1, which='minor') ax1.set_xlim([0.3,550]) ax1.set_ylim([10**-6, 10**0]) ax1.legend(fontsize=18) plt.tight_layout() - plt.savefig('./figures/wfe_frequency_analysis/bandpass_spatial_freq_distance.png', bbox_inches='tight', transparent=True) - plt.savefig('./figures/wfe_frequency_analysis/bandpass_spatial_freq_distance.pdf', bbox_inches='tight', transparent=True) + figtitle = 'bandpass_spatial_freq_distance' + if figtitle: + plt.savefig('{}.pdf'.format(figtitle), + bbox_inches='tight', + transparent=False, + facecolor=(1, 1, 0, 0.0)) + plt.savefig('{}.png'.format(figtitle), + bbox_inches='tight', + transparent=False, + facecolor=(1, 1, 0, 0.0)) + # plt.savefig('./figures/wfe_frequency_analysis/bandpass_spatial_freq_distance.png', bbox_inches='tight', transparent=True) + # plt.savefig('./figures/wfe_frequency_analysis/bandpass_spatial_freq_distance.pdf', bbox_inches='tight', transparent=True) plt.show() \ No newline at end of file