Пример #1
0
	def __psfcaculator__(self,r=1,lambda_1=632*10**(-9),z=0.1):
		"""
		pupil: Exit pupil diameter
		z: Distance from exit pupil to image plane
		r: pupil radius, in unit of lambda
		"""
		pupil = l1 = 200 # exit pupil sample points
		x = __np__.linspace(-r, r, l1)
		[X,Y] = __np__.meshgrid(x,x)
		Z = __interferometer__.__zernikecartesian__(self.__coefficients__,X,Y)
		for i in range(len(Z)):
			for j in range(len(Z)):
				if x[i]**2+x[j]**2>r**2:
					Z[i][j] = 0
		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
		axis_1 = d/pupil*r
		fig = __plt__.figure()
		# ax = fig.gca()
		# __plt__.imshow(A,extent=[-axis_1,axis_1,-axis_1,axis_1],cmap=__cm__.RdYlGn)
		# ax.set_xlabel('mm',fontsize=14)
		# __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
Пример #2
0
	def __psfcaculator__(self,r=1,lambda_1=632*10**(-9),z=0.1):
		"""
		pupil: Exit pupil diameter
		z: Distance from exit pupil to image plane
		r: pupil radius, in unit of lambda
		"""
		pupil = l1 = 200 # exit pupil sample points
		x = __np__.linspace(-r, r, l1)
		[X,Y] = __np__.meshgrid(x,x)
		Z = __zernikecartesian__(self.__coefficients__,X,Y)
		for i in range(len(Z)):
			for j in range(len(Z)):
				if x[i]**2+x[j]**2>r**2:
					Z[i][j] = 0	
		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
		axis_1 = d/pupil*r
		fig = __plt__.figure()
		# ax = fig.gca()
		# __plt__.imshow(A,extent=[-axis_1,axis_1,-axis_1,axis_1],cmap=__cm__.RdYlGn)
		# ax.set_xlabel('mm',fontsize=14)
		# __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
Пример #3
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
Пример #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
Пример #5
0
 def otf(self, r=1, lambda_1=632 * 10**(-9), z=0.1, matrix=False):
     PSF = self.__psfcaculator__(r=r, lambda_1=lambda_1, z=z)
     OTF = __fftshift__(__fft2__(PSF))
     if matrix:
         return OTF
     else:
         return 0
Пример #6
0
    def mtf(self, r=1, lambda_1=632 * 10**(-9), z=0.1):
        """
		Modulate Transfer function
		"""
        PSF = self.__psfcaculator__(r=r, lambda_1=lambda_1, z=z)
        MTF = __fftshift__(__fft2__(PSF))
        MTF = MTF / MTF.max()
        f0 = r / 1000 / lambda_1 / z / 10000  # cutoff frequency?
        __plt__.imshow(abs(MTF), cmap=__cm__.bwr)
        __plt__.colorbar()
        __plt__.show()
        return 0
Пример #7
0
	def mtf(self,r=1,lambda_1=632*10**(-9),z=0.1):
		"""
		Modulate Transfer function
		"""
		PSF = self.__psfcaculator__(r=r,lambda_1=lambda_1,z=z)
		MTF = __fftshift__(__fft2__(PSF))
		MTF = MTF/MTF.max()
		f0 = r/1000/lambda_1/z/10000   # cutoff frequency?
		__plt__.imshow(abs(MTF),cmap=__cm__.bwr)
		__plt__.colorbar()
		__plt__.show()
		return 0
Пример #8
0
	def mtf(self,lambda_1=632*10**(-9),z=0.1,matrix = False):
		"""
		Modulate Transfer function
		"""
		PSF = self.__psfcaculator__(lambda_1=lambda_1,z=z)
		MTF = __fftshift__(__fft2__(PSF))
		MTF = MTF/MTF.max()
		fig = __plt__.figure(figsize=(9, 6), dpi=80)
		__plt__.imshow(abs(MTF),cmap=__cm__.bwr)
		__plt__.colorbar()
		__plt__.show()
		if matrix == True:
			return MTF
		else:
			return 0
Пример #9
0
    def mtf(self, lambda_1=632 * 10**(-9), z=0.1, matrix=False):
        """
		Modulate Transfer function
		"""
        PSF = self.__psfcaculator__(lambda_1=lambda_1, z=z)
        MTF = __fftshift__(__fft2__(PSF))
        MTF = MTF / MTF.max()
        fig = __plt__.figure(figsize=(9, 6), dpi=80)
        __plt__.imshow(abs(MTF), cmap=__cm__.bwr)
        __plt__.colorbar()
        __plt__.show()
        if matrix == True:
            return MTF
        else:
            return 0
Пример #10
0
	def ptf(self):
		"""
		Phase transfer function
		"""
		PSF = self.__psfcaculator__()
		PTF = __fftshift__(__fft2__(PSF))
		PTF = __np__.angle(PTF)
		l1 = 100
		d = 400
		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] = PTF[d/2-l1/2+1:d/2+l1/2+1,d/2-l1/2+1:d/2+l1/2+1]
		__plt__.imshow(abs(A),cmap=__cm__.rainbow)
		__plt__.colorbar()
		__plt__.show()
		return 0
Пример #11
0
	def ptf(self):
		"""
		Phase transfer function
		"""
		PSF = self.__psfcaculator__()
		PTF = __fftshift__(__fft2__(PSF))
		PTF = __np__.angle(PTF)
		l1 = 100
		d = 400
		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] = PTF[d//2-l1//2+1:d//2+l1//2+1,d//2-l1//2+1:d//2+l1//2+1]
		__plt__.imshow(abs(A),cmap=__cm__.rainbow)
		__plt__.colorbar()
		__plt__.show()
		return 0
Пример #12
0
	def ptf(self):
		"""
		Phase transfer function
		"""
		PSF = self.__psfcaculator__()
		PTF = __fftshift__(__fft2__(PSF))
		PTF = __np__.angle(PTF)
		b = 400
		R = (200)**2
		for i in range(b):
			for j in range(b):
				if (i-b/2)**2+(j-b/2)**2>R:
					PTF[i][j] = 0
		__plt__.imshow(abs(PTF),cmap=__cm__.rainbow)
		__plt__.colorbar()
		__plt__.show()
		return 0
Пример #13
0
	def ptf(self):
		"""
		Phase transfer function
		"""
		PSF = self.__psfcaculator__()
		PTF = __fftshift__(__fft2__(PSF))
		PTF = __np__.angle(PTF)
		b = 400
		R = (200)**2
		for i in range(b):
			for j in range(b):
				if (i-b/2)**2+(j-b/2)**2>R:
					PTF[i][j] = 0
		__plt__.imshow(abs(PTF),cmap=__cm__.rainbow)
		__plt__.colorbar()
		__plt__.show()
		return 0
Пример #14
0
    def mtf(self,
            r=1,
            lambda_1=632 * 10**(-9),
            z=0.1,
            draw=True,
            matrix=False):
        """
		Modulate Transfer function
		"""
        PSF = self.__psfcaculator__(r=r, lambda_1=lambda_1, z=z)
        MTF = __fftshift__(__fft2__(PSF))
        MTF = MTF / MTF.max()
        f0 = r / 1000 / lambda_1 / z / 10000  # cutoff frequency?
        if draw:
            fig = __plt__.figure(figsize=(9, 6), dpi=80)
            __plt__.imshow(abs(MTF), cmap=__cm__.bwr)
            __plt__.colorbar()
            __plt__.show()
        if matrix == True:
            return MTF
        else:
            return 0
Пример #15
0
	def otf(self,r=1,lambda_1=632*10**(-9),z=0.1):
		PSF = self.__psfcaculator__(r=r,lambda_1=lambda_1,z=z)
		OTF = __fftshift__(__fft2__(PSF))
		return 0
Пример #16
0
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
	else:
		return __np__.exp(1j*2*__np__.pi*a)
exp_func1 = __np__.vectorize(exp_func,otypes=[__np__.complex64])
abbe = exp_func1(A)

fig = __plt__.figure(2)
AP = abs(__fftshift__(__fft2__(__fftshift__(abbe))))**2
AP = AP/AP.max()
__plt__.imshow(AP)
__plt__.show()
Пример #17
0
	def otf(self,r=1,lambda_1=632*10**(-9),z=0.1):
		PSF = self.__psfcaculator__(r=r,lambda_1=lambda_1,z=z)
		OTF = __fftshift__(__fft2__(PSF))
		return 0
Пример #18
0
def lens_param_to_psf():
    import numpy as __np__
    from numpy import sqrt as __sqrt__
    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 mpl_toolkits.mplot3d import Axes3D
    from numpy.fft import fftshift as __fftshift__
    from numpy.fft import ifftshift as __ifftshift__
    from numpy.fft import fft2 as __fft2__

    def __apershow__(obj):
        obj = -abs(obj)
        __plt__.imshow(obj)
        __plt__.set_cmap('Greys')
        __plt__.show()

    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 = __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

    fig = __plt__.figure(1)
    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(-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)
    __plt__.show()

    d = 800
    A = __np__.zeros([d, d])
    A[d // 2 - 49:d // 2 + 51, d // 2 - 49:d // 2 + 51] = Z
    __plt__.imshow(A)
    __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
    fig = __plt__.figure(2)
    AP = abs(__fftshift__(__fft2__(__fftshift__(abbe))))**2
    AP = AP / AP.max()

    __plt__.imshow(AP)
    __plt__.show()