def moon_libration(jd):
    ''' compute  libration of the Moon

    Arg:
        jd  JDE

    Return:
        longitude in radians

    '''
    t = (jde - J2000) / 36525.0
    t2 = t * t
    t3 = t2 * t
    t4 = t3 * t
    # mean longitude, referred to the mean equinox of the date, and including
    # the constant term of the effect of light-time
    Lp = (218.3164591 + t * 481267.88134236 +
                        t2 * -0.0013268 +
                        t3 / 538841.0 +
                        t4 / 65194000.0)
    # mean elongation of the moon
    D = (297.8502042 + t * 445267.1115168 +
                        t2 * -0.00163 +
                        t3 / 545868.0 +
                        t4 / 113065000.0)
    # sun's mean anomaly
    M = (357.5291092 + t * 35999.0502909 +
                        t2 * -0.0001536 +
                        t3 / 24490000.0)
    # moon's mean anomaly
    Mx = (134.9634114 + t * 477198.8676313 +
                        t2 * 0.0089970 +
                        t3 / 69699.0 +
                        t4 / -14712000.0)
    # moon's argument of latitude 45.5
    F = (93.2720993 + t * 483202.0175273 +
                        t2 * -0.0034029 +
                        t3 / 3526000.0 +
                        t4 / 863310000.0)
    # 45.7
    OMEGA = (125.044555 - 1934.1361849 * t + 0.0020762 * t2 - t3 / 80053.0
                + t4 / 18999000.0)
    # other args in degree
    A1 = 119.75 + 131.849 * t
    A2 = 53.09 + 479264.29 * t
    #A3 = 313.45 + 481266.484 * t

    E = 1 + t * (-0.002516 - 0.0000074 * t)

    suml = 0
    for row in moon_tableA:
        pd, pm, pmx, pf, plong, plat = row
        if pm == 1 or pm == -1:
            pm *= E
        elif pm == 2 or pm == -2:
            pm *= E * E
        arg = pd * D + pm * M + pmx * Mx + pf * F
        suml += plong * math.sin(math.radians(arg))
    suml += 3958 * math.sin(math.radians(A1))
    suml += 1962 * math.sin(math.radians(Lp - F))
    suml += 318 * math.sin(math.radians(A2))

    # moon longitude in degrees
    res = Lp + suml / 1000000.0
    # apparent longitude, add nutation

    if not ignorenutation:
        return math.radians(res % 360) + nutation(jde)
    else:
        return math.radians(res % 360)
 compute  libration of the Moon

    Arg:
        jd  JDE

    Return:
        longitude in radians

    
aa.py