示例#1
0
def hartmann(coefficients, r, R):
    """
	Generate Hartmann spotdiagram
	use circle hartmann plate
	coefficients: zernike coefficients
	r: distance from the pupil of the wavefront to detect plate
	R: radius of mirror under test
	"""
    coefficients = coefficients.__coefficients__
    x_list = []
    y_list = []
    Ax_list = []
    Ay_list = []
    s = 40
    x = y = __np__.linspace(-R, R, s)
    M = []
    for i in x:
        tmp = []
        for j in y:
            if i**2 + j**2 < R**2:
                x_list.append(i)
                y_list.append(j)
                W0 = __zernike__.__zernikecartesian__(coefficients, i, j)
                Wx = __zernike__.__zernikecartesian__(coefficients, 1.01 * i,
                                                      j)
                Wy = __zernike__.__zernikecartesian__(coefficients, i,
                                                      1.01 * j)
                TAx = -(Wx - W0) / (0.01 * i) * r
                TAy = -(Wy - W0) / (0.01 * j) * r
                Ax_list.append(TAx)
                Ay_list.append(TAy)
                tmp.append([1, [i, j], [TAx, TAy]])
            else:
                tmp.append([0, [i, j], [0, 0]])
        M.append(tmp)
    fig = __plt__.figure(1, figsize=(6, 6))
    ax = fig.gca()
    ax.set_axis_bgcolor('black')
    __plt__.title('Hartmann Spotdiagram', fontsize=18)
    __plt__.plot(Ax_list, Ay_list, 'wo')
    __plt__.show()

    return M, r
示例#2
0
def hartmann(coefficients, r, R):
	"""
	Generate Hartmann spotdiagram
	use circle hartmann plate
	coefficients: zernike coefficients
	r: distance from the pupil of the wavefront to detect plate
	R: radius of mirror under test
	"""
	coefficients = coefficients.__coefficients__
	x_list = []
	y_list = []
	Ax_list = []
	Ay_list = []
	s = 40
	x = y = __np__.linspace(-R, R, s)
	M = []
	for i in x:
		tmp = []
		for j in y:
			if i**2 + j**2 < R**2:
				x_list.append(i)
				y_list.append(j)
				W0 = __zernike__.__zernikecartesian__(coefficients,i,j)
				Wx = __zernike__.__zernikecartesian__(coefficients,1.01*i,j)
				Wy = __zernike__.__zernikecartesian__(coefficients,i,1.01*j)
				TAx = -(Wx-W0)/(0.01*i)*r
				TAy = -(Wy-W0)/(0.01*j)*r
				Ax_list.append(TAx)
				Ay_list.append(TAy)
				tmp.append([1,[i,j],[TAx,TAy]])
			else:
				tmp.append([0,[i,j],[0,0]])
		M.append(tmp)
	fig = __plt__.figure(1,figsize=(6, 6))
	ax = fig.gca()
	ax.set_axis_bgcolor('black')
	__plt__.title('Hartmann Spotdiagram',fontsize=18)
	__plt__.plot(Ax_list,Ay_list,'wo')
	__plt__.show()

	return M,r
def twyman_green(coefficients, lambda_1=632, PR=1):
    """
	Genertate Twyman_Green Interferogram based on zernike polynomials
	=============================================

	input
	----------------------------------------------

	Class zernike polynomials coefficients in wavenumber

	see Class:opticspy.zernike.Coefficients

	lambda_1: wavelength in nanometer, default = 632nm
	PR: pupil radius, default = 1mm

	output
	----------------------------------------------
	Interferogram of aberration
	"""
    lambda_1 = lambda_1 * (10**-9)
    coefficients = coefficients.__coefficients__
    r = __np__.linspace(-PR, PR, 400)
    x, y = __np__.meshgrid(r, r)
    rr = __np__.sqrt(x**2 + y**2)
    OPD = __zernike__.__zernikecartesian__(coefficients, x, y) * 2 / PR

    ph = 2 * __np__.pi * OPD
    I1 = 1
    I2 = 1
    Ixy = I1 + I2 + 2 * __np__.sqrt(I1 * I2) * __np__.cos(ph)
    __tools__.makecircle(Ixy, r, PR)
    #======================================================
    fig = __plt__.figure(figsize=(9, 6), dpi=80)
    __plt__.imshow(-Ixy, extent=[-PR, PR, -PR, PR])
    __plt__.set_cmap('Greys')

    label = 'Zernike Coefficients:'
    m = 1
    for i in coefficients:
        if i != 0:
            label = label + "Z" + str(m) + "=" + str(i) + " "
        m = m + 1
    __plt__.xlabel(label, fontsize=16)
    __plt__.title('Twyman Green Interferogram', fontsize=16)
    fig.set_tight_layout(True)
    __plt__.show()
示例#4
0
def twyman_green(coefficients, lambda_1 = 632, PR = 1):
	"""
	Genertate Twyman_Green Interferogram based on zernike polynomials
	=============================================

	input
	----------------------------------------------

	Class zernike polynomials coefficients in wavenumber

	see Class:opticspy.zernike.Coefficients

	lambda_1: wavelength in nanometer, default = 632nm
	PR: pupil radius, default = 1mm

	output
	----------------------------------------------
	Interferogram of aberration
	"""
	lambda_1 = lambda_1*(10**-9)
	coefficients = coefficients.__coefficients__
	r = __np__.linspace(-PR, PR, 400)
	x, y = __np__.meshgrid(r,r)
	rr = __np__.sqrt(x**2 + y**2)
	OPD = 	__zernike__.__zernikecartesian__(coefficients,x,y)*2/PR

	ph = 2 * __np__.pi * OPD
	I1 = 1
	I2 = 1
	Ixy = I1 + I2 + 2 * __np__.sqrt(I1*I2) * __np__.cos(ph)
	__tools__.makecircle(Ixy, r, PR)
#======================================================
	fig = __plt__.figure(figsize=(9, 6), dpi=80)
	__plt__.imshow(-Ixy, extent=[-PR,PR,-PR,PR])
	__plt__.set_cmap('Greys')

	label = 'Zernike Coefficients:'
	m = 1
	for i in coefficients:
		if i!=0:
			label = label + "Z" + str(m) + "=" + str(i) +" "
		m = m + 1
	__plt__.xlabel(label,fontsize=16)
	__plt__.title('Twyman Green Interferogram',fontsize=16)
	fig.set_tight_layout(True)
	__plt__.show()
def twyman_green(coefficients, lambda_1=632, PR=1):
    """
	Genertate Twyman_Green Interferogram based on zernike polynomials
	=============================================
	
	input
	----------------------------------------------
	
	Class zernike polynomials coefficients in wavenumber
	 
	see Class:opticspy.zernike.Coefficients
	
	lambda_1: wavelength in nanometer, default = 632nm
	PR: pupil radius, default = 1mm

	output
	----------------------------------------------
	Interferogram of aberration
	"""
    lambda_1 = lambda_1 * (10**-9)
    coefficients = coefficients.__coefficients__
    r = __np__.linspace(-PR, PR, 400)
    x, y = __np__.meshgrid(r, r)
    rr = __np__.sqrt(x**2 + y**2)
    OPD = __zernike__.__zernikecartesian__(coefficients, x, y) * 2 / PR

    ph = 2 * __np__.pi * OPD
    I1 = 1
    I2 = 1
    Ixy = I1 + I2 + 2 * __np__.sqrt(I1 * I2) * __np__.cos(ph)
    __tools__.makecircle(Ixy, r, PR)
    #======================================================
    fig = __plt__.figure(figsize=(11, 9), dpi=60)
    __plt__.imshow(-Ixy, extent=[-PR, PR, -PR, PR])
    ax = fig.gca()
    ax.set_aspect('equal', 'datalim')
    __plt__.set_cmap('Greys')
    __plt__.title('Twyman Green Interferogram', fontsize=18)
    __plt__.colorbar()
    fig.set_tight_layout(True)
    return fig


################################################################
def twyman_green(coefficients, lambda_1 = 632, PR = 1):
	"""
	Genertate Twyman_Green Interferogram based on zernike polynomials
	=============================================
	
	input
	----------------------------------------------
	
	Class zernike polynomials coefficients in wavenumber
	 
	see Class:opticspy.zernike.Coefficients
	
	lambda_1: wavelength in nanometer, default = 632nm
	PR: pupil radius, default = 1mm

	output
	----------------------------------------------
	Interferogram of aberration
	"""
	lambda_1 = lambda_1*(10**-9)
	coefficients = coefficients.__coefficients__
	r = __np__.linspace(-PR, PR, 400)
	x, y = __np__.meshgrid(r,r) 
	rr = __np__.sqrt(x**2 + y**2)
	OPD = 	__zernike__.__zernikecartesian__(coefficients,x,y)*2/PR

	ph = 2 * __np__.pi * OPD
	I1 = 1
	I2 = 1
	Ixy = I1 + I2 + 2 * __np__.sqrt(I1*I2) * __np__.cos(ph)
	__tools__.makecircle(Ixy, r, PR)
#======================================================
	fig = __plt__.figure(figsize=(11, 9), dpi=60)
	__plt__.imshow(-Ixy, extent=[-PR,PR,-PR,PR])
	ax = fig.gca()
	ax.set_aspect('equal', 'datalim')
	__plt__.set_cmap('Greys')
	__plt__.title('Twyman Green Interferogram',fontsize=18)
	__plt__.colorbar()
	fig.set_tight_layout(True)
	return fig

################################################################
def phase_shift(coefficients,
                lambda_1=632,
                PR=1,
                type='4-step',
                noise=0,
                sample=200):
    """
	Genertate phase_shift Interferogram from interferometer
	based on zernike polynomials and twyman_green interferometer
	===========================================================

	input
	----------------------------------------------

	Class zernike polynomials coefficients in wavenumber

	see Class:opticspy.zernike.Coefficients

	lambda_1: wavelength in nanometer, default = 632nm
	PR: pupil radius, default = 1(also use this value for aperture matrix generate)
	type: PSI algorithm default:'4-step'
	boundary: if have a aperture
	noise: from 0 to 1, default 0
	sample: sample points

	output
	----------------------------------------------
	Interferogram of aberration
	"""
    lambda_1 = lambda_1 * (10**-9)
    coefficients = coefficients.__coefficients__
    r = __np__.linspace(-PR, PR, sample)
    x, y = __np__.meshgrid(r, r)
    rr = __np__.sqrt(x**2 + y**2)
    OPD = __zernike__.__zernikecartesian__(coefficients, x, y) * 2 / PR
    Ia = 1
    Ib = 1
    ph = 2 * __np__.pi * OPD

    if type == "4-step":
        __tools__.makecircle_boundary(OPD, r, PR, 0)
        im = __plt__.imshow(OPD, extent=[-PR, PR, -PR, PR], cmap=__cm__.RdYlGn)
        __plt__.colorbar()
        __plt__.title('Surface figure', fontsize=16)
        __plt__.show()

        I1 = Ia + Ib + 2 * __np__.sqrt(Ia * Ib) * __np__.cos(ph)
        I2 = Ia + Ib + 2 * __np__.sqrt(
            Ia * Ib) * __np__.cos(ph + 90.0 / 180 * __np__.pi)
        I3 = Ia + Ib + 2 * __np__.sqrt(
            Ia * Ib) * __np__.cos(ph + 180.0 / 180 * __np__.pi)
        I4 = Ia + Ib + 2 * __np__.sqrt(
            Ia * Ib) * __np__.cos(ph + 270.0 / 180 * __np__.pi)
        if noise != 0:
            # add noise / default noise 0
            I1 = I1 + I1 * noise * __np__.random.randn(sample, sample)
            I2 = I2 + I2 * noise * __np__.random.randn(sample, sample)
            I3 = I3 + I3 * noise * __np__.random.randn(sample, sample)
            I4 = I4 + I4 * noise * __np__.random.randn(sample, sample)
        __tools__.makecircle_boundary(I1, r, PR, 0)
        __tools__.makecircle_boundary(I2, r, PR, 0)
        __tools__.makecircle_boundary(I3, r, PR, 0)
        __tools__.makecircle_boundary(I4, r, PR, 0)
        I = [I1, I2, I3, I4]
        __tools__.phase_shift_figure(I, PR, type="4-step")
        M = __np__.ones([sample, sample])  #map matrix, which is boundary
        __tools__.makecircle_boundary(M, r, PR, 0)

        # fig = __plt__.figure(figsize=(8, 6), dpi=80)
        # im = __plt__.pcolormesh(M,cmap=__cm__.RdYlGn)
        # __plt__.title('Phase value map',fontsize=16)
        # __plt__.colorbar()
        # __plt__.show()

        return [I, PR, M, sample]
    else:
        print("No this type of PSI")
示例#8
0
def phase_shift(coefficients, lambda_1 = 632, PR = 1, type = '4-step', noise = 0, sample = 200):
	"""
	Genertate phase_shift Interferogram from interferometer
	based on zernike polynomials and twyman_green interferometer
	===========================================================

	input
	----------------------------------------------

	Class zernike polynomials coefficients in wavenumber

	see Class:opticspy.zernike.Coefficients

	lambda_1: wavelength in nanometer, default = 632nm
	PR: pupil radius, default = 1(also use this value for aperture matrix generate)
	type: PSI algorithm default:'4-step'
	boundary: if have a aperture
	noise: from 0 to 1, default 0
	sample: sample points

	output
	----------------------------------------------
	Interferogram of aberration
	"""
	lambda_1 = lambda_1*(10**-9)
	coefficients = coefficients.__coefficients__
	r = __np__.linspace(-PR, PR, sample)
	x, y = __np__.meshgrid(r,r)
	rr = __np__.sqrt(x**2 + y**2)
	OPD = 	__zernike__.__zernikecartesian__(coefficients,x,y)*2/PR
	Ia = 1
	Ib = 1
	ph = 2 * __np__.pi * OPD

	if type == "4-step":
		__tools__.makecircle_boundary(OPD, r, PR, 0)
		im = __plt__.imshow(OPD,extent=[-PR,PR,-PR,PR],cmap=__cm__.RdYlGn)
		__plt__.colorbar()
		__plt__.title('Surface figure',fontsize=16)
		__plt__.show()

		I1 = Ia + Ib + 2 * __np__.sqrt(Ia*Ib) * __np__.cos(ph)
		I2 = Ia + Ib + 2 * __np__.sqrt(Ia*Ib) * __np__.cos(ph+90.0/180*__np__.pi)
		I3 = Ia + Ib + 2 * __np__.sqrt(Ia*Ib) * __np__.cos(ph+180.0/180*__np__.pi)
		I4 = Ia + Ib + 2 * __np__.sqrt(Ia*Ib) * __np__.cos(ph+270.0/180*__np__.pi)
		if noise != 0:
			# add noise / default noise 0
			I1 = I1 + I1*noise*__np__.random.randn(sample,sample)
			I2 = I2 + I2*noise*__np__.random.randn(sample,sample)
			I3 = I3 + I3*noise*__np__.random.randn(sample,sample)
			I4 = I4 + I4*noise*__np__.random.randn(sample,sample)
		__tools__.makecircle_boundary(I1, r, PR, 0)
		__tools__.makecircle_boundary(I2, r, PR, 0)
		__tools__.makecircle_boundary(I3, r, PR, 0)
		__tools__.makecircle_boundary(I4, r, PR, 0)
		I = [I1,I2,I3,I4]
		__tools__.phase_shift_figure(I,PR,type = "4-step")
		M = __np__.ones([sample,sample])	 #map matrix, which is boundary
		__tools__.makecircle_boundary(M, r, PR, 0)

		# fig = __plt__.figure(figsize=(8, 6), dpi=80)
		# im = __plt__.pcolormesh(M,cmap=__cm__.RdYlGn)
		# __plt__.title('Phase value map',fontsize=16)
		# __plt__.colorbar()
		# __plt__.show()

		return [I,PR,M,sample]
	else:
		print("No this type of PSI")