示例#1
0
def metatron(data, center,  phi, dp, sp, pixelsize):
    '''
    Description:
        metatron uses the relevant physical parameters from the laser bench
        setup and computes a transform that goes from the detector plane
        (what we measure) to the screen plane (what we want to measure).
        It is a helper function only intended to be called by fat_angel.

    Inputs:
        data      - ndarray
                    The data to be transformed. This is only used to make 
                    sure the transform has the right dimensions.
        center    - Tuple
                    The center of the ring in pixels
        phi       - Float
                    The angle between the detector normal and the screen normal
                    in radians.
        dp        - Float
                    The distance from the center of the screen to the front 
                    glass of the camera lens, in millimeters.
        sp        - Float
                    The image distance given the object distance and lens focal
                    length, in millimeters.
        pixelsize - Float
                    The size of the detector pixels, in microns.

    Output:
        The output is a ndarray that contains the real physical distance of
        each pixel from the center of the ring at the SCREEN PLANE. In other 
        words, all the pixels of the same value correspond to a perfect 
        circle on the screen.
    '''

    '''first get the distances in the detector plane'''
    r = ADE.dist_gen(data,center)*pixelsize
    alpha = ADE.angle_gen(data,center)

    '''now transform. See my notebook pages 101-103 for an explanation'''
#    den = sp**2*(np.cos(2*alpha) - 2*np.cos(alpha)**2*np.cos(2*phi))\
#        + 4*r**2 - 3*sp**2
#    bignum = 2*dp*r*(\
#        (sp-r)*(sp+r)\
#            *(3 + np.cos(2*phi) - 2*np.cos(2*alpha)*np.sin(phi)**2)\
#            )**0.5
#    t_dist = (4*dp*r**2*np.cos(alpha)*np.sin(phi) - bignum)/den

    den = sp*(np.cos(alpha)**2*np.cos(phi)**2 + np.sin(alpha)**2)**0.5 \
        + r*np.cos(alpha)*np.sin(phi)

    t_dist = dp*r/den
    
    return t_dist