def _apply_relativistic_doppler_shift(scoord, velocity):
    '\n    Given a `SpectralQuantity` and a velocity, return a new `SpectralQuantity`\n    that is Doppler shifted by this amount.\n\n    Note that the Doppler shift applied is the full relativistic one, so\n    `SpectralQuantity` currently expressed in velocity and not using the\n    relativistic convention will temporarily be converted to use the\n    relativistic convention while the shift is applied.\n\n    Positive velocities are assumed to redshift the spectral quantity,\n    while negative velocities blueshift the spectral quantity.\n    '
    squantity = scoord.view(SpectralQuantity)
    beta = (velocity / c)
    doppler_factor = np.sqrt(((1 + beta) / (1 - beta)))
    if squantity.unit.is_equivalent(u.m):
        return (squantity * doppler_factor)
    elif (squantity.unit.is_equivalent(u.Hz) or squantity.unit.is_equivalent(u.eV) or squantity.unit.is_equivalent((1 / u.m))):
        return (squantity / doppler_factor)
    elif squantity.unit.is_equivalent(KMS):
        return (squantity.to(u.Hz) / doppler_factor).to(squantity.unit)
    else:
        raise RuntimeError(f'Unexpected units in velocity shift: {squantity.unit}. This should not happen, so please report this in the astropy issue tracker!')
Given a `SpectralQuantity` and a velocity, return a new `SpectralQuantity`
that is Doppler shifted by this amount.

Note that the Doppler shift applied is the full relativistic one, so
`SpectralQuantity` currently expressed in velocity and not using the
relativistic convention will temporarily be converted to use the
relativistic convention while the shift is applied.

Positive velocities are assumed to redshift the spectral quantity,
while negative velocities blueshift the spectral quantity.
def _apply_relativistic_doppler_shift(scoord, velocity):
    '\n    Given a `SpectralQuantity` and a velocity, return a new `SpectralQuantity`\n    that is Doppler shifted by this amount.\n\n    Note that the Doppler shift applied is the full relativistic one, so\n    `SpectralQuantity` currently expressed in velocity and not using the\n    relativistic convention will temporarily be converted to use the\n    relativistic convention while the shift is applied.\n\n    Positive velocities are assumed to redshift the spectral quantity,\n    while negative velocities blueshift the spectral quantity.\n    '
    squantity = scoord.view(SpectralQuantity)
    beta = (velocity / c)
    doppler_factor = np.sqrt(((1 + beta) / (1 - beta)))
    if squantity.unit.is_equivalent(u.m):
        return (squantity * doppler_factor)
    elif (squantity.unit.is_equivalent(u.Hz) or squantity.unit.is_equivalent(u.eV) or squantity.unit.is_equivalent((1 / u.m))):
        return (squantity / doppler_factor)
    elif squantity.unit.is_equivalent(KMS):
        return (squantity.to(u.Hz) / doppler_factor).to(squantity.unit)
    else:
        raise RuntimeError(f'Unexpected units in velocity shift: {squantity.unit}. This should not happen, so please report this in the astropy issue tracker!')