Files
fourierOptics/scripts/MICADO_paraxial_system.py

180 lines
6.1 KiB
Python

#!/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
'''
This file simulates the paraxial optical model of the ELT-MICADO system
with an ADC placed inside the collimated beam near the pupil.
Author: Joost van den Born
Contact: born@astron.nl
'''
if __name__ == '__main__':
plt.rc('font', family='serif')
plt.rc('axes', labelsize='large')
l = 1.35e-3
fou = FourierOptics(l=l)
# MICADO paraxial system
# Pick sampling parameters
dpix = 50
n, m = 3001, 3001
print ('Your resolution is {}x{} with a pixel size of {}'.format(n,m,dpix))
# Create an input grid
x, y = np.meshgrid(np.linspace(-n/2*dpix, n/2*dpix, n), np.linspace(-m/2*dpix, m/2*dpix, m))
print('This means your grid is {} mm by {} mm, with each pixel {} mm.'.format(x.max()-x.min(), y.max()-y.min(), dpix))
###########################################################
#################### SETTING UP MICADO ####################
###########################################################
# Define the ELT mask (the spiders and central obscuration)
prof = Profiles()
# ELT_MASK = prof.top_hat(19427, n,m,dpix)#.astype('float64')
# ELT_MASK = prof.obscured_top_hat(4000, 500, n, m, dpix)
ELT_MASK = prof.ELT_pupil(n,m,dpix)
# ELT Mirror system combined into a single lens
ELT_MIRROR = ParabolicMirror(dx=0, dy=0, name='ELT-paraxial', CA=38854, f=6.84022e5)
ELT_FP = OpticalSurface(name='MCD-IFP')
ELT_COL = ParaxialLens(CA=154.54, f=1418.94, name='MCD-COL')
ELT_ADC = ADCObject()
ELT_CAM = ParaxialLens(CA=89.2, f=4278.32701, name='MCD-CAM')
ELT_DET = OpticalSurface(name='MCD-DET')
MCD = OpticalTrain()
MCD.add_object(ELT_MIRROR, dist=0)
MCD.add_object(ELT_FP, dist=ELT_MIRROR.f)
MCD.add_object(ELT_COL, dist=ELT_COL.f)
ELT_ADC.add_to_optical_train(MCD, 1209.4718)
MCD.add_object(ELT_CAM, dist=50)
MCD.add_object(ELT_DET, dist=ELT_CAM.f)
# Print lens data for verification
MCD.print_lens_data()
###########################################################
###########################################################
###################### PROPAGATION ########################
###########################################################
coordinatesList = [
[-1.5, 1.5, -1.5, 1.5],
[-200, 200, -200, 200],
[-120, 120, -120, 120],
[-120, 120, -120, 120],
[-120, 120, -120, 120],
[-120, 120, -120, 120],
[-120, 120, -120, 120],
[-2.5, 2.5, -2.5, 2.5]
]
xin, yin = x, y
zList = np.linspace(ELT_MIRROR.f-100, ELT_MIRROR.f+100, 15).tolist()
print('Starting propagation...')
# From ELT-M1 to ELT-FP
print('Propagating from ELT-M1 to ELT-IFP')
wf = ELT_MASK.astype('complex128')
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)
# From ELT-FP to MCD-COL
print('Propagating from ELT-IFP to MCD-COL')
Exyz2, x2, y2 = fou.fresnel_propagation(Exyz, x, y, dz=ELT_COL.f, oversample=None,
show=False, save=False, outputCoordinates=coordinatesList[1], apply_interpolation=False)
# From MCD-COL to MCD-ADC-P1
print('Propagating from MCD-COL to MCD-ADC-P1')
Exyz2 *= ELT_COL.phase_delay(x2,y2,l, paraxial=True)
Exyz3, x3, y3 = fou.plane_wave_propagation(Exyz2, x2, y2, dz=MCD.sequentialDistance[3], oversample=None,
show=False, save=False, outputCoordinates=None)
# From MCD-ADC-P1 to MCD-ADC-P2
print('Propagating from MCD-ADC-P1 to MCD-ADC-P2')
Exyz3 *= ELT_ADC.get_phase_delay(x3,y3,l, theta=None, paraxial=True, prism=1)
Exyz4, x4, y4 = fou.plane_wave_propagation(Exyz3, x3, y3, dz=MCD.sequentialDistance[4], oversample=None,
show=False, save=False, outputCoordinates=None)
# From MCD-ADC-P2 to MCD-ADC-P3
print('Propagating from MCD-ADC-P2 to MCD-ADC-P3')
Exyz4 *= ELT_ADC.get_phase_delay(x4,y4,l, theta=None, paraxial=True, prism=2)
Exyz5, x5, y5 = fou.plane_wave_propagation(Exyz4, x4, y4, dz=MCD.sequentialDistance[5], oversample=None,
show=False, save=False, outputCoordinates=None)
# From MCD-ADC-P3 to MCD-ADC-P4
print('Propagating from MCD-ADC-P3 to MCD-ADC-P4')
Exyz5 *= ELT_ADC.get_phase_delay(x5,y5,l, theta=None, paraxial=True, prism=3)
Exyz6, x6, y6 = fou.plane_wave_propagation(Exyz5, x5, y5, dz=MCD.sequentialDistance[6], oversample=None,
show=False, save=False, outputCoordinates=None)
# From MCD-ADC-P4 to MCD-CAM
print('Propagating from MCD-ADC-P4 to MCD-CAM')
Exyz6 *= ELT_ADC.get_phase_delay(x6,y6,l, theta=None, paraxial=True, prism=4)
Exyz7, x7, y7 = fou.plane_wave_propagation(Exyz6, x6, y6, dz=MCD.sequentialDistance[7], oversample=None,
show=False, save=False, outputCoordinates=None)
# From MCD-CAM to MCD-DET
print('Propagating from MCD-CAM to MCD-DET')
Exyz7 *= ELT_CAM.phase_delay(x7,y7,l, paraxial=True)
Exyz8, x8, y8 = fou.fresnel_propagation(Exyz7, x7, y7, dz=ELT_CAM.f, oversample=None,
show=False, save=False, outputCoordinates=None, apply_interpolation=False)
# save_variable('./data/MICADO_PSF_(1.35).pkl', [Exyz8, x8, y8])
# The result here shifts the PSF to the side, due to the phase tilts of the ADC
# surfaces. We find the locations of the maximum and redo the the fresnel propagation
# around these coordinates.
print('Zooming in on the PSF location...')
imax_1, imax_2 = find_maximum(np.abs(Exyz8))
x8max = x8[imax_1, imax_2]
y8max = y8[imax_1, imax_2]
newCoordinates = np.asarray(coordinatesList[7]) + np.array([x8max, x8max, y8max, y8max])
newCoordinates = newCoordinates.real.tolist()
save = 'MICADO_PSF.pdf'
Exyz9, x9, y9 = fou.fresnel_propagation(Exyz7, x7, y7, dz=ELT_CAM.f, oversample=None,
show=True, save=save, outputCoordinates=newCoordinates, apply_interpolation=True)
print('Propagation finished!')
# save_variable('./data/MICADO_PSF_(1.35)_interpolated.pkl', [Exyz9, x9, y9])
###########################################################