The radial velocity (RV) determination for APOGEE spectra has been rewritten for DR17. This was motivated by the availability of a new code, Doppler (Nidever et al. 2021, github/dnidever/doppler, doi:10.5281/zenodo.4906680) for RV determination that uses a model to provide a continuous set of template spectra for a simultaneous template+RV fit, as well as an effort to improve radial velocities for faint stars. These are described below.

See the Using APOGEE Radial Velocities page for information on how best to use these quantities.

The Doppler code uses a "Cannon" model (Ness et al. 2015 and Casey et al. 2016) that allows one to quickly generate a template spectrum for arbitrary choices of effective temperature, surface gravity, and metallicity. This model is trained on a set of synthetic spectra generated using the Synspec spectral synthesis code (Hubeny et al. 2011) with Kurucz model atmospheres.

The Doppler code first resamples the observed visit spectra and cross correlates each visit spectrum against a small set of templates that span a range of stellar parameters. The cross correlation that yields the highest peak gives a set of starting guesses for the stellar parameters of the object and for individual visit radial velocities. These are passed to a non-linear least squares routine that then simultaneously solves for a set of stellar parameters (Teff, log g, [Fe/H]) and individual radial velocities. This fit is done on the "raw" (i.e., not resampled) visit spectra, and all spectra are fit simultaneously; the pipeline LSF characterization is used by the routine to convolve the model spectra so that they can be directly compared with the data.

After the best fit values are found, a template is generated and cross-correlated against resampled individual visit spectra. The resulting cross-correlation functions are saved in the apStar files (see below). While these are not used to provide radial velocities, the agreement between this cross-correlation RV and the best-fit RV are used as a diagnostic to flag suspicious or bad radial velocities. The cross-correlation functions can also be used to identify potential spectroscopic binaries.

## Faint stars

For faint stars, this procedure can often fail, finding significantly discrepant radial velocities. To improve the success for these, a procedure has been developed in which an initial combined spectrum is made under the assumption of no radial velocity variations, i.e., the spectra are combined after shifting to the barycentric frame with no additional velocity shifts. This spectrum is then run through Doppler to provide an estimate of a systemic velocity. The full set of individual spectra are then passed to Doppler for the normal procedure, but the fits are constrained so that only velocities within 50 km/s of the initial systemic estimate are allowed. This generally provides significantly improved radial velocities, as confirmed, in particular, by assessing the radial velocities of stars in nearby dwarf galaxies.

## Reference frame for radial velocities

Radial velocities in APOGEE are reported with respect to the center of mass of the Solar System - the barycenter. The individual exposures are corrected for the relative motion of the Earth along the line of sight to the star during each observation. This correction is called the "barycentric correction," and it can be calculated very accurately (to m/s levels). When these corrections are applied to the absolute RVs, we determine the RV with respect to the barycenter or Vhelio for short.

Note: The terminology and header keyword VHELIO is retained for historical reasons, but the pipeline is calculating a true barycentric velocity, not a heliocentric velocity.

## Spectroscopic Binary Identification

The cross-correlation functions can provide information about potential spectroscopic binaries, as such stars can yield double-peaked cross correlation functions if they are observed when the two stars have measurably different radial velocities. Following the work of Kounkel et al. (2021), we attempt to recognize these using autonomous Gaussian decomposition of the cross-correlation function. Our main goal is to identify the most-likely spectroscopic binaries, as these are the ones for which the stellar parameter and abundance determinations are likely to be most suspect, since we analyze spectra under the assumption that they can be modeled with the spectrum of a single star. We flag suspect systems with the MULTIPLE_SUSPECT bit in the STARFLAG bitmask (which is also propagated into the ASPCAPFLAG bitmask); for a combined spectrum, if any of the individual visits have MULTIPLE_SUSPECT, then the combined spectrum has this bit set. Note that this determination is neither complete nor perfect: there may be spectroscopic binaries for which the flag is set, and there may be spectra for which the bit is set that are not spectroscopic binaries, although we have tuned things so that we expect more of the former (false negatives) than the latter (false positives).

For significantly enhanced detection and characterization of spectroscopic multiples that includes visual inspection, identification of individual components, and attempts to fit orbits, see this value added catalog (Kounkel et al. 2021)

The RV uncertainty depends on the S/N, the resolution, and the information in the spectral lines themselves. A spectrum with many deep and narrow lines (such as in cool and metal-rich stars) will have a more precise RV than a spectrum with a few shallow and broad lines (such as in hot stars). The RV uncertainty in the APOGEE spectra can be estimated by looking at the RV scatter for stars with multiple visits. The histogram of the RV scatter peaks at ~70 m/s (much smaller than our original survey target of 500 m/s), but it has a long tail at larger scatter. Much of this is due to real variability from stellar binaries. The observed scatter is stored in the VSCATTER parameter for each star, and it is probably the best indicator to use to determine whether a star is a binary (for stars with multiple visits). If VSCATTER > 1 km/s (i.e., much larger than the typical uncertainties), then it is likely a binary. Note, however, that for stars with a single visit, VSCATTER will be set to zero. The number of visits is stored in the  NVISITS column.

## Data quality flags

Some information about the quality of the radial velocities is available in some bits in the STARFLAG bitmask and in the (new) RV_FLAG bitmask .

In particular, visits with RV_REJECT set are those for which RVs were not determined. This is triggered either by very low S/N (we do not attempt to determine RVs for S/N<3), for objects for which the derived RV from the spectral fit deviates significantly from that inferred from the cross-correlation function with the best fitting template, or for objects for which the RV fit failed. Stars with RV_SUSPECT have radial velocities, but these have differences between the fit and cross-correlation RVs of up to 10 km/s (50 km/s for stars with Teff > 6000 K).

The barycentric radial velocities u is stored in VHELIO for each visit spectrum; an estimated error is stored in VERR.
For the combined spectrum, a signal-to-noise weighted average is stored in VHELIO_AVG and the scatter around this average is stored in VSCATTER. The S/N weighted pipeline-reported uncertainty is stored in VERR. We note, however, that VERR tends to be small and that VSCATTER may represent a better estimate of the true measurement precision.