コード例 #1
0
ファイル: diffraction.py プロジェクト: yumcyaWiz/opticspy
def fresnel(aperture, z=2, lambda1=660 * 10**(-9)):
    aperturelist = [
        'rectangle', 'doublerectangle', 'frame', 'doublecircle', 'ring'
    ]
    if aperture.__type__ == 'circle':
        n = aperture.__background__
        d = aperture.__d__
        D = aperture.__d__ * aperture.__scale__
        scale = aperture.__scale__
        Nf = D**2 / (4 * lambda1 * z)
        #Fresnel number. Smaller is better for single-DFT Fresnel
        print("Fresnel number = ", Nf)
    elif aperture.__type__ in aperturelist:
        print(aperture.__type__)
        n = aperture.__background__
        scale = aperture.__scale__
    else:
        print("No this kind aperture for fresnel diffraction")

    x1 = __np__.linspace(-n / 2 + 1, n / 2, n)
    [x, y] = __np__.meshgrid(x1, x1)
    # Single-DFT
    e1 = __np__.exp(1j * 2 * __np__.pi / lambda1 * (x**2 + y**2) / 2 / z *
                    ((scale)**2))
    diffraction = __np__.fft.fftshift(__np__.fft.fft2(aperture.__aper__ * e1))

    extent = n * scale
    __tools__.__apershow__(diffraction, extent=extent)
    return diffraction
コード例 #2
0
ファイル: diffraction.py プロジェクト: Diti24/opticspy
def fresnel(aperture,z = 2,lambda1 = 660*10**(-9)):
	aperturelist = ['rectangle','doublerectangle','frame','doublecircle','ring']
	if aperture.__type__ == 'circle':
		n = aperture.__background__
		d = aperture.__d__
		D = aperture.__d__*aperture.__scale__
		scale = aperture.__scale__
		Nf = D**2/(4*lambda1*z);  #Fresnel number. Smaller is better for single-DFT Fresnel
		print("Fresnel number = ", Nf)
	elif aperture.__type__ in aperturelist:
		print(aperture.__type__)
		n = aperture.__background__
		scale = aperture.__scale__
	else:
		print("No this kind aperture for fresnel diffraction")

	x1 = __np__.linspace(-n/2+1,n/2,n)
	[x,y] = __np__.meshgrid(x1,x1)
	# Single-DFT
	e1 = __np__.exp(1j*2*__np__.pi/lambda1*(x**2+y**2)/2/z*((scale)**2))
	diffraction = __np__.fft.fftshift(__np__.fft.fft2(aperture.__aper__*e1))

	extent = n*scale
	__tools__.__apershow__(diffraction, extent = extent)
	return diffraction
コード例 #3
0
ファイル: aperture.py プロジェクト: minjungkh/opticspy
    def otf(self):
        """
		Compute an aperture's otf
		"""
        print "-------------OTF---------------"
        aperfft = __np__.fft.fftshift(__np__.fft.fft2(self.__aper__)) ** 2
        aper_OTF = __np__.fft.fftshift(__np__.fft.fft2(aperfft))
        __tools__.__apershow__(aper_OTF, extent=0)
        return 0
コード例 #4
0
ファイル: aperture.py プロジェクト: minjungkh/opticspy
    def otf(self):
        """
		Compute an aperture's otf
		"""
        print "-------------OTF---------------"
        aperfft = __np__.fft.fftshift(__np__.fft.fft2(self.__aper__))**2
        aper_OTF = __np__.fft.fftshift(__np__.fft.fft2(aperfft))
        __tools__.__apershow__(aper_OTF, extent=0)
        return 0
コード例 #5
0
ファイル: diffraction.py プロジェクト: Diti24/opticspy
def fraunhofer(aperture, z = 2, lambda1 = 660*10**(-9)):
	"""
	Fraunhofer diffraction
	"""
	diffraction = 1j*__np__.exp(1j*2*__np__.pi/lambda1*z)/lambda1/z*__np__.fft.fftshift(__np__.fft.fft2(aperture.__aper__))

	extent = aperture.__background__*aperture.__scale__
	__tools__.__apershow__(diffraction, extent)
	return diffraction
コード例 #6
0
ファイル: diffraction.py プロジェクト: yumcyaWiz/opticspy
def fraunhofer(aperture, z=2, lambda1=660 * 10**(-9)):
    """
	Fraunhofer diffraction
	"""
    diffraction = 1j * __np__.exp(
        1j * 2 * __np__.pi / lambda1 * z) / lambda1 / z * __np__.fft.fftshift(
            __np__.fft.fft2(aperture.__aper__))

    extent = aperture.__background__ * aperture.__scale__
    __tools__.__apershow__(diffraction, extent)
    return diffraction
コード例 #7
0
ファイル: aperture.py プロジェクト: minjungkh/opticspy
    def show(self):
        """
		Show aperture figure

		Output
		------------------------------------
		Aperture figure

		"""

        print "---------show aperture--------"
        extent = self.__scale__ * self.__background__
        __tools__.__apershow__(self.__aper__, extent)
コード例 #8
0
ファイル: aperture.py プロジェクト: minjungkh/opticspy
    def show(self):

        """
		Show aperture figure

		Output
		------------------------------------
		Aperture figure

		"""

        print "---------show aperture--------"
        extent = self.__scale__ * self.__background__
        __tools__.__apershow__(self.__aper__, extent)