Large update for finishing thesis

This commit is contained in:
yosata committed 2022-08-02 14:26:17 +02:00
1 parent 8e0575e0e9
commit 9ce4b7045f
25 files changed
+2316 -521

No files matched your search

@@ -91,9 +91,10 @@ def convert_detector_size(x, y, old=True):
def plot_distortions(xe, ye, xp, yp, lims=False, add_detectors=True,
save=False, figtitle='geom_distortions',
show=True, cmap='magma'):
vmin, vmax = 0.1, 100
vmin, vmax = 0.01, 100
mcd = ParaxialMICADO(n=3001, m=3001, dpix=50, l=1.49e-3)
n = xe.shape[0]
no_of_grids = int(n/121)
X = xe.flatten()
Y = ye.flatten()
dX = xp - xe
@@ -103,7 +104,7 @@ def plot_distortions(xe, ye, xp, yp, lims=False, add_detectors=True,
# Magnitude of the distortions
R = np.sqrt(dx**2 + dy**2) * mcd.platescale * 1e6
print('RMS of the PSF shifts: {:.4f} μas.'.format(np.sqrt(np.mean((R)**2))))
print('RMS of the PSF shifts: {:.4f} μas.'.format(np.sqrt(np.mean((R[:121])**2))))
# Dummy figure, used for the colorbar colors in the quiver plot
# im = plt.imshow(np.reshape(R, (n,n)))
@@ -113,104 +114,160 @@ def plot_distortions(xe, ye, xp, yp, lims=False, add_detectors=True,
plt.close()
# Initiate the figure
# fig = plt.figure(figsize=(9.6,4.8))
# ax = fig.add_subplot(121, aspect='equal')
# ax2 = fig.add_subplot(122, aspect='equal')
fig, axes = plt.subplots(ncols=2,
nrows=1,
gridspec_kw={'width_ratios': [1,1]},
figsize=(9.6,4.8))
ax, ax2 = axes
ax.set_aspect('equal')
ax2.set_aspect('equal')
fig = plt.figure(figsize=(12,4.8))
gs = GridSpec(ncols=3, nrows=2, width_ratios=[2,1,1], height_ratios=[1,1])#left=0.05, right=0.48, wspace=0.05)
ax = fig.add_subplot(gs[:, :1])
ax2 = fig.add_subplot(gs[0, 1])
ax3 = fig.add_subplot(gs[0, 2])
ax4 = fig.add_subplot(gs[1, 1])
ax5 = fig.add_subplot(gs[1, 2])
axilist = [ax, ax2, ax3, ax4, ax5]
for axi in axilist:
axi.set_aspect('equal')
# Add the detector layout if so desired.
if add_detectors:
add_detector_layout((fig,ax), lw=.8, alpha=1, show_label=False)
add_detector_layout((fig,ax), lw=1, alpha=1, show_label=False)
# Plot the vector plot
xe = np.asarray(xe[:121]).reshape((11,11))
ye = np.asarray(ye[:121]).reshape((11,11))
# for i in range(len(xe)):
# ax.plot(xe[:,i], ye[:,i], 'k-', alpha=0.2, linewidth=.5)
# ax.plot(xe[i,:], ye[i,:], 'k-', alpha=0.2, linewidth=.5)
# ax.quiver(X,Y,dx,dy,R, alpha=1, units='dots', zorder=300)
for k in range(4):
print()
# Now we iterate over the different iterations of the GD simulations
print('Total number of grids: {}'.format(no_of_grids))
for k in range(no_of_grids):
# Selecting the different iterations (11x11 grid, but flattened)
ind_end = (k+1) * 121
ind_start = k * 121
dpix = np.diff(Y)[ind_start:ind_end][1]
print(k, ind_start, ind_end, dpix)
# Coordinates of the grid in this iteration
xplot = np.asarray(X[ind_start:ind_end]).reshape((11,11))
yplot = np.asarray(Y[ind_start:ind_end]).reshape((11,11))
yplot, xplot = np.mgrid[yplot.min()+dpix/2:yplot.max()-dpix/2:12j,
xplot.min()+dpix/2:xplot.max()-dpix/2:12j]
# Magnitude of the distortion at coordinates xplot, yplot
# Used to color the background
Rtemp = np.asarray(R[ind_start:ind_end]).reshape((11,11))
ax.pcolor(-1*yplot.T, -1*xplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=vmin, vmax=vmax))
# ax2.pcolor(-1*xplot.T, -1*yplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=1, vmax=100))
shiftx = X[ind_start:ind_end][61]#np.abs(dpix)/2
shiftx = X[ind_start:ind_end][61]
shifty = Y[ind_start:ind_end][60]
print(Y[ind_start:ind_end])
print('shiftx:', shiftx)
print('shifty:', shifty)
# ax2.pcolor(k*shifty-1*yplot.T, k*shiftx-1*xplot.T, Rtemp.T*10, cmap=cmap, norm=LogNorm(vmin=1, vmax=100))
if k == 1: ax2.pcolor(shifty-1*yplot.T, shiftx-1*xplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=vmin, vmax=vmax))
elif k == 2: ax2.pcolor(2*shifty-1*yplot.T, 2*shiftx-1*xplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=vmin, vmax=vmax))
elif k == 3: ax2.pcolor(2*shifty-1*yplot.T, 2*shiftx-1*xplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=vmin, vmax=vmax))
if k == 0:
if k in [0,1,2,3,7]: # Plot the center part pcolor
ax.pcolor(1*shifty-1*yplot.T, 1*shiftx-1*xplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=vmin, vmax=vmax))
# if k > 3: # Plot the zoom and megazoom
ax2.pcolor(2*shifty-1*yplot.T, 2*shiftx-1*xplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=vmin, vmax=vmax))
ax3.pcolor(2*shifty-1*yplot.T, 2*shiftx-1*xplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=vmin, vmax=vmax))
if k in [0,4,5,6,8]: # Plot the left bottom part pcolor
if k!=0:
ax.pcolor(yplot.T, xplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=vmin, vmax=vmax))
ax4.pcolor(2*shifty-1*yplot.T, 2*shiftx-1*xplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=vmin, vmax=vmax))
ax5.pcolor(2*shifty-1*yplot.T, 2*shiftx-1*xplot.T, Rtemp.T, cmap=cmap, norm=LogNorm(vmin=vmin, vmax=vmax))
# Quiver plots
# Full field plot
if k == 0:
ax.quiver(X[ind_start:ind_end],Y[ind_start:ind_end],
dx[ind_start:ind_end],dy[ind_start:ind_end],
angles='xy', edgecolor='k', facecolor='k',
linewidth=.8, zorder=300, alpha=1, scale=1.4e-5,
linewidth=.8, zorder=300, alpha=1, scale=1.2e-5,
units='dots')
elif k in [2,3]:
# Center plot zoom
if k in [0,1,2]:
ax2.quiver(X[ind_start:ind_end],Y[ind_start:ind_end],
dx[ind_start:ind_end],dy[ind_start:ind_end],
angles='xy', edgecolor='k', facecolor='k',
linewidth=.8, zorder=300, alpha=1, scale=0.2e-5,
linewidth=.8, zorder=300, alpha=1, scale=7e-7,
units='dots')
# ax.pcolor(xplot * (1 - dpix/105), yplot * (1 - dpix/105), Rtemp, cmap='jet', norm=LogNorm(vmin=1, vmax=100))
ax.set_xlabel('x (mm)', fontsize=16)
ax.set_ylabel('y (mm)', fontsize=16)
ax.tick_params(axis='both', direction='in', labelsize=14, zorder=-1,
top=True, right=True)
ax2.set_xlabel('x (mm)', fontsize=16)
ax2.set_ylabel('y (mm)', fontsize=16)
ax2.tick_params(axis='both', direction='in', labelsize=14, zorder=-1,
top=True, right=True)
# Center plot megazoom
elif k in [2,3,7]:
ax3.quiver(X[ind_start:ind_end],Y[ind_start:ind_end],
dx[ind_start:ind_end],dy[ind_start:ind_end],
angles='xy', edgecolor='k', facecolor='k',
linewidth=.8, zorder=300, alpha=1, scale=1e-6,
units='dots')
# Left bottom zoom
if k in [4,5]:
ax4.quiver(X[ind_start:ind_end],Y[ind_start:ind_end],
dx[ind_start:ind_end],dy[ind_start:ind_end],
angles='xy', edgecolor='k', facecolor='k',
linewidth=.8, zorder=300, alpha=1, scale=1.2e-5,
units='dots')
if k in [5,6,8]:
ax5.quiver(X[ind_start:ind_end],Y[ind_start:ind_end],
dx[ind_start:ind_end],dy[ind_start:ind_end],
angles='xy', edgecolor='k', facecolor='k',
linewidth=.8, zorder=300, alpha=1, scale=7e-6,
units='dots')
# Adjusting how the axes look in all subfigures
for axi in [ax, ax2, ax4]:
axi.set_ylabel('y (mm)', fontsize=16)
for axi in [ax, ax4, ax5]:
axi.set_xlabel('x (mm)', fontsize=16)
for axi in axilist:
axi.tick_params(axis='both', direction='in', labelsize=14, zorder=-1,
top=True, right=True)
cb = fig.colorbar(im, ax=axes, fraction=0.025, pad=0.04)
cb.set_label(label='PSF centroid shift (μas)', size=14)
cb.ax.tick_params(labelsize=14)
lbls = 10**np.asarray(cb.ax.get_yticks())
print(lbls)
newlbls = ['{:.0f}'.format(x) for x in 10**np.asarray(cb.ax.get_yticks())]
newlbls[1] = '{:.1f}'.format(lbls[1])
newlbls[0] = '{:.1f}'.format(lbls[0])
cb.ax.set_yticklabels(newlbls)
print(cb.ax.get_yticks())
# Setting some limits to the subplots
if not lims:
ax.set_xlim([-125, 115])
ax.set_ylim([-115, 115])
elif lims:
ax.set_xlim(lims[0])
ax.set_ylim(lims[1])
ax2.set_xlim([-2.01,2.75])
ax2.set_ylim([-2.01,2.75])
ax.indicate_inset_zoom(ax2, edgecolor="black")
ax2.set_xlim([-1+0.3513,1+0.3513])
ax2.set_ylim([-1+0.3513,1+0.3513])
ax3.set_xlim([-0.01+0.3513, 0.01+0.3513])
ax3.set_ylim([-0.01+0.3513, 0.01+0.3513])
# ax4.set_xlim([-2.01-84,2.75-84])
# ax4.set_ylim([-2.01-84,2.75-84])
ax4.set_xlim([-83.6-1,-83.6+1])
ax4.set_ylim([-83.6-1,-83.6+1])
ax5.set_xlim([-0.01-83.6070, 0.01-83.6070])
ax5.set_ylim([-0.01-83.6070, 0.01-83.6070])
# For the center inset
ax.indicate_inset_zoom(ax2, edgecolor='black')
ax2.indicate_inset_zoom(ax3, edgecolor='black')
# For the off-center inset
ax.indicate_inset_zoom(ax4, edgecolor='black')
ax4.indicate_inset_zoom(ax5, edgecolor='black')
# after plotting the data, format the labels
ax5.set_xticklabels(['{:.2f}'.format(x) for x in ax5.get_xticks()])
ax5.set_yticklabels(['{:.2f}'.format(x) for x in ax5.get_yticks()])
fig.subplots_adjust(top=1.0,
bottom=0.0,
left=0.1,
right=0.8,
hspace=0.135,
wspace=0.3)
bottom=0.08,
left=0.075,
right=0.88,
hspace=0.145,
wspace=0.45)
# Setting and modifying the colorbar
fig.subplots_adjust(right=0.88)
cbar_ax = fig.add_axes([0.9, 0.12, 0.02, 0.85])
cb = fig.colorbar(im, cax=cbar_ax)
cb.set_label(label='PSF centroid shift (μas)', size=14)
cb.ax.tick_params(labelsize=14)
lbls = 10**np.asarray(cb.ax.get_yticks())
newlbls = ['{:.0f}'.format(x) for x in 10**np.asarray(cb.ax.get_yticks())]
newlbls[3] = '{:.1f}'.format(lbls[3])
newlbls[2] = '{:.1f}'.format(lbls[2])
newlbls[1] = '{:.2f}'.format(lbls[1])
newlbls[0] = '{:.2f}'.format(lbls[0])
cb.ax.set_yticklabels(newlbls)
# plt.tight_layout()
if save:
plt.savefig('{}.pdf'.format(figtitle),
@@ -228,51 +285,127 @@ def plot_distortions(xe, ye, xp, yp, lims=False, add_detectors=True,
if __name__ == '__main__':
ps = ParaxialMICADO(n=3001, m=3001, dpix=50, l=1.49e-3).platescale
print(ps)
plt.rc('font', family='serif')
plt.rc('axes', labelsize='large')
# convert_detector_size()
# Plotting the original distortions
# Plotting the original distortions, -1/11 :1/11
data_dir = '../data/GD Focal Plane WFEs/'
xe_og = load_variable(data_dir + 'GD_IFP_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og = load_variable(data_dir + 'GD_IFP_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og = load_variable(data_dir + 'GD_IFP_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og = load_variable(data_dir + 'GD_IFP_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Zoom 1:
xe_og1 = load_variable(data_dir + 'GD_IFP_zoom_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og1 = load_variable(data_dir + 'GD_IFP_zoom_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og1 = load_variable(data_dir + 'GD_IFP_zoom_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og1 = load_variable(data_dir + 'GD_IFP_zoom_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# # Zoom 1: -1/11 :1/11
# xe_og1 = load_variable(data_dir + 'GD_IFP_zoom_obscured_PSF_xcentroid_expected_zern_psd.pkl')
# ye_og1 = load_variable(data_dir + 'GD_IFP_zoom_obscured_PSF_ycentroid_expected_zern_psd.pkl')
# xp_og1 = load_variable(data_dir + 'GD_IFP_zoom_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
# yp_og1 = load_variable(data_dir + 'GD_IFP_zoom_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Zoom 2
xe_og2 = load_variable(data_dir + 'GD_IFP_zoom2_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og2 = load_variable(data_dir + 'GD_IFP_zoom2_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og2 = load_variable(data_dir + 'GD_IFP_zoom2_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og2 = load_variable(data_dir + 'GD_IFP_zoom2_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# # Zoom 2: -.5/11:.5/11
# xe_og2 = load_variable(data_dir + 'GD_IFP_zoom2_obscured_PSF_xcentroid_expected_zern_psd.pkl')
# ye_og2 = load_variable(data_dir + 'GD_IFP_zoom2_obscured_PSF_ycentroid_expected_zern_psd.pkl')
# xp_og2 = load_variable(data_dir + 'GD_IFP_zoom2_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
# yp_og2 = load_variable(data_dir + 'GD_IFP_zoom2_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Zoom 3
xe_og3 = load_variable(data_dir + 'GD_IFP_zoom3_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og3 = load_variable(data_dir + 'GD_IFP_zoom3_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og3 = load_variable(data_dir + 'GD_IFP_zoom3_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og3 = load_variable(data_dir + 'GD_IFP_zoom3_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# # Zoom 3: -.1/11:.1/11
# xe_og3 = load_variable(data_dir + 'GD_IFP_zoom3_obscured_PSF_xcentroid_expected_zern_psd.pkl')
# ye_og3 = load_variable(data_dir + 'GD_IFP_zoom3_obscured_PSF_ycentroid_expected_zern_psd.pkl')
# xp_og3 = load_variable(data_dir + 'GD_IFP_zoom3_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
# yp_og3 = load_variable(data_dir + 'GD_IFP_zoom3_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
xe = np.append(xe_og, [xe_og1, xe_og2, xe_og3])
ye = np.append(ye_og, [ye_og1, ye_og2, ye_og3])
xp = np.append(xp_og, [xp_og1, xp_og2, xp_og3])
yp = np.append(yp_og, [yp_og1, yp_og2, yp_og3])
# Zoom 97: -1/11: 1/11
xe_og1 = load_variable(data_dir + 'GD_IFP_zoom97_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og1 = load_variable(data_dir + 'GD_IFP_zoom97_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og1 = load_variable(data_dir + 'GD_IFP_zoom97_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og1 = load_variable(data_dir + 'GD_IFP_zoom97_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# xe = np.append(xe_og2, xe_og3)
# ye = np.append(ye_og2, ye_og3)
# xp = np.append(xp_og2, xp_og3)
# yp = np.append(yp_og2, yp_og3)
# Zoom 98: -1/121 : 1/121
xe_og2 = load_variable(data_dir + 'GD_IFP_zoom98_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og2 = load_variable(data_dir + 'GD_IFP_zoom98_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og2 = load_variable(data_dir + 'GD_IFP_zoom98_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og2 = load_variable(data_dir + 'GD_IFP_zoom98_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Zoom 99: -1/11**3 : -1/11**3
xe_og3 = load_variable(data_dir + 'GD_IFP_zoom99_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og3 = load_variable(data_dir + 'GD_IFP_zoom99_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og3 = load_variable(data_dir + 'GD_IFP_zoom99_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og3 = load_variable(data_dir + 'GD_IFP_zoom99_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
figtitle = '../figures adapted for thesis/Focal Plane/GD_IFP_zern'
plot_distortions(xe, ye, xp, yp, show=True, save=True, figtitle=figtitle,
# Zoom7: -.01/11:.01/11
xe_og4 = load_variable(data_dir + 'GD_IFP_zoom92_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og4 = load_variable(data_dir + 'GD_IFP_zoom92_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og4 = load_variable(data_dir + 'GD_IFP_zoom92_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og4 = load_variable(data_dir + 'GD_IFP_zoom92_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Zoom8: -.05/11:.05/11 - not plotted
# Zoom93: -.004/11:.004/11
xe_og5 = load_variable(data_dir + 'GD_IFP_zoom93_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og5 = load_variable(data_dir + 'GD_IFP_zoom93_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og5 = load_variable(data_dir + 'GD_IFP_zoom93_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og5 = load_variable(data_dir + 'GD_IFP_zoom93_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# # Zoom91: -.01/11:.01/11 but hx and hy shifted to an area near the corner of the image,
# # where distortion is supposed to be large
# xe_og6 = load_variable(data_dir + 'GD_IFP_zoom91_obscured_PSF_xcentroid_expected_zern_psd.pkl')
# ye_og6 = load_variable(data_dir + 'GD_IFP_zoom91_obscured_PSF_ycentroid_expected_zern_psd.pkl')
# xp_og6 = load_variable(data_dir + 'GD_IFP_zoom91_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
# yp_og6 = load_variable(data_dir + 'GD_IFP_zoom91_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Zoom94: -1/11:1/11 but hx and hy shifted to an area near the corner of the image,
# where distortion is supposed to be large
xe_og6 = load_variable(data_dir + 'GD_IFP_zoom94_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og6 = load_variable(data_dir + 'GD_IFP_zoom94_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og6 = load_variable(data_dir + 'GD_IFP_zoom94_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og6 = load_variable(data_dir + 'GD_IFP_zoom94_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Zoom95: -1/121:1/121 but hx and hy shifted to an area near the corner of the image,
# where distortion is supposed to be large
xe_og7 = load_variable(data_dir + 'GD_IFP_zoom95_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og7 = load_variable(data_dir + 'GD_IFP_zoom95_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og7 = load_variable(data_dir + 'GD_IFP_zoom95_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og7 = load_variable(data_dir + 'GD_IFP_zoom95_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Zoom96: -1/11**3:1/11**3 but hx and hy shifted to an area near the corner of the image,
# where distortion is supposed to be large
xe_og8 = load_variable(data_dir + 'GD_IFP_zoom96_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og8 = load_variable(data_dir + 'GD_IFP_zoom96_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og8 = load_variable(data_dir + 'GD_IFP_zoom96_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og8 = load_variable(data_dir + 'GD_IFP_zoom96_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Zoom 100: - 1/11**4:1/11**4, phase interpolation, center of the field
xe_og9 = load_variable(data_dir + 'GD_IFP_zoom100_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og9 = load_variable(data_dir + 'GD_IFP_zoom100_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og9 = load_variable(data_dir + 'GD_IFP_zoom100_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og9 = load_variable(data_dir + 'GD_IFP_zoom100_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Zoom 101: - 1/11**4:1/11**4, phase interpolation, center of the field, with shift to left bottom corner
xe_og10 = load_variable(data_dir + 'GD_IFP_zoom101_obscured_PSF_xcentroid_expected_zern_psd.pkl')
ye_og10 = load_variable(data_dir + 'GD_IFP_zoom101_obscured_PSF_ycentroid_expected_zern_psd.pkl')
xp_og10 = load_variable(data_dir + 'GD_IFP_zoom101_obscured_PSF_xcentroid_found_with_wfe_airy_zern_psd.pkl')
yp_og10 = load_variable(data_dir + 'GD_IFP_zoom101_obscured_PSF_ycentroid_found_with_wfe_airy_zern_psd.pkl')
# Combining the data points
# xe = np.append(xe_og, [xe_og1, xe_og2, xe_og3, xe_og4, xe_og5, xe_og6, xe_og7, xe_og8])
# ye = np.append(ye_og, [ye_og1, ye_og2, ye_og3, ye_og4, ye_og5, ye_og6, ye_og7, ye_og8])
# xp = np.append(xp_og, [xp_og1, xp_og2, xp_og3, xp_og4, xp_og5, xp_og6, xp_og7, xp_og8])
# yp = np.append(yp_og, [yp_og1, yp_og2, yp_og3, yp_og4, yp_og5, yp_og6, yp_og7, yp_og8])
xe = np.append(xe_og, [xe_og1, xe_og2, xe_og3, xe_og6, xe_og7, xe_og8, xe_og9, xe_og10])
ye = np.append(ye_og, [ye_og1, ye_og2, ye_og3, ye_og6, ye_og7, ye_og8, ye_og9, ye_og10])
xp = np.append(xp_og, [xp_og1, xp_og2, xp_og3, xp_og6, xp_og7, xp_og8, xp_og9, xp_og10])
yp = np.append(yp_og, [yp_og1, yp_og2, yp_og3, yp_og6, yp_og7, yp_og8, yp_og9, yp_og10])
figtitle = '../figures adapted for thesis/Focal Plane/GD_IFP_psd'
plot_distortions(xe, ye, xp, yp, show=False, save=True, figtitle=figtitle,
lims=[[-120,120],[-120,120]])
plt.close()