def get_distance(m, M, Av=0):
    """
    calculate distance [in pc] from extinction-corrected magnitude
    using the equation: d=10**((m-M+5-Av)/5)

    Note: m-M=5*log10(d)-5+Av
    see http://astronomy.swin.edu.au/cosmos/I/Interstellar+Reddening

    Parameters
    ---------
    m : apparent magnitude
    M : absolute magnitude
    Av : extinction (in V band)
    """
    assert (m is not None) & (str(m) != "nan")
    assert (M is not None) & (str(M) != "nan")
    distance = 10 ** (0.2 * (m - M + 5 - Av))
    return distance