def g2jd(y, m, d):
    ''' convert a Gregorian date to JD
    from AA, p61
    '''

    if m <= 2:
        y -= 1
        m += 12
    a = int(y / 100)
    julian = False
    if y < 1582:
        julian = True
    elif y == 1582:
        if m < 10:
            julian = True
        if m == 10 and d <= 5:
            julian = True
        if m == 10 and d > 5 and d < 15:
            return 2299160.5
    if julian:
        b = 0
    else:
        b = 2 - a + int(a / 4)

    # 30.6001 is a hack Meeus suggested
    return int(365.25 * (y + 4716)) + int(30.6001 * (m + 1)) + d + b - 1524.5
 convert a Gregorian date to JD
    from AA, p61
    
aa.py