def vel_space(lam, lam0):
    """
    Convert a maximum absorption wavelength to a velocity
    using the relativistic Doppler formula

    Args:
        lam: maximum absorption wavelength
        lam0: rest-frame absorption wavelength

    Returns:
        v: ejecta velocity
    """
    z = lam / lam0
    return 3e5 * (z ** 2 - 1) / (z ** 2 + 1)