Example #1
0
	def __psfcaculator__(self,lambda_1=632*10**(-9),z=0.1):
		"""
		height: Exit pupil height
		width: Exit pupil width
		z: Distance from exit pupil to image plane
		"""
		a = self.__a__
		b = __sqrt__(1-a**2)
		l1 = 100;
		x1 = __np__.linspace(-a, a, l1)
		y1 = __np__.linspace(-b, b, l1)
		[X,Y] = __np__.meshgrid(x1,y1)
		Z = __zernikecartesian__(self.__coefficients__,a,X,Y)
		d = 400 # background
		A = __np__.zeros([d,d])
		A[d//2-l1//2+1:d//2+l1//2+1,d//2-l1//2+1:d//2+l1//2+1] = Z
		# fig = __plt__.figure()
		# __plt__.imshow(A)
		# __plt__.colorbar()
		# __plt__.show()
		abbe = __np__.exp(-1j*2*__np__.pi*A)
		for i in range(len(abbe)):
			for j in range(len(abbe)):
				if abbe[i][j]==1:
					abbe[i][j]=0
		PSF = __fftshift__(__fft2__(__fftshift__(abbe)))**2
		PSF = PSF/PSF.max()
		return PSF
Example #2
0
def __seidelcartesian__(coefficient,x,y):
	W = coefficient
	h = 1
	u = __arctan2__(y,x)
	r = __sqrt__(x**2+y**2)
	W = __seidelpolar__(coefficient,r,u)
	return W
Example #3
0
def __seidelcartesian__(coefficient, x, y):
    W = coefficient
    h = 1
    u = __arctan2__(y, x)
    r = __sqrt__(x**2 + y**2)
    W = __seidelpolar__(coefficient, r, u)
    return W
Example #4
0
    def __psfcaculator__(self, lambda_1=632 * 10**(-9), z=0.1):
        """
		height: Exit pupil height
		width: Exit pupil width
		z: Distance from exit pupil to image plane
		"""
        a = self.__a__
        b = __sqrt__(1 - a**2)
        l1 = 100
        x1 = __np__.linspace(-a, a, l1)
        y1 = __np__.linspace(-b, b, l1)
        [X, Y] = __np__.meshgrid(x1, y1)
        Z = __zernikecartesian__(self.__coefficients__, a, X, Y)
        d = 400  # background
        A = __np__.zeros([d, d])
        A[d // 2 - l1 // 2 + 1:d // 2 + l1 // 2 + 1,
          d // 2 - l1 // 2 + 1:d // 2 + l1 // 2 + 1] = Z
        # fig = __plt__.figure()
        # __plt__.imshow(A)
        # __plt__.colorbar()
        # __plt__.show()
        abbe = __np__.exp(-1j * 2 * __np__.pi * A)
        for i in range(len(abbe)):
            for j in range(len(abbe)):
                if abbe[i][j] == 1:
                    abbe[i][j] = 0
        PSF = __fftshift__(__fft2__(__fftshift__(abbe)))**2
        PSF = PSF / PSF.max()
        return PSF
Example #5
0
 def asphereline(self):
     R, k, a2, a3, a4, a5, a6, a7, a8, a9, a10 = self.__coefficients__
     r = __np__.linspace(-R, R, 100)
     C = 1 / R
     Z = C*r**2*(1+__sqrt__(1-(1+k)*r**2*C**2)) + a2*r**4 + a3*r**6 + a4*r**8 + \
     + a5*r**10 + a6*r**12 + a7*r**14 + a8*r**16 + a9*r**18 + a10*r**20
     Z = -Z
     fig = __plt__.figure(figsize=(12, 8), dpi=80)
     __plt__.plot(r, Z)
     __plt__.axis('equal')
     __plt__.show()
Example #6
0
	def asphereline(self):
		R,k,a2,a3,a4,a5,a6,a7,a8,a9,a10 = self.__coefficients__
		r = __np__.linspace(-R,R,100)
		C = 1/R
		Z = C*r**2*(1+__sqrt__(1-(1+k)*r**2*C**2)) + a2*r**4 + a3*r**6 + a4*r**8 + \
		+ a5*r**10 + a6*r**12 + a7*r**14 + a8*r**16 + a9*r**18 + a10*r**20
		Z = -Z
		fig = __plt__.figure(figsize=(12, 8), dpi=80)
		__plt__.plot(r,Z)
		__plt__.axis('equal')
		__plt__.show()
Example #7
0
def spherical_surf(l1):
	R = 1.02
	l1 = l1  #surface matrix length
	theta = __np__.linspace(0, 2*__np__.pi, l1)
	rho = __np__.linspace(0, 1, l1)
	[u,r] = __np__.meshgrid(theta,rho)
	X = r*__cos__(u)
	Y = r*__sin__(u)
	Z = __sqrt__(R**2-r**2)-__sqrt__(R**2-1)
	v_1 = max(abs(Z.max()),abs(Z.min()))

	noise = (__np__.random.rand(len(Z),len(Z))*2-1)*0.05*v_1
	Z = Z+noise
	fig = __plt__.figure(figsize=(12, 8), dpi=80)
	ax = fig.gca(projection='3d')
	surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=__cm__.RdYlGn,\
								linewidth=0, antialiased=False, alpha = 0.6)
	v = max(abs(Z.max()),abs(Z.min()))
	ax.set_zlim(-1, 2)
	ax.zaxis.set_major_locator(__LinearLocator__(10))
	ax.zaxis.set_major_formatter(__FormatStrFormatter__('%.02f'))
	cset = ax.contourf(X, Y, Z, zdir='z', offset=-1, cmap=__cm__.RdYlGn)
	fig.colorbar(surf, shrink=1, aspect=30)
	__plt__.title('Test Surface: Spherical surface with some noise',fontsize=16)
	__plt__.show()

	#Generate test surface matrix from a detector
	x = __np__.linspace(-1, 1, l1)
	y = __np__.linspace(-1, 1, l1)
	[X,Y] = __np__.meshgrid(x,y)
	Z = __sqrt__(R**2-(X**2+Y**2))-__sqrt__(R**2-1)+noise
	for i in range(len(Z)):
		for j in range(len(Z)):
			if x[i]**2+y[j]**2>1:
				Z[i][j]=0
	return Z
Example #8
0
	def zernikemap(self):
		a = self.__a__
		b = __sqrt__(1-a**2)
		x1 = __np__.linspace(-a, a, 100)
		y1 = __np__.linspace(-b, b, 100)
		[X,Y] = __np__.meshgrid(x1,y1)
		Z = __zernikecartesian__(self.__coefficients__,a,X,Y)
		fig = __plt__.figure(figsize=(12, 8), dpi=80)
		ax = fig.gca()
		im = __plt__.pcolormesh(X, Y, Z, cmap=__cm__.RdYlGn)
		__plt__.colorbar()
		ax.set_aspect('equal', 'datalim')
		__plt__.show()

		return 0
Example #9
0
    def zernikemap(self):
        a = self.__a__
        b = __sqrt__(1 - a**2)
        x1 = __np__.linspace(-a, a, 100)
        y1 = __np__.linspace(-b, b, 100)
        [X, Y] = __np__.meshgrid(x1, y1)
        Z = __zernikecartesian__(self.__coefficients__, a, X, Y)
        fig = __plt__.figure(figsize=(12, 8), dpi=80)
        ax = fig.gca()
        im = __plt__.pcolormesh(X, Y, Z, cmap=__cm__.RdYlGn)
        __plt__.colorbar()
        ax.set_aspect('equal', 'datalim')
        __plt__.show()

        return 0
Example #10
0
	def aspherematrix(self):
		l = 100
		R = self.__coefficients__[0]
		x1 = __np__.linspace(-R, R, l)
		[X,Y] = __np__.meshgrid(x1,x1)
		r = __sqrt__(X**2+Y**2)
		Z = __aspherepolar__(self.__coefficients__,r)
		for i in range(l):
			for j in range(l):
				if x1[i]**2+x1[j]**2 > R**2:
					Z[i][j] = 0
		fig = __plt__.figure(figsize=(12, 8), dpi=80)
		ax = fig.gca(projection='3d')
		surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=__cm__.RdYlGn,
	        linewidth=0, antialiased=False, alpha = 0.6)
		__plt__.show()
		return Z
Example #11
0
	def aspherematrix(self):
		l = 100
		R = self.__coefficients__[0]
		x1 = __np__.linspace(-R, R, l)
		[X,Y] = __np__.meshgrid(x1,x1)
		r = __sqrt__(X**2+Y**2)
		Z = __aspherepolar__(self.__coefficients__,r)
		for i in range(l):
			for j in range(l):
				if x1[i]**2+x1[j]**2 > R**2:
					Z[i][j] = 0
		fig = __plt__.figure(figsize=(12, 8), dpi=80)
		ax = fig.gca(projection='3d')
		surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=__cm__.RdYlGn,
	        linewidth=0, antialiased=False, alpha = 0.6)
		__plt__.show()
		return Z
Example #12
0
    def zernikesurface(self):
        """
		------------------------------------------------
		zernikesurface(self, label_1 = True):

		Return a 3D Zernike Polynomials surface figure

		label_1: default show label

		------------------------------------------------
		"""
        a = self.__a__
        b = __sqrt__(1 - a**2)
        x1 = __np__.linspace(-a, a, 50)
        y1 = __np__.linspace(-b, b, 50)
        [X, Y] = __np__.meshgrid(x1, y1)
        Z = __zernikecartesian__(self.__coefficients__, a, X, Y)
        fig = __plt__.figure(figsize=(12, 8), dpi=80)
        ax = fig.gca(projection='3d')
        surf = ax.plot_surface(X,
                               Y,
                               Z,
                               rstride=1,
                               cstride=1,
                               cmap=__cm__.RdYlGn,
                               linewidth=0,
                               antialiased=False,
                               alpha=0.6)

        ax.auto_scale_xyz([-1, 1], [-1, 1], [Z.max(), Z.min()])
        # ax.set_xlim(-a, a)
        # ax.set_ylim(-b, b)
        # v = max(abs(Z.max()),abs(Z.min()))
        # ax.set_zlim(-v*5, v*5)
        # cset = ax.contourf(X, Y, Z, zdir='z', offset=-v*5, cmap=__cm__.RdYlGn)

        # ax.zaxis.set_major_locator(__LinearLocator__(10))
        # ax.zaxis.set_major_formatter(__FormatStrFormatter__('%.02f'))
        fig.colorbar(surf, shrink=1, aspect=30)

        # p2v = round(__tools__.peak2valley(Z),5)
        # rms1 = round(__tools__.rms(Z),5)
        __plt__.show()
Example #13
0
	def zernikesurface(self):
		"""
		------------------------------------------------
		zernikesurface(self, label_1 = True):

		Return a 3D Zernike Polynomials surface figure

		label_1: default show label

		------------------------------------------------
		"""
		a = self.__a__
		b = __sqrt__(1-a**2)
		x1 = __np__.linspace(-a, a, 50)
		y1 = __np__.linspace(-b, b, 50)
		[X,Y] = __np__.meshgrid(x1,y1)
		Z = __zernikecartesian__(self.__coefficients__,a,X,Y)
		fig = __plt__.figure(figsize=(12, 8), dpi=80)
		ax = fig.gca(projection='3d')
		surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=__cm__.RdYlGn,
	        linewidth=0, antialiased=False, alpha = 0.6)

		ax.auto_scale_xyz([-1, 1], [-1, 1], [Z.max(), Z.min()])
		# ax.set_xlim(-a, a)
		# ax.set_ylim(-b, b)
		# v = max(abs(Z.max()),abs(Z.min()))
		# ax.set_zlim(-v*5, v*5)
		# cset = ax.contourf(X, Y, Z, zdir='z', offset=-v*5, cmap=__cm__.RdYlGn)

		# ax.zaxis.set_major_locator(__LinearLocator__(10))
		# ax.zaxis.set_major_formatter(__FormatStrFormatter__('%.02f'))
		fig.colorbar(surf, shrink=1, aspect=30)

		# p2v = round(__tools__.peak2valley(Z),5)
		# rms1 = round(__tools__.rms(Z),5)
		__plt__.show()
Example #14
0
	def Z12(self,r,u):
		return __sqrt__(10)*(4*r**2-3)*r**2*__cos__(2*u)
Example #15
0
	def Z11(self,r,u):
		return __sqrt__(5)*(1-6*r**2+6*r**4)
Example #16
0
	def Z10(self,r,u):
		return __sqrt__(8)*r**3*__cos__(3*u)
Example #17
0
	def Z9(self,r,u):
		return __sqrt__(8)*r**3*__sin__(3*u)
Example #18
0
	def Z8(self,r,u):
		return __sqrt__(8)*(3*r**2-2)*r*__cos__(u)
Example #19
0
def __zernikecartesian__(coefficient,a,x,y):
	"""
	------------------------------------------------
	__zernikecartesian__(coefficient,a,x,y):

	Return combined aberration

	Orthonormal Rectangle Aperture Polynomials Caculation for 
	Rectangle aperture in Cartesian coordinates

	coefficient: Zernike Polynomials Coefficient from input
	a: 1/2 aperture width in a circle(See reference)
	x: x in Cartesian coordinates
	y: y in Cartesian coordinates
	------------------------------------------------
	"""
	mu = __sqrt__(9-36*a**2+103*a**4-134*a**6+67*a**6+67*a**8)
	v = __sqrt__(49-196*a**2+330*a**4-268*a**6+134*a**8)
	tau = 1/(128*v*a**4*(1-a**2)**2)
	eta = 9-45*a**2+139*a**4-237*a**6+210*a**8-67*a**10
	r = x**2+y**2

	R = [0]+coefficient
	R1  =  R[1]  * 1                              
	R2  =  R[2]  * __sqrt__(3)/a*x
	R3  =  R[3]  * __sqrt__(3/(1-a**2))*y
	R4  =  R[4]  * __sqrt__(5)/2/__sqrt__(1-2*a**2+2*a**4)*(3*r**2-1)
	R5  =  R[5]  * 3/a/__sqrt__(1-a**2)*x*y
	R6  =  R[6]  * __sqrt__(5)/4/a**2/(1-a**2)/__sqrt__(1-2*a**2+2*a**4)*\
					(3*(1-a**2)**2*x**2-3*a**4*y**2-a*82*(1-3*a**2+2*a**4))
	R7  =  R[7]  * __sqrt__(21)/2/__sqrt__(27-81*a**2+116*a**4-62*a**6)*\
					(15*r**2-9+4*a**2)*y
	R8  =  R[8]  * __sqrt__(21)/2/a/__sqrt__(35-70*a**2+62*a**4)*\
					(15*r**2-5-4*a**2)*x
	R9  =  R[9]  * (__sqrt__(5)*__sqrt__((27-54*a**2+62*a**4)/(1-a**2))/\
					(2*a**2*(27-81*a**2+116*a**4-62*a**6)))*(27*(1-a**2)**2*x**2-\
					35*a**4*y**2-a**2*(9-39*a**2+30*a**4))*y
	r1  = 35-70*a**2+62*a**4
	R10 =  R[10] * (__sqrt__(5)/(2*a**3*(1-a**2)*__sqrt__(r1)))*(35*(1-a**2)**2*x**2-\
					27*a**4*y**2-a**2*(21-51*a**2+30*a**4))*x
	R11 =  R[11] * 1/8/mu*(315*r**4+30*(7+2*a**2)*x**2-30*(9-2*a**2)*y**2+27+16*a**2-16*a**4)

	R12 =  R[12] * (3*mu/(8*a**2*v*eta))*(35*(1-a**2)**2*(18-36*a**2+67*a**4)*x**4+\
					630*(1-2*a**2)*(1-2*a**2+2*a**4)*x**2*y**2-35*a**4*(49-98*a**2+67*a**4)*y**4-\
					30*(1-a**2)*(7-10*a**2-12*a**4+75*a**6-67*a**8)*x**2-\
					30*a**2*(7-77*a**2+189*a**4-193*a**6+67*a**8)*y**2+\
					a**2*(1-a**2)*(1-2*a**2)*(70-233*a**2+233*a**4))
	R13 =  R[13] * __sqrt__(21)/(2*a*__sqrt__(1-3*a**2+4*a**4-2*a**6))*(5*r**2-3)*x*y
	R14 =  R[14] * 16*tau*(735*(1-a**2)**4*x**4-540*a**4*(1-a**2)**2*x**2*y**2+735*a**8*y**4-\
					90*a**2*(1-a**2)**3*(7-9*a**2)*x**2+90*a**6*(1-a**2)*(2-9*a**2)*y**2+\
					+3*a**4*(1-a**2)**2*(21-62*a**2+62*a**4))
	R15 =  R[15] * __sqrt__(21)/(2*a**3*(1-a**2)*__sqrt__(1-3*a**2+4*a**4-2*a**6))*\
					(5*(1-a**2)**2*x**2-5*a**4*y**2-a**2*(3-9*a**2+6*a**4))*x*y

	RW = 	R1 + R2 +  R3+  R4+  R5+  R6+  R7+  R8+  R9+ \
			R10+ R11+ R12+ R13+ R14+ R15
	return RW
Example #20
0
	def Z15(self,r,u):
		return __sqrt__(10)*r**4*__sin__(4*u)
Example #21
0
	def Z26(self,r,u):
		return __sqrt__(14)*(6*r**2-5)*r**4*__cos__(4*u)
Example #22
0
	def Z24(self,r,u):
		return __sqrt__(14)*(15*r**4-20*r**2+6)*r**2*__cos__(2*u)
Example #23
0
	def Z21(self,r,u):
		return __sqrt__(12)*r**5*__sin__(5*u)
Example #24
0
	def Z19(self,r,u):
		return __sqrt__(12)*(5*r**2-4)*r**3*__sin__(3*u)
Example #25
0
	def Z17(self,r,u):
		return __sqrt__(12)*(10*r**4-12*r**2+3)*r*__sin__(u)
Example #26
0
def __zernikepolar__(coefficient,a,r,u):
	"""
	------------------------------------------------
	__zernikepolar__(coefficient,r,u):

	Return combined aberration

	Orthonormal Rectangle Aperture Polynomials Caculation in polar coordinates

	coefficient: Orthonormal Rectangle Aperture Polynomials Coefficient from input
	r: rho in polar coordinates
	u: theta in polar coordinates
	------------------------------------------------
	"""
	mu = __sqrt__(9-36*a**2+103*a**4-134*a**6+67*a**6+67*a**8)
	v = __sqrt__(49-196*a**2+330*a**4-268*a**6+134*a**8)
	tau = 1/(128*v*a**4*(1-a**2)**2)
	eta = 9-45*a**2+139*a**4-237*a**6+210*a**8-67*a**10

	R = [0]+coefficient
	R1  =  R[1]  * 1                              
	R2  =  R[2]  * __sqrt__(3)/a*r*__cos__(u)
	R3  =  R[3]  * __sqrt__(3/(1-a**2))*r*__sin__(u)
	R4  =  R[4]  * __sqrt__(5)/2/__sqrt__(1-2*a**2+2*a**4)*(3*r**2-1)
	R5  =  R[5]  * 3/2/a/__sqrt__(1-a**2)*r**2*__sin__(2*u)
	R6  =  R[6]  * __sqrt__(5)/2/a**2/(1-a**2)/__sqrt__(1-2*a**2+2*a**4)*\
					(3*(1-2*a**2+2*a**4)*r**2*__cos__(2*u)+3*(1-2*a**2)*r**2-\
					2*a**2*(1-a**2)*(1-2*a**2))
	R7  =  R[7]  * __sqrt__(21)/2/__sqrt__(27-81*a**2+116*a**4-62*a**6)*\
					(15*r**2-9+4*a**2)*r*__sin__(u)
	R8  =  R[8]  * __sqrt__(21)/2/a/__sqrt__(35-70*a**2+62*a**4)*\
					(15*r**2-5-4*a**2)*r*__cos__(u)
	R9  =  R[9]  * (__sqrt__(5)*__sqrt__((27-54*a**2+62*a**4)/(1-a**2))/\
					(8*a**2*(27-81*a**2+116*a**4-62*a**6)))*((27-54*a**2+62*a**4)*\
					r*__sin__(3*u)-3*(4*a**2*(3-13*a**2+10*a**4)-(9-18*a**2-26*a**4))\
					*r*__sin__(u))
	r1  = 35-70*a**2+62*a**4
	R10 =  R[10] * (__sqrt__(5)/(8*a**3*(1-a**2)*__sqrt__(r1)))*((r1)*r**3*__cos__(3*u)-\
					3*(4*a**2*(7-17*a**2+10*a**4)-(r1)*r**2)*r*__cos__(u))
	R11 =  R[11] * 1/8/mu*(315*r**4+30*(1-2*a**2)*r**2*__cos__(2*u)-240*r**2+27+16*a*2-16*a**4)
	R12 =  R[12] * (3*mu/(8*a**2*v*eta))*(315*(1-2*a**2)*(1-2*a**2+2*a**4)*r**4+\
					5*(7*mu**2*r**2-21+72*a**2-225*a**4+306*a**6-152*a**8)*r**2*__cos__(2*u)-\
					15*(1-2*a**2)*(7+4*a**2-71*a**4+134*a**6-67*a**8)*r**2+\
						a**2*(1-a**2)*(1-2*a**2)*(70-233*a**2+233*a**4))
	R13 =  R[13] * __sqrt__(21)/(4*a*__sqrt__(1-3*a**2+4*a**4-2*a**6))*(5*r**2-3)*r**2*__sin__(2*u)
	R14 =  R[14] * 6*tau*(5*v**2*r**4*__cos__(4*u)-20*(1-2*a**2)*(6*a**2*(7-16*a**2+18*a**4-9*a**6)-\
					49*(1-2*a**2+2*a**4)*r**2)*r**2*__cos__(u)+8*a**4*(1-a**2)**2*(21-62*a**2+62*a**4)-\
					120*a**2*(7-30*a**2+46*a**4-23*a**6)*r**2+\
					15*(49-196*a**2+282*a**4-172*a**6+86*a**8)*r**4)
	R15 =  R[15] * (__sqrt__(21)/(8*a**3*__sqrt__((1-a**2)**3))/__sqrt__(1-2*a**2+2*a**4))*\
					(-(1-2*a**2)*(6*a**2-6*a**4-5*r**2)*r**2*__sin__(2*u)+\
					(5/2)*(1-2*a**2+2**a**4)*r**4*__sin__(4*u))
	RW = 	R1 + R2 +  R3+  R4+  R5+  R6+  R7+  R8+  R9+ \
			R10+ R11+ R12+ R13+ R14+ R15
	return RW
Example #27
0
	def Z13(self,r,u):
		return __sqrt__(10)*(4*r**2-3)*r**2*__sin__(2*u)
Example #28
0
	def Z14(self,r,u):
		return __sqrt__(10)*r**4*__cos__(4*u)
Example #29
0
	def Z28(self,r,u):
		return __sqrt__(14)*r**6*__cos__(6*u)
Example #30
0
	def Z16(self,r,u):
		return __sqrt__(12)*(10*r**4-12*r**2+3)*r*__cos__(u)
Example #31
0
def __aspherepolar__(coefficient,r):
	R,k,a2,a3,a4,a5,a6,a7,a8,a9,a10 = coefficient
	C = 1/R
	Z = C*r**2*(1+__sqrt__(1-(1+k)*r**2*C**2)) + a2*r**4 + a3*r**6 + a4*r**8 + \
		+ a5*r**10 + a6*r**12 + a7*r**14 + a8*r**16 + a9*r**18 + a10*r**20
	return -Z
Example #32
0
	def Z18(self,r,u):
		return __sqrt__(12)*(5*r**2-4)*r**3*__cos__(3*u)
Example #33
0
from numpy import cos as __cos__
from numpy import sin as __sin__
import matplotlib.pyplot as __plt__
from matplotlib import cm as __cm__
from matplotlib.ticker import LinearLocator as __LinearLocator__
from matplotlib.ticker import FormatStrFormatter as __FormatStrFormatter__
from numpy.fft import fftshift as __fftshift__
from numpy.fft import ifftshift as __ifftshift__
from numpy.fft import fft2 as __fft2__

l1 = 100
#Generate test surface matrix from a detector
x = __np__.linspace(-1, 1, l1)
y = __np__.linspace(-1, 1, l1)
[X,Y] = __np__.meshgrid(x,y)
r = __sqrt__(X**2+Y**2)
#Z = 20*X
Z = __sqrt__(14)*(8*X**4-8*X**2*r**2+r**4)*(6*r**2-5)
for i in range(len(Z)):
	for j in range(len(Z)):
		if x[i]**2+y[j]**2>1:
			Z[i][j]=0

d = 400
A = __np__.zeros([d,d])
A[d/2-49:d/2+51,d/2-49:d/2+51] = Z
__plt__.imshow(A)
__plt__.show()
def exp_func(a):
	if a == 0:
		return 0
Example #34
0
	def Z20(self,r,u):
		return __sqrt__(12)*r**5*__cos__(5*u)
Example #35
0
	def zernike2seidel(self):
		'''
		Ap is the piston aberration,coefficients Ai represent the 
		peak value of the corresponding Seidel aberration term,
		'''
		a = [0]+self.__coefficients__
		#Piston
		Ap = a[1]-__sqrt__(3)*a[4]+__sqrt__(5)*a[11]
		#tilt
		At = 2*__sqrt__((a[2]-__sqrt__(8)*a[8])**2+(a[3]-__sqrt__(8)*a[7])**2)
		Bt = __arctan2__(a[3]-__sqrt__(8)*a[7],a[2]-__sqrt__(8)*a[8])*180/__np__.pi
		#Astigmatism 
		Aa = 2*__sqrt__(6*(a[5]**2+a[6]**2))
		Ba = 0.5*__arctan2__(a[5],a[6])*180/__np__.pi
		#defocus
		Ad = 2*(__sqrt__(3)*a[4]-3*__sqrt__(5)*a[11]-Aa)
		#Coma
		Ac = 6*__sqrt__(2*(a[7]**2+a[8]**2))
		Bc = __arctan2__(a[7],a[8])*180/__np__.pi
		#Spherical
		As = 6*__sqrt__(5)*a[11]
		A = [Ap,At,Bt,Ad,Aa,Ba,Ac,Bc,As]


		seidellist=["Piston",
				 	"Tilt",
				 	"Defocus",
				 	"Astigmatism",
				 	"Coma",
				 	"Spherical"]
		Atable = [[Ap,0.0],[At,Bt],[Ad,0.0],[Aa,Ba],[Ac,Bc],[As,0.0]]
		print"                 Magnitude  Angle (Degrees)"
		print"-------------------------------------------"
		for i in range(len(seidellist)):
			print "| {0:>13s} |  {1:>8s}  | {2:>8s}   |".\
			format(seidellist[i],str(round(Atable[i][0],3)),str(round(Atable[i][1],3)))
		print"-------------------------------------------"
		SeidelCoefficient = __seidel2__.Coefficient(Atable)	
		return SeidelCoefficient
Example #36
0
	def Z22(self,r,u):
		return __sqrt__(7)*(20*r**6-30*r**4+12*r**2-1)
Example #37
0
def __zernikepolar__(coefficient,r,u):
	"""
	------------------------------------------------
	__zernikepolar__(coefficient,r,u):

	Return combined aberration

	Zernike Polynomials Caculation in polar coordinates

	coefficient: Zernike Polynomials Coefficient from input
	r: rho in polar coordinates
	u: theta in polar coordinates

	------------------------------------------------
	"""
	Z = [0]+coefficient
	Z1  =  Z[1]  * 1*(__cos__(u)**2+__sin__(u)**2)                                 
	Z2  =  Z[2]  * 2*r*__cos__(u)
	Z3  =  Z[3]  * 2*r*__sin__(u)
	Z4  =  Z[4]  * __sqrt__(3)*(2*r**2-1)
	Z5  =  Z[5]  * __sqrt__(6)*r**2*__sin__(2*u)
	Z6  =  Z[6]  * __sqrt__(6)*r**2*__cos__(2*u)
	Z7  =  Z[7]  * __sqrt__(8)*(3*r**2-2)*r*__sin__(u)
	Z8  =  Z[8]  * __sqrt__(8)*(3*r**2-2)*r*__cos__(u)
	Z9  =  Z[9]  * __sqrt__(8)*r**3*__sin__(3*u)
	Z10 =  Z[10] * __sqrt__(8)*r**3*__cos__(3*u)
	Z11 =  Z[11] * __sqrt__(5)*(1-6*r**2+6*r**4)
	Z12 =  Z[12] * __sqrt__(10)*(4*r**2-3)*r**2*__cos__(2*u)
	Z13 =  Z[13] * __sqrt__(10)*(4*r**2-3)*r**2*__sin__(2*u)
	Z14 =  Z[14] * __sqrt__(10)*r**4*__cos__(4*u)
	Z15 =  Z[15] * __sqrt__(10)*r**4*__sin__(4*u)
	Z16 =  Z[16] * __sqrt__(12)*(10*r**4-12*r**2+3)*r*__cos__(u)
	Z17 =  Z[17] * __sqrt__(12)*(10*r**4-12*r**2+3)*r*__sin__(u)
	Z18 =  Z[18] * __sqrt__(12)*(5*r**2-4)*r**3*__cos__(3*u)
	Z19 =  Z[19] * __sqrt__(12)*(5*r**2-4)*r**3*__sin__(3*u)
	Z20 =  Z[20] * __sqrt__(12)*r**5*__cos__(5*u)
	Z21 =  Z[21] * __sqrt__(12)*r**5*__sin__(5*u)
	Z22 =  Z[22] * __sqrt__(7)*(20*r**6-30*r**4+12*r**2-1)
	Z23 =  Z[23] * __sqrt__(14)*(15*r**4-20*r**2+6)*r**2*__sin__(2*u)
	Z24 =  Z[24] * __sqrt__(14)*(15*r**4-20*r**2+6)*r**2*__cos__(2*u)
	Z25 =  Z[25] * __sqrt__(14)*(6*r**2-5)*r**4*__sin__(4*u)
	Z26 =  Z[26] * __sqrt__(14)*(6*r**2-5)*r**4*__cos__(4*u)
	Z27 =  Z[27] * __sqrt__(14)*r**6*__sin__(6*u)
	Z28 =  Z[28] * __sqrt__(14)*r**6*__cos__(6*u)
	Z29 =  Z[29] * 4*(35*r**6-60*r**4+30*r**2-4)*r*__sin__(u)
	Z30 =  Z[30] * 4*(35*r**6-60*r**4+30*r**2-4)*r*__cos__(u)
	Z31 =  Z[31] * 4*(21*r**4-30*r**2+10)*r**3*__sin__(3*u)
	Z32 =  Z[32] * 4*(21*r**4-30*r**2+10)*r**3*__cos__(3*u)
	Z33 =  Z[33] * 4*(7*r**2-6)*r**5*__sin__(5*u)
	Z34 =  Z[34] * 4*(7*r**2-6)*r**5*__cos__(5*u)
	Z35 =  Z[35] * 4*r**7*__sin__(7*u)
	Z36 =  Z[36] * 4*r**7*__cos__(7*u)
	Z37 =  Z[37] * 3*(70*r**8-140*r**6+90*r**4-20*r**2+1)


	Z = Z1 + Z2 +  Z3+  Z4+  Z5+  Z6+  Z7+  Z8+  Z9+ \
		Z10+ Z11+ Z12+ Z13+ Z14+ Z15+ Z16+ Z17+ Z18+ Z19+ \
		Z20+ Z21+ Z22+ Z23+ Z24+ Z25+ Z26+ Z27+ Z28+ Z29+ \
		Z30+ Z31+ Z32+ Z33+ Z34+ Z35+ Z36+ Z37
	return Z
Example #38
0
	def Z25(self,r,u):
		return __sqrt__(14)*(6*r**2-5)*r**4*__sin__(4*u)
Example #39
0
def __zernikecartesian__(coefficient,x,y):
	"""
	------------------------------------------------
	__zernikecartesian__(coefficient,x,y):

	Return combined aberration

	Zernike Polynomials Caculation in Cartesian coordinates

	coefficient: Zernike Polynomials Coefficient from input
	x: x in Cartesian coordinates
	y: y in Cartesian coordinates
	------------------------------------------------
	"""
	Z = [0]+coefficient
	r = __sqrt__(x**2 + y**2)
	Z1  =  Z[1]  * 1
	Z2  =  Z[2]  * 2*x
	Z3  =  Z[3]  * 2*y
	Z4  =  Z[4]  * __sqrt__(3)*(2*r**2-1)
	Z5  =  Z[5]  * 2*__sqrt__(6)*x*y
	Z6  =  Z[6]  * __sqrt__(6)*(x**2-y**2)
	Z7  =  Z[7]  * __sqrt__(8)*y*(3*r**2-2)
	Z8  =  Z[8]  * __sqrt__(8)*x*(3*r**2-2)
	Z9  =  Z[9]  * __sqrt__(8)*y*(3*x**2-y**2)
	Z10 =  Z[10] * __sqrt__(8)*x*(x**2-3*y**2)
	Z11 =  Z[11] * __sqrt__(5)*(6*r**4-6*r**2+1)
	Z12 =  Z[12] * __sqrt__(10)*(x**2-y**2)*(4*r**2-3)
	Z13 =  Z[13] * 2*__sqrt__(10)*x*y*(4*r**2-3)
	Z14 =  Z[14] * __sqrt__(10)*(r**4-8*x**2*y**2)
	Z15 =  Z[15] * 4*__sqrt__(10)*x*y*(x**2-y**2)
	Z16 =  Z[16] * __sqrt__(12)*x*(10*r**4-12*r**2+3)
	Z17 =  Z[17] * __sqrt__(12)*y*(10*r**4-12*r**2+3)
	Z18 =  Z[18] * __sqrt__(12)*x*(x**2-3*y**2)*(5*r**2-4)
	Z19 =  Z[19] * __sqrt__(12)*y*(3*x**2-y**2)*(5*r**2-4)
	Z20 =  Z[20] * __sqrt__(12)*x*(16*x**4-20*x**2*r**2+5*r**4)
	Z21 =  Z[21] * __sqrt__(12)*y*(16*y**4-20*y**2*r**2+5*r**4)
	Z22 =  Z[22] * __sqrt__(7)*(20*r**6-30*r**4+12*r**2-1)
	Z23 =  Z[23] * 2*__sqrt__(14)*x*y*(15*r**4-20*r**2+6)
	Z24 =  Z[24] * __sqrt__(14)*(x**2-y**2)*(15*r**4-20*r**2+6)
	Z25 =  Z[25] * 4*__sqrt__(14)*x*y*(x**2-y**2)*(6*r**2-5)
	Z26 =  Z[26] * __sqrt__(14)*(8*x**4-8*x**2*r**2+r**4)*(6*r**2-5)
	Z27 =  Z[27] * __sqrt__(14)*x*y*(32*x**4-32*x**2*r**2+6*r**4)
	Z28 =  Z[28] * __sqrt__(14)*(32*x**6-48*x**4*r**2+18*x**2*r**4-r**6)
	Z29 =  Z[29] * 4*y*(35*r**6-60*r**4+30*r**2+10)
	Z30 =  Z[30] * 4*x*(35*r**6-60*r**4+30*r**2+10)
	Z31 =  Z[31] * 4*y*(3*x**2-y**2)*(21*r**4-30*r**2+10)
	Z32 =  Z[32] * 4*x*(x**2-3*y**2)*(21*r**4-30*r**2+10)
	Z33 =  Z[33] * 4*(7*r**2-6)*(4*x**2*y*(x**2-y**2)+y*(r**4-8*x**2*y**2))
	Z34 =  Z[34] * (4*(7*r**2-6)*(x*(r**4-8*x**2*y**2)-4*x*y**2*(x**2-y**2)))
	Z35 =  Z[35] * (8*x**2*y*(3*r**4-16*x**2*y**2)+4*y*(x**2-y**2)*(r**4-16*x**2*y**2))
	Z36 =  Z[36] * (4*x*(x**2-y**2)*(r**4-16*x**2*y**2)-8*x*y**2*(3*r**4-16*x**2*y**2))
	Z37 =  Z[37] * 3*(70*r**8-140*r**6+90*r**4-20*r**2+1)
	ZW = 	Z1 + Z2 +  Z3+  Z4+  Z5+  Z6+  Z7+  Z8+  Z9+ \
			Z10+ Z11+ Z12+ Z13+ Z14+ Z15+ Z16+ Z17+ Z18+ Z19+ \
			Z20+ Z21+ Z22+ Z23+ Z24+ Z25+ Z26+ Z27+ Z28+ Z29+ \
			Z30+ Z31+ Z32+ Z33+ Z34+ Z35+ Z36+ Z37
	return ZW
Example #40
0
	def Z27(self,r,u):
		return __sqrt__(14)*r**6*__sin__(6*u)
Example #41
0
	def Z6(self,r,u):
		return __sqrt__(6)*r**2*__cos__(2*u)
Example #42
0
def __zernikepolar__(coefficient,r,u):
	"""
	------------------------------------------------
	__zernikepolar__(coefficient,r,u):

	Return combined aberration

	Zernike Polynomials Caculation in polar coordinates

	coefficient: Zernike Polynomials Coefficient from input
	r: rho in polar coordinates
	u: theta in polar coordinates

	------------------------------------------------
	"""
	Z = [0]+coefficient
	Z1  =  Z[1]  * 1*(__cos__(u)**2+__sin__(u)**2)
	Z2  =  Z[2]  * 2*r*__cos__(u)
	Z3  =  Z[3]  * 2*r*__sin__(u)
	Z4  =  Z[4]  * __sqrt__(3)*(2*r**2-1)
	Z5  =  Z[5]  * __sqrt__(6)*r**2*__sin__(2*u)
	Z6  =  Z[6]  * __sqrt__(6)*r**2*__cos__(2*u)
	Z7  =  Z[7]  * __sqrt__(8)*(3*r**2-2)*r*__sin__(u)
	Z8  =  Z[8]  * __sqrt__(8)*(3*r**2-2)*r*__cos__(u)
	Z9  =  Z[9]  * __sqrt__(8)*r**3*__sin__(3*u)
	Z10 =  Z[10] * __sqrt__(8)*r**3*__cos__(3*u)
	Z11 =  Z[11] * __sqrt__(5)*(1-6*r**2+6*r**4)
	Z12 =  Z[12] * __sqrt__(10)*(4*r**2-3)*r**2*__cos__(2*u)
	Z13 =  Z[13] * __sqrt__(10)*(4*r**2-3)*r**2*__sin__(2*u)
	Z14 =  Z[14] * __sqrt__(10)*r**4*__cos__(4*u)
	Z15 =  Z[15] * __sqrt__(10)*r**4*__sin__(4*u)
	Z16 =  Z[16] * __sqrt__(12)*(10*r**4-12*r**2+3)*r*__cos__(u)
	Z17 =  Z[17] * __sqrt__(12)*(10*r**4-12*r**2+3)*r*__sin__(u)
	Z18 =  Z[18] * __sqrt__(12)*(5*r**2-4)*r**3*__cos__(3*u)
	Z19 =  Z[19] * __sqrt__(12)*(5*r**2-4)*r**3*__sin__(3*u)
	Z20 =  Z[20] * __sqrt__(12)*r**5*__cos__(5*u)
	Z21 =  Z[21] * __sqrt__(12)*r**5*__sin__(5*u)
	Z22 =  Z[22] * __sqrt__(7)*(20*r**6-30*r**4+12*r**2-1)
	Z23 =  Z[23] * __sqrt__(14)*(15*r**4-20*r**2+6)*r**2*__sin__(2*u)
	Z24 =  Z[24] * __sqrt__(14)*(15*r**4-20*r**2+6)*r**2*__cos__(2*u)
	Z25 =  Z[25] * __sqrt__(14)*(6*r**2-5)*r**4*__sin__(4*u)
	Z26 =  Z[26] * __sqrt__(14)*(6*r**2-5)*r**4*__cos__(4*u)
	Z27 =  Z[27] * __sqrt__(14)*r**6*__sin__(6*u)
	Z28 =  Z[28] * __sqrt__(14)*r**6*__cos__(6*u)
	Z29 =  Z[29] * 4*(35*r**6-60*r**4+30*r**2-4)*r*__sin__(u)
	Z30 =  Z[30] * 4*(35*r**6-60*r**4+30*r**2-4)*r*__cos__(u)
	Z31 =  Z[31] * 4*(21*r**4-30*r**2+10)*r**3*__sin__(3*u)
	Z32 =  Z[32] * 4*(21*r**4-30*r**2+10)*r**3*__cos__(3*u)
	Z33 =  Z[33] * 4*(7*r**2-6)*r**5*__sin__(5*u)
	Z34 =  Z[34] * 4*(7*r**2-6)*r**5*__cos__(5*u)
	Z35 =  Z[35] * 4*r**7*__sin__(7*u)
	Z36 =  Z[36] * 4*r**7*__cos__(7*u)
	Z37 =  Z[37] * 3*(70*r**8-140*r**6+90*r**4-20*r**2+1)


	Z = Z1 + Z2 +  Z3+  Z4+  Z5+  Z6+  Z7+  Z8+  Z9+ \
		Z10+ Z11+ Z12+ Z13+ Z14+ Z15+ Z16+ Z17+ Z18+ Z19+ \
		Z20+ Z21+ Z22+ Z23+ Z24+ Z25+ Z26+ Z27+ Z28+ Z29+ \
		Z30+ Z31+ Z32+ Z33+ Z34+ Z35+ Z36+ Z37
	return Z
Example #43
0
	def Z7(self,r,u):
		return __sqrt__(8)*(3*r**2-2)*r*__sin__(u)