Added features, fixed bugs and other small things

This commit is contained in:
yosata committed 2020-06-23 16:05:59 +02:00
1 parent 4007525275
commit 61ca707689
12 files changed
+784 -2118

No files matched your search

@@ -0,0 +1,20 @@
import numpy as np
import sys
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()
# 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)
@@ -0,0 +1,69 @@
import numpy as np
import sys
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()
wfe = WavefrontError(mcd.n, mcd.m)
# Create the Bahtinov mask and set it on the entrance pupil (ELT-M1)
bahtinov = Profiles().bahtinov_mask(40, 10, mcd.n, mcd.m, dpix=0.33, N=30, oversample=1)
mcd.ELT_CAM.add_mask(bahtinov)
# Set up
Elist = []
lList = np.linspace(1.49e-3, 1.78e-3, 15).tolist()
# Dispersion of 40 mas over the band
dispMax = 40e-3 / 3600 # maximum dispersion in degrees
dispersion = np.linspace(0, dispMax, len(lList)).tolist()
# Iterate over the wavelengths
for i in range(len(lList)):
l = lList[i]
# Generating the tilt to the input field.
d = dispersion[i]
field_tilt = wfe.generate_tilt(mcd.x,mcd.y,tx=0, ty=d)
# Adding the tilt to the input field
Ein = Profiles().ELT_pupil(mcd.n,mcd.m,mcd.dpix).astype('complex128')\
* np.exp(-1j * 2*np.pi/l * field_tilt)
mcd.apply_mask(Ein, replace=True)
# Propagate the input field throug the paraxial model
E, x, y = mcd.propagate(l=l,surface=-1, zoom=False, show=False,
image_output=[-4,4,-4,4], print_progress=True)
Elist.append(E)
# Average over all the wavelengths to get the final field.
Eca = np.asarray([np.abs(x) for x in Elist]).mean(axis=0) # Amplitude
Eci = Eca**2 # Intensity
Ecp = np.asarray([np.angle(x) for x in Elist]).mean(axis=0) # Phase
# Convert the scale to sky-angles using the plate scale
x *= mcd.platescale*1000 # x in milli arcseconds
y *= mcd.platescale*1000 # y in milli arcseconds
# Plotting the results
fig = plt.figure(figsize=(8,3))
ax = fig.add_subplot(121)
im = ax.imshow(Eca, cmap='hot', origin='lower', extent=[x.min(),x.max(),y.min(),y.max()])
ax.set_xlim([x.min(),x.max()])
ax.set_ylim([y.min(),y.max()])
ax.set_xlabel('x [mas]')
ax.set_ylabel('y [mas]')
fig.colorbar(im, ax=ax, label='Amplitude')
ax2 = fig.add_subplot(122)
im2 = ax2.imshow(Ecp, cmap='hot', origin='lower', extent=[x.min(),x.max(),y.min(),y.max()])
ax2.set_xlim([x.min(),x.max()])
ax2.set_ylim([y.min(),y.max()])
ax2.set_xlabel('x [mas]')
ax2.set_ylabel('y [mas]')
fig.colorbar(im2, ax=ax2, label='Phase')
plt.tight_layout()
plt.show()
+80
View File
@@ -0,0 +1,80 @@
import numpy as np
import sys
sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics')
from fourierOptics import *
from pdb import set_trace
def field_angle(hx, hy):
fx = hx * 0.0075
fy = hy * 0.0075
return fx, fy
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
Elist = []
# Set field points
hxList, hyList = np.mgrid[-0.03:0.03:3j,-0.03:0.03:3j]
hxList = hxList.flatten()
hyList = hyList.flatten()
# Iterating over the field positions.
for i in range(len(hxList)):
hx = hxList[i]
hy = hyList[i]
# Calculate the relative wavefront tilt for the field position
fieldx, fieldy = field_angle(hx,hy)
field_tilt = wfe.generate_tilt(mcd.x,mcd.y,tx=fieldx, ty=fieldy)
# Apply the field tilt
Ein = Profiles().ELT_pupil(mcd.n,mcd.m,mcd.dpix).astype('complex128')\
* np.exp(-1j * 2*np.pi/l * field_tilt)
mcd.apply_mask(Ein, replace=True)
# Propagate through the MICADO system
E, x, y = mcd.propagate(l=l,surface=-1, zoom=False, show=False,
print_progress=False)
Elist.append(E)
# Average over all the wavelengths to get the final field.
Eca = np.asarray([np.abs(x) for x in Elist]).mean(axis=0) # Amplitude
Eci = Eca**2 # Intensity
Ecp = np.asarray([np.angle(x) for x in Elist]).mean(axis=0) # Phase
# Convert the scale to sky-angles using the plate scale
x *= mcd.platescale*1000 # x in milli arcseconds
y *= mcd.platescale*1000 # y in milli arcseconds
# Plotting the results
fig = plt.figure(figsize=(8,3))
ax = fig.add_subplot(121)
im = ax.imshow(Eca, cmap='hot', origin='lower', extent=[x.min(),x.max(),y.min(),y.max()])
ax.set_xlim([x.min(),x.max()])
ax.set_ylim([y.min(),y.max()])
ax.set_xlabel('x [mas]')
ax.set_ylabel('y [mas]')
fig.colorbar(im, ax=ax, label='Amplitude')
ax2 = fig.add_subplot(122)
im2 = ax2.imshow(Ecp, cmap='hot', origin='lower', extent=[x.min(),x.max(),y.min(),y.max()])
ax2.set_xlim([x.min(),x.max()])
ax2.set_ylim([y.min(),y.max()])
ax2.set_xlabel('x [mas]')
ax2.set_ylabel('y [mas]')
fig.colorbar(im2, ax=ax2, label='Phase')
plt.tight_layout()
plt.show()
@@ -0,0 +1,16 @@
import numpy as np
import sys
sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics')
from fourierOptics import *
import matplotlib.pyplot as plt
from pdb import set_trace
if __name__ == '__main__':
plt.rc('font', family='serif')
plt.rc('axes', labelsize='large')
# Initiate MICADO paraxial model
mcd = ParaxialMICADO()
# Generate the PSF and plot it
E, x, y = mcd.propagate(l=1.35e-3,surface=-1, zoom=True, show=True, save='all')
@@ -0,0 +1,51 @@
import numpy as np
import sys
sys.path.insert(0, '/Users/joost/Dropbox/Werk/PhD/Analyses/Python/Analytical/Fourier Optics')
from fourierOptics import *
import matplotlib.pyplot as plt
from pdb import set_trace
if __name__ == '__main__':
plt.rc('font', family='serif')
plt.rc('axes', labelsize='large')
# 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')]
for i in range(len(confList)):
s = confList[i][0]
coordinates = confList[i][1]
savename = confList[i][2]
E, x, y = mcd.propagate(l=1.35e-3, surface=s, image_output=coordinates,
zoom=False, show=False, save=savename)
Eout, x, y = mcd.propagate(l=1.35e-3, surface=0, zoom=False, show=False)
x /= 1e3 # convert to m
y /= 1e3 # convert to m
_fig = plt.figure(figsize=(8,3))
_ax = _fig.add_subplot(121)
_im = _ax.imshow(np.abs(Eout), cmap='hot', extent=[x.min(), x.max(), y.min(), y.max()])
_ax.set_xlim([-30, 30])
_ax.set_ylim([-30, 30])
_ax.set_xlabel('x [m]')
_ax.set_ylabel('y [m]')
_fig.colorbar(_im, ax=_ax, label='Amplitude')
_ax2 = _fig.add_subplot(122)
_im2 = _ax2.imshow(np.angle(Eout), cmap='hot', extent=[x.min(), x.max(), y.min(), y.max()])
_ax2.set_xlim([-30, 30])
_ax2.set_ylim([-30, 30])
_ax2.set_xlabel('x [m]')
_ax2.set_ylabel('y [m]')
_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()