# 6.4.4 Full extraction

FullExtraction is the workflow of the spectroscopic pipeline where all corrections are applied and filtering of bad data takes place:

• Bias and bias non-uniformity is first removed using appropriate calibration coefficients (see Section 6.3.1).

• Saturated samples (65 535 ADU) are flagged. The spectra presenting a saturated sample are removed from the pipeline.

• The fixed, onground-measured CCD gain is applied.

• The onground-measured dark current is subtracted (see Section 6.3.2).

• The straylight background is removed by subtracting the flux from the cell in the RVS straylight map that corresponds to the processing window’s position, time and pixel sampling. The spectra with a total negative flux resulting from a too high background subtraction are removed from the pipeline, and so are the spectra for which the background was higher than 100 electrons pixel${}^{-1}$ s${}^{-1}$.

• Windows that contain any columns from the cosmetic defect list (see Section 6.3.2) are flagged and removed from the pipeline.

• 2D windows are optimally collapsed into 1D spectra, if there is a sufficient number of unsaturated pixels to model over the saturated ones. If there are too many saturated pixels, the window is flagged and later filtered from the pipeline.

• Cosmic rays are removed from both 2D and 1D windows. If pixels are saturated due to cosmic rays and the cosmic ray is successfully removed, the saturation flag is turned off and the window can proceed in the pipeline, otherwise it is removed from the pipeline.

• The trended wavelength coefficients are applied to the field angles and wavelength range cut to 846–870 nm to avoid the RVS filter wings.

• The internal $G_{\rm RVS}$ magnitude is estimated from the calibrated flux between 846 and 870 nm. This magnitude is not used in the processing downstream and it is not published. It is only used for validation (see Section 6.5.2).

• The onground-measured RVS filter response is removed.

• Normalise the spectra: the spectra are normalised to their pseudo-continuum using a $2^{\mathrm{nd}}$-degree polynomial fitting. The stellar lines are iteratively rejected using a sigma-clipping with interval $[-3,+10]\sigma$. For the faint stars and the very cool stars the polynomial was replaced by a constant equal to the 90th percentile of the fluxes.

The uncertainties with all these processes are propagated for each sample in each window/spectrum.

## Determine atmospheric parameters

The astrophysical parameters ($T_{\rm eff}$, $\log g$ and [Fe/H]) are needed in the further processing, to select the appropriate synthetic spectrum (Section 6.2.3) for each observed spectrum. A first approach is the use of the auxiliary data file (Section 6.2.3) that contains the effective temperature for some stars. However, if this information is lacking for a given source, the astrophysical parameters are determined from Pearson correlation with all of the templates generated (Section 6.4.7) from the restricted set of synthetic spectra in Section 6.2.3. The template that gives the highest correlation peak determines the parameters for that star.