def RUWE_u0(g_mag=0, bp_rp=0):
    """Adapted from https://github.com/adrn/pyia/blob/master/pyia/ruwetools.py
    Return the normalization factor for the re-normalised unit weight error for a Gaia DR2 solution.
    Tables and techincal note on RUWE found here: https://www.cosmos.esa.int/web/gaia/dr2-known-issues
    """
    import numpy as np
    from scipy.interpolate import RectBivariateSpline
    ngmagbins = 1741
    ncolorbins = 111
    if g_mag != 0 and bp_rp != 0:
        u0data = np.genfromtxt('myastrotools/table_u0_g_col.txt', names=[
            'g_mag', 'bp_rp', 'u0'], skip_header=1, delimiter=',')
        gmagmesh = np.reshape(u0data['g_mag'], (ngmagbins, ncolorbins))
        bprpmesh = np.reshape(u0data['bp_rp'], (ngmagbins, ncolorbins))
        u0mesh = np.reshape(u0data['u0'], (ngmagbins, ncolorbins))
        gmag = gmagmesh[:, (0)]
        bprp = bprpmesh[(0), :]
        u0spline = RectBivariateSpline(gmag, bprp, u0mesh, kx=1, ky=1, s=0)
        u0 = u0spline.ev(g_mag, bp_rp)
    else:
        print('Please call function as RUWE(g_mag = value, bp_rp = value)')
    return u0
