def f2j(j,N,jsodd,ajsodd,deltaphi,dxp,pupilRadius): # 2: phij's of matrix A to find a_j even #Get the jth zernike polynomials values on a circular pupil of radius rad Zj = Z.calc_zern_j(j,N,dxp,pupilRadius) #compute the different 2Dfft given in the equations of deltaPSF cosZj = np.cos(deltaphi)*Zj sinZj = np.sin(deltaphi)*Zj FFTcosZj = scaledfft2(cosZj,dxp) FFTsinZj = scaledfft2(sinZj,dxp) #odd phase oddPhasor = ph.phasor(jsodd,ajsodd,N,dxp,pupilRadius) oddPhase = oddPhasor.phase pupil = oddPhasor.pupil cosOddPhase = pupil*np.cos(deltaphi)*oddPhase sinOddPhase = pupil*np.sin(deltaphi)*oddPhase FFTcosOddPhase = scaledfft2(cosOddPhase,dxp) FFTsinOddPhase = scaledfft2(sinOddPhase,dxp) #2Dfft of pupil function times sin(deltaPhi) and cos(deltaPhi) pupilSin = pupil*np.sin(deltaphi) pupilCos = pupil*np.cos(deltaphi) FFTPupilSin = scaledfft2(pupilSin,dxp) FFTPupilCos = scaledfft2(pupilCos,dxp) FFTsinZjOddPhase = scaledfft2(sinZj*oddPhase,dxp) FFTcosZjOddPhase = scaledfft2(cosZj*oddPhase,dxp) return np.ravel(2*np.imag(np.conj(FFTcosZj) * FFTsinOddPhase + FFTsinZj * np.conj(FFTcosOddPhase) - np.conj(FFTPupilCos) * FFTsinZjOddPhase + np.conj(FFTPupilSin) * FFTcosZjOddPhase))
def f1j(j,N,dxp,pupilRadius): # 1: phij's of matrix A to find a_j odd Zj = Z.calc_zern_j(j,N,dxp,pupilRadius) FFTZj = scaledfft2(Zj,dxp) Lp = N*dxp xp = np.arange(-Lp/2,Lp/2,dxp) yp = xp [Xp,Yp]=np.meshgrid(xp,yp) pupil = np.float64(np.sqrt(Xp**2+Yp**2)<=pupilRadius) FFTPupil = scaledfft2(pupil,dxp) return np.ravel(2 * np.real(FFTPupil) * np.imag(FFTZj))
def f2jeven(j,N,deltaphi,dxp,pupilRadius): # 2: phij's of matrix A to find a_j even #Get the jth zernike polynomials values on a circular pupil of radius rad Zj = Z.calc_zern_j(j,N,dxp,pupilRadius) Phasor = ph.phasor([1],[0],N,dxp,pupilRadius) pupil = Phasor.pupil #compute the different 2Dfft given in the equations of deltaPSF cosZj = pupil*np.cos(deltaphi)*Zj sinZj = pupil*np.sin(deltaphi)*Zj FFTcosZj = scaledfft2(cosZj,dxp) FFTsinZj = scaledfft2(sinZj,dxp) #2Dfft of pupil function times sin(deltaPhi) and cos(deltaPhi) pupilSin = pupil*np.sin(deltaphi) pupilCos = pupil*np.cos(deltaphi) FFTPupilSin = scaledfft2(pupilSin,dxp) FFTPupilCos = scaledfft2(pupilCos,dxp) return np.ravel(-4*np.real(np.conj(FFTPupilCos)*FFTsinZj-np.conj(FFTPupilSin)*FFTcosZj))
import fs import numpy as np import zernike as Z import matplotlib.pyplot as plt #%matplotlib inline #%config InlineBackend.figure_format = 'svg' Zj = Z.calc_zern_j(8, 400, 1) plt.figure() plt.subplot(3, 2, 1) plt.imshow(Zj) plt.subplot(3, 2, 2) plt.imshow(fs.flipMatrix(Zj)) plt.subplot(3, 2, 3) plt.imshow(fs.cleanZeros((Zj + fs.flipMatrix(Zj)) / 2., 1e-2)) plt.subplot(3, 2, 4) plt.imshow(fs.cleanZeros((Zj - fs.flipMatrix(Zj)) / 2., 1e-2)) plt.subplot(3, 2, 5) plt.imshow(fs.cleanZeros( Zj - ((Zj + fs.flipMatrix(Zj)) / 2. + (Zj - fs.flipMatrix(Zj)) / 2.), 1e-13), vmin=1e-16, vmax=1e-12) C = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) M = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) print(M + fs.flipMatrix(M)) / 2. + (M - fs.flipMatrix(M)) / 2.
theta = np.arctan2(Yp, Xp) plt.figure plt.subplot(2, 1, 1) plt.imshow(r) plt.subplot(2, 1, 2) plt.imshow(theta) pup = np.float64(np.sqrt(Xp**2 + Yp**2) <= pupilRadius) rad = int(np.ceil(pupilRadius / dxp)) phasor = ph.phasor([1], [0], N, rad) plt.figure() plt.imshow(pup) plt.figure() plt.imshow(pup - phasor.pupil) fftpup = np.fft.ifftshift(np.fft.fft2(np.fft.fftshift(pup))) fftpupil = np.fft.ifftshift(np.fft.fft2(np.fft.fftshift(phasor.pupil))) plt.figure() plt.subplot(2, 1, 1) plt.imshow(np.real(fftpup) - np.real(fftpupil)) plt.subplot(2, 1, 2) plt.imshow(np.imag(fftpup) - np.imag(fftpupil)) Zj = Z.calc_zern_j(4, N, dxp, pupilRadius) plt.figure() plt.imshow(Zj)
def deltaPhi(N,deltaZ,F,D,wavelength,dxp): Zj = Z.calc_zern_j(4,N,dxp,D/2.) P2Vdephasing = np.pi*deltaZ/wavelength*(D/F)**2/4. a4defocus = P2Vdephasing/2/np.sqrt(3) return a4defocus*Zj
#[mm] dExP = 727.4046 #[mm] DDM = 32.7 #[mm] # for OAP0 alpha = np.arctan(dExP * 0.5 / ExP2FP) #[rad] PFL_OAP0 = (DDM) / 2 / (-1 / np.tan(theta_OAP0 + alpha) + (1 / (np.tan(theta_OAP0 + alpha))**2 + 1)**0.5 + 1 / np.tan(theta_OAP0 - alpha) - (1 / (np.tan(theta_OAP0 - alpha))**2 + 1)**0.5) #[mm] pour l'OAP0 EFL_OAP0 = 2 * PFL_OAP0 / (1 + np.cos(theta_OAP0)) print('PFL_OAP0 (estim) : ', PFL_OAP0) #PFL_OAP0 = 445.0; print('PFL_OAP0 : ', PFL_OAP0) EFL_OAP0 = 2 * PFL_OAP0 / (1 + np.cos(theta_OAP0)) print('EFL_OAP0 : ', EFL_OAP0) po = -(PFL_OAP0 + ExP2FP) pi = po * PFL_OAP0 / (po + PFL_OAP0) print('pi (DM) : ', pi) #Aberrations : Wabefront MAP import zernike as zer aa = zer.calc_zern_j(4, 200, 0.1, 1) print(aa)
def constructPhase(self): phase = np.zeros((self.N, self.N)) for ij, j in enumerate(self.js): Zj = Z.calc_zern_j(j, self.N, self.dxp, self.pupilRadius) phase += self.ajs[ij] * Zj return phase