def gaia_passbands_ext_calc(g, bprp, EBV, AV=None):
    """ Takes Gaia DR2 G, BP, RP apparent magnitude measurements and
    calculates the passband specific extinction using either a provided
    E(B-V) reddening value or an AV extinction value. Polynomial fit
    coefficients are from Babusieaux et. al. 2018
    
    Parameters
    ----------
        g : array, N
            Gaia DR2 G-band apparent magnitude measurements
        bp : array, N
            Gaia DR2 BP-band apparent magnitude measurements
        rp : array, N
            Gaia DR2 RP-band apparent magnitude measurements
        EBV : float
            Reddening value in the B-V Johnson-cousins passbands
        AV : float
            Johnson-cousins V-band extinction value (default=None)
    Returns
    -------
        A_G : array, N
            Gaia DR2 G-band extinction values
        A_BP : array, N
            Gaia DR2 BP-band extinction values
        A_RP : array, N
            Gaia DR2 RP-band extinction values
    """
    # k_x = A_x / A_0
    # A_0 = 3.1 * EBV

    kG = {'c1':0.9761, 'c2':-0.1704, 'c3':0.0086, 
            'c4':0.0011, 'c5':-0.0438, 'c6':0.0013, 'c7':0.0099}

    kBP = {'c1':1.1517, 'c2':-0.0871, 'c3':-0.0333, 
            'c4':0.0173, 'c5':-0.0230, 'c6':0.0006, 'c7':0.0043}

    kRP = {'c1':0.6104, 'c2':-0.0170, 'c3':-0.0026, 
            'c4':-0.0017, 'c5':-0.0078, 'c6':0.00005, 'c7':0.0006}

    if AV is None:
        A0 = 3.1 * EBV
    else:
        A0 = AV
    kGequ = kG['c1'] + kG['c2']*(bprp) + kG['c3']*(bprp)**2. \
            + kG['c4']*(bprp)**3. + kG['c5']*A0 + kG['c6']*A0**2. \
            + kG['c7']*(bprp)*A0
    A_G = kGequ * A0


    kBPequ = kBP['c1'] + kBP['c2']*(bprp) + kBP['c3']*(bprp)**2. \
            + kBP['c4']*(bprp)**3. + kBP['c5']*A0 + kBP['c6']*A0**2. \
            + kBP['c7']*(bprp)*A0
    A_BP = kBPequ * A0


    kRPequ = kRP['c1'] + kRP['c2']*(bprp) + kRP['c3']*(bprp)**2. \
            + kRP['c4']*(bprp)**3. + kRP['c5']*A0 + kRP['c6']*A0**2. \
            + kRP['c7']*(bprp)*A0
    A_RP = kRPequ * A0

    return (A_G, A_BP, A_RP)