def angle_factor(angle, ab, msrc, mrec):
    r"""Return the angle-dependent factor.

    The whole calculation in the wavenumber domain is only a function of the
    distance between the source and the receiver, it is independent of the
    angel. The angle-dependency is this factor, which can be applied to the
    corresponding parts in the wavenumber or in the frequency domain.

    The ``angle_factor`` corresponds to the sine and cosine-functions in Eqs
    105-107, 111-116, 119-121, 123-128.

    This function is called from one of the Hankel functions in
    :mod:`transform`.  Consult the modelling routines in :mod:`model` for a
    description of the input and output parameters.

    """

    # 33/66 are completely symmetric and hence independent of angle
    if ab in [33, ]:
        return np.ones(angle.size)

    # Evaluation angle
    eval_angle = angle.copy()

    # Add pi if receiver is magnetic (reciprocity), but not if source is
    # electric, because then source and receiver are swapped, ME => EM:
    # G^me_ab(s, r, e, z) = -G^em_ba(r, s, e, z).
    if mrec and not msrc:
        eval_angle += np.pi

    # Define fct (cos/sin) and angles to be tested
    if ab in [11, 22, 15, 24, 13, 31, 26, 35]:
        fct = np.cos
        test_ang_1 = np.pi/2
        test_ang_2 = 3*np.pi/2
    else:
        fct = np.sin
        test_ang_1 = np.pi
        test_ang_2 = 2*np.pi

    if ab in [11, 22, 15, 24, 12, 21, 14, 25]:
        eval_angle *= 2

    # Get factor
    factAng = fct(eval_angle)

    # Ensure cos([pi/2, 3pi/2]) and sin([pi, 2pi]) are zero (floating pt issue)
    factAng[np.isclose(np.abs(eval_angle), test_ang_1, 1e-10, 1e-14)] = 0
    factAng[np.isclose(np.abs(eval_angle), test_ang_2, 1e-10, 1e-14)] = 0

    return factAng
def angle_factor ( angle , ab , msrc , mrec ) : if ab in [ 33 , ] : return np . ones ( angle . size ) eval_angle = angle . copy ( ) if mrec and not msrc : eval_angle += np . pi if ab in [ 11 , 22 , 15 , 24 , 13 , 31 , 26 , 35 ] : fct = np . cos test_ang_1 = np . pi / 2 test_ang_2 = 3 * np . pi / 2 else : fct = np . sin test_ang_1 = np . pi test_ang_2 = 2 * np . pi if ab in [ 11 , 22 , 15 , 24 , 12 , 21 , 14 , 25 ] : eval_angle *= 2 factAng = fct ( eval_angle ) factAng [ np . isclose ( np . abs ( eval_angle ) , test_ang_1 , 1e-10 , 1e-14 ) ] = 0 factAng [ np . isclose ( np . abs ( eval_angle ) , test_ang_2 , 1e-10 , 1e-14 ) ] = 0 return factAng
r"""Return the angle-dependent factor.

    The whole calculation in the wavenumber domain is only a function of the
    distance between the source and the receiver, it is independent of the
    angel. The angle-dependency is this factor, which can be applied to the
    corresponding parts in the wavenumber or in the frequency domain.

    The ``angle_factor`` corresponds to the sine and cosine-functions in Eqs
    105-107, 111-116, 119-121, 123-128.

    This function is called from one of the Hankel functions in
    :mod:`transform`.  Consult the modelling routines in :mod:`model` for a
    description of the input and output parameters.