Calculate the difference between Terrestrial Dynamical Time (TD)
    and Universal Time (UT).

    Note: This function is not yet compatible for calculations using
    Numba.

    Equations taken from http://eclipse.gsfc.nasa.gov/SEcat5/deltatpoly.html

def calculate_deltat(year, month):
    """Calculate the difference between Terrestrial Dynamical Time (TD)
    and Universal Time (UT).

    Note: This function is not yet compatible for calculations using
    Numba.

    Equations taken from http://eclipse.gsfc.nasa.gov/SEcat5/deltatpoly.html
    """

    plw = 'Deltat is unknown for years before -1999 and after 3000. ' \
          'Delta values will be calculated, but the calculations ' \
          'are not intended to be used for these years.'

    try:
        if np.any((year > 3000) | (year < -1999)):
            warnings.warn(plw)
    except ValueError:
        if (year > 3000) | (year < -1999):
            warnings.warn(plw)
    except TypeError:
        return 0

    y = year + (month - 0.5)/12

    deltat = np.where(year < -500,

                      -20+32*((y-1820)/100)**2, 0)

    deltat = np.where((-500 <= year) & (year < 500),

                      10583.6-1014.41*(y/100)
                      + 33.78311*(y/100)**2
                      - 5.952053*(y/100)**3
                      - 0.1798452*(y/100)**4
                      + 0.022174192*(y/100)**5
                      + 0.0090316521*(y/100)**6, deltat)

    deltat = np.where((500 <= year) & (year < 1600),

                      1574.2-556.01*((y-1000)/100)
                      + 71.23472*((y-1000)/100)**2
                      + 0.319781*((y-1000)/100)**3
                      - 0.8503463*((y-1000)/100)**4
                      - 0.005050998*((y-1000)/100)**5
                      + 0.0083572073*((y-1000)/100)**6, deltat)

    deltat = np.where((1600 <= year) & (year < 1700),

                      120-0.9808*(y-1600)
                      - 0.01532*(y-1600)**2
                      + (y-1600)**3/7129, deltat)

    deltat = np.where((1700 <= year) & (year < 1800),

                      8.83+0.1603*(y-1700)
                      - 0.0059285*(y-1700)**2
                      + 0.00013336*(y-1700)**3
                      - (y-1700)**4/1174000, deltat)

    deltat = np.where((1800 <= year) & (year < 1860),

                      13.72-0.332447*(y-1800)
                      + 0.0068612*(y-1800)**2
                      + 0.0041116*(y-1800)**3
                      - 0.00037436*(y-1800)**4
                      + 0.0000121272*(y-1800)**5
                      - 0.0000001699*(y-1800)**6
                      + 0.000000000875*(y-1800)**7, deltat)

    deltat = np.where((1860 <= year) & (year < 1900),

                      7.62+0.5737*(y-1860)
                      - 0.251754*(y-1860)**2
                      + 0.01680668*(y-1860)**3
                      - 0.0004473624*(y-1860)**4
                      + (y-1860)**5/233174, deltat)

    deltat = np.where((1900 <= year) & (year < 1920),

                      -2.79+1.494119*(y-1900)
                      - 0.0598939*(y-1900)**2
                      + 0.0061966*(y-1900)**3
                      - 0.000197*(y-1900)**4, deltat)

    deltat = np.where((1920 <= year) & (year < 1941),

                      21.20+0.84493*(y-1920)
                      - 0.076100*(y-1920)**2
                      + 0.0020936*(y-1920)**3, deltat)

    deltat = np.where((1941 <= year) & (year < 1961),

                      29.07+0.407*(y-1950)
                      - (y-1950)**2/233
                      + (y-1950)**3/2547, deltat)

    deltat = np.where((1961 <= year) & (year < 1986),

                      45.45+1.067*(y-1975)
                      - (y-1975)**2/260
                      - (y-1975)**3/718, deltat)

    deltat = np.where((1986 <= year) & (year < 2005),

                      63.86+0.3345*(y-2000)
                      - 0.060374*(y-2000)**2
                      + 0.0017275*(y-2000)**3
                      + 0.000651814*(y-2000)**4
                      + 0.00002373599*(y-2000)**5, deltat)

    deltat = np.where((2005 <= year) & (year < 2050),

                      62.92+0.32217*(y-2000)
                      + 0.005589*(y-2000)**2, deltat)

    deltat = np.where((2050 <= year) & (year < 2150),

                      -20+32*((y-1820)/100)**2
                      - 0.5628*(2150-y), deltat)

    deltat = np.where(year >= 2150,

                      -20+32*((y-1820)/100)**2, deltat)

    deltat = deltat.item() if np.isscalar(year) & np.isscalar(month)\
        else deltat

    return deltat