Added descriptions to all scripts, checked functioning

This commit is contained in:
yosata committed 2022-08-02 20:01:24 +02:00
1 parent 9ce4b7045f
commit 7cbaec6ff9
48 files changed
+262 -255

No files matched your search

@@ -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