WorksPhysics and Astronomy
Redrock: Spectroscopic Classification and Redshift Fitting for the Dark Energy Spectroscopic Instrument
Abstract
Redrock is a software package for spectroscopic classification and redshift fitting, designed to use the full information from spectroperfectionism outputs: flux-calibrated spectra, uncorrelated errors, and a per-spectrum resolution matrix encoding the non-Gaussian wavelength-dependent spectral line-spread function. Redrock was originally developed for the Dark Energy Spectroscopic Instrument (DESI), but the Extended Baryon Oscillation Spectroscopic Survey (eBOSS) also used Redrock as their primary galaxy redshift fitter prior to DESI. This paper presents the algorithmic details of Redrock and its performance on DESI data. On spectra from DESI DR2, Redrock achieves a redshift recovery rate of approximately 98% for the Bright Galaxy Survey (BGS) and Luminous Red Galaxies (LRG), 95.9% for Emission Line Galaxies (ELG), and 92.6% for quasars (QSO), and it delivers unbiased stellar radial velocities with a precision of roughly 5 km/s.
Introduction
Introduction
The Dark Energy Spectroscopic Instrument (DESI; [28, 30, 66, 78]) is a spectroscopic redshift survey designed to observe ∼60 million galaxies and quasars over 17,000 deg with an 8-year observing program (E. F. Schlafly et al. [82]). In addition to the sky-subtracted flux-calibrated spectra, a key output of DESI is the spectral classification (galaxy, quasar, star) and redshift of each observed object, included with the public data releases (DESI Collaboration et al. [31, 33]). Redrock is a spectral classification and redshift fitting code designed for the needs of DESI, while at the same time being open-source and generic enough to be applicable to other spectroscopic surveys such as the Sloan Digital Sky Survey (SDSS).
The algorithmic method in Redrock is similar to that used by SDSS (A. S. Bolton et al. [15]): selecting the minimum from Principal Component Analysis (PCA) template fits over a range of redshifts and template spectral types. It improves upon that method through updated templates, more rigorous error propagation, the use of wavelength-dependent non-Gaussian per-spectrum resolution modeling, and optional spectral archetype fits to avoid unphysical solutions (A. Anand et al. [8]). The improvements in Redrock were significant enough that the SDSS-IV Extended Baryon Oscillation Spectroscopic Survey (eBOSS) switched to using Redrock for the final cosmology analyses instead of the original SDSS code (A. J. Ross et al. [80]).
Other previous methods for automated spectroscopic classification and redshift measurement include template Fourier cross-correlation (J. Tonry & M. Davis [86]), explicitly matching observed spectral peaks to sets of known emission lines (WiggleZ; M. J. Drinkwater et al. [35]), template fitting after subtracting a median-filtered spectrum (DEEP2; J. A. Newman et al. [73]), and fitting flux-calibrated spectra to a library of archetype basis templates (PRIMUS; R. J. Cool et al. [25]). Redrock also uses flux-calibrated spectra — including the continuum — and fits templates across all observed wavelengths simultaneously without explicitly searching for and fitting individual emission or absorption features. This approach enables Redrock to use the full information available in the data. Since the PCA templates are derived from complete spectra, they implicitly encode correlations between line strengths, relative velocity offsets (for the quasar templates), and other line properties in addition to the relationship between these features and the underlying continuum shape. In principle, this offers an advantage over methods that rely on identification of individual features or groups of features: many low signal-to-noise emission and/or absorption lines can collectively contribute to achieving a secure classification and emission line confusion is discouraged. However, this approach is limited by the adequacy of the PCA templates, and reliant upon upstream
processing to provide high-quality sky-subtracted flux-calibrated spectra with well-characterized errors as input.
Redrock comes with a set of templates for fitting stars, quasars (QSOs), and galaxies. The default templates are tuned to the primary populations targeted by DESI. For example, the default galaxy templates are derived from simulated spectra of nearby bright galaxies (BGS; C. Hahn et al. [42]), old metal-rich luminous red galaxies (LRG; R. Zhou et al. [94]), and active star-forming emission line galaxies (ELG; A. Raichoor et al. [79]) while the quasar templates are designed to span the spectral diversity observed over the full targeted redshift range () for cosmology (E. Chaussidon et al. [22]). At the same time, the templates are kept separate from the code, enabling future projects to develop their own custom templates that match their target populations (e.g., V. Ruhlmann-Kleider et al. [81]).
This paper is organized as follows. § 3 provides an overview of the Redrock algorithmic method. § 4 describes the underlying galaxy, QSO, and stellar templates, with further details in Appendix § 11. § 5 lists the performance of Redrock on DESI data. Known issues are described in § 6. §§§ 7, § 8, § 9 discuss the computational performance, output files, and Redrock code, respectively. We conclude in § 10.
Overview of Method
Redrock determines spectral classes and redshifts of astronomical spectra by fitting Principal Component Analysis (PCA) templates to the data. Each template set models a particular spectral class — galaxy, quasar, or star — and is fit over a range of redshifts to form a vs. scan. The minimum from these scans is selected as the best-fit spectral classification and redshift. In addition to their overall classification, templates can optionally have a subtype, e.g., Redrock has multiple template sets for different stellar subtypes; see § 4.1.3. The core Redrock algorithms are independent of the specific templates and redshift ranges used. § 4 describes the default DESI-centric templates provided with Redrock, but other users can develop (and have developed) their own templates to use with Redrock for other cases.
Redrock is designed to make full use of the spectral outputs of the “spectroperfectionism” algorithm described in A. S. Bolton & D. J. Schlegel [14] — flux-calibrated spectra with an error model that is by construction uncorrelated across wavelength bins, and a resolution matrix per spectrum encoding the full non-Gaussian wavelength-dependent spectral line-spread function. In order to preserve the fidelity of the input data error model, including its lack of covariance between wavelength bins, Redrock always transforms the templates to match the data (redshifting, wavelength resampling, resolution convolving), rather than transforming the data to match the templates.
Redrock fits flux-calibrated spectra but does not incorporate separate imaging-based photometric fluxes or colors as part of the fit. Although the PCA templates provide some flexibility to absorb flux-miscalibration, the templates themselves were constructed from flux-calibrated models and data without explicitly introducing broadband mis-calibration terms into the templates. Early algorithmic comparison testing indicated that Redrock outperformed methods that first removed broadband spectral information, implying that the use of imperfectly calibrated data was better than completely removing calibration effects. However, this improvement has not been quantified on current DESI data. It should also be noted that galactic extinction is not incorporated into Redrock fits.
DESI runs Redrock on spectra that are pre-coadded across exposures following the algorithm described in J. Guy et al. [41] §4.11, which includes the effective resolution matrix of the resulting coadded spectra. An equivalent algorithm is implemented independently within Redrock and is used if the inputs are provided as uncoadded spectra; since it does not import the DESI pipeline code, it is not guaranteed to reproduce the DESI pipeline coadds exactly. Redrock can simultaneously fit multiple spectra for the same object, but it will coadd them only if they are already on identical wavelength grids. For example, DESI coadds across exposures but not across spectrograph arms, such that each target has 3 spectra for the 3 DESI spectrograph arms B (3600–5930 Å), R (5600–7720 Å), and Z (7470–9800 Å). Redrock naturally handles the camera overlap regions since the measurements in each arm are independent. Redrock performs a simultaneous fit to all 3 spectra per object to determine a single best-fit classification and redshift. Since the DESI spectra are in the barycentric frame, so are the resulting redshift estimates from Redrock.
The templates are assumed to be noise-free and fully span the wavelength range of the data for any possible redshift solution. To perform the redshift scan, Redrock multiplies the wavelength grid of the templates by then resamples to the binning of the data using trapezoidal integration over each wavelength bin. It then multiplies the templates by the wavelength-dependent resolution matrix , provided by the spectropectifionism extractions (see §4.5 of J. Guy et al. [41]). The redshifted and resampled templates , convolved with the resolution matrix , are then fit to the spectral flux with uncertainties to obtain the PCA coefficients and best fit .
The initial vs. scan uses the redshift ranges and step sizes given in Table 1 for each template set. 70 For each template set, the lowest 3 minima are rescanned using 15 finer redshift steps spanning coarse redshift step around the original minimum. These are refined in order from lowest local minimum to highest; if a new minimum is within 1000 km s of a previously fit minimum (or 100 km s for stellar fits), it is considered part of the same redshift solution and skipped, so that the lower- minimum is always the one retained.
| Template | range (Å) | step | ||
| STAR | 3000 − 11000 | −0.002 | 0.002 | |
| GALAXY | 1228 − 11000 | −0.005 | 1.7 | |
| QSO | 450 − 10399 | 0.05 | 6.0 | |
| QSO-LOZ | 1329 − 9632 | 0.05 | 1.6 | |
| QSO-HIZ | 444 − 4498 | 1.4 | 7.0 |
Table 1. Rest-frame wavelength coverage, redshift ranges, and redshift step sizes used by each Redrock template type. The DESI Early Data Release (EDR) used a single QSO template set spanning redshifts ; Data Release 1 (DR1) and the forthcoming DR2 use two sets of QSO templates spanning and .
A parabola is fit to the 3 points around the minimum of the new finer vs. scan. The parabolic fit minimum defines the redshift and for this candidate classification/redshift, and the change in redshift for a is used as the estimate of the statistical redshift error. This is shown schematically in Figure 1 for fitting 3 minima while excluding a 4th minimum that is too close in redshift to an already better minimum. Figure 2 shows the coarse redshift scan, refined redshift scan, and parabola fit to the minimum for a DESI QSO target at . The redshift step size and number of points included in the final fit were selected to balance algorithmic performance, robustness to fit failures, and computational cost.
Figure 1. Schematic diagram of vs. scan and minimum selection.

Figure 2. Example vs. scan for a QSO. The upper plot shows vs. for the coarse redshift scan for GALAXY and QSO templates; the lower plot shows a zoom in of the finer redshift scan around the minimum and the final parabolic fit to the 3 points about the minimum.
After determining the fits to the best 3 minima of each template set, these are then compared to select the best overall redshift. Failed minima fits are excluded, and the lowest of the remaining fits is chosen. A fit is considered failed if its minimum is outside the range of points being fit, the parabola has zero or negative curvature, the vs. parabola minimum is negative, or the linear algebra fitting routine (numpy.polyfit) raises an exception (a defensive check, e.g., for non-finite values when no valid data remain). In the case where the minimum is at an endpoint (e.g., for galaxies), the refined scan spans only the single coarse step on the interior side, since templates are never evaluated outside their configured redshift range. If is still decreasing toward the boundary, the parabola minimum falls outside the fitted points and the candidate is considered a failed fit and excluded.
Although different template sets may have different numbers of coefficients (as is the case for the default DESI template set), Redrock compares the total , not the reduced , when selecting the best overall redshift. While this slightly biases the solution towards templates with more eigenspectra, this convention was used for all DESI data productions to date. In § 6 we show that ranking by reduced instead would have a negligible effect on the redshifts of confidently classified spectra. In addition to the single best overall classification/redshift, Redrock also saves the original vs.
scan for each template, and the refined scans and fits of the best 3 fits per classification (galaxy, QSO, or star). For example, although there are 8 different stellar templates, only the best 3 across all stellar templates are kept, even if the 4th best stellar fit is better than the best galaxy fit.
Figure 3 shows Redrock fits to the 3 primary DESI target types observed during dark time: an LRG, ELG, and QSO. Redrock does not distinguish between galaxy subtypes, and thus fits both the LRG and the ELG with the same galaxy PCA templates even though they have dramatically different continuum vs. emission line properties. While the Redrock fits (dark lines) are to the unsmoothed data, the data in the figure (light lines) have a 2.4 Å (3 wavelength bin) Gaussian smoothing for visual clarity. Inset plots illustrate the ability of the templates to accurately model distinct galaxy features, such as the Ca H&K absorption lines for the LRG, and the [O II] λλ3726, 29 doublet for the ELG.
Figure 3. Example Redrock fits to an LRG (top, with inset for Ca H&K), an ELG (middle, with inset plot for [OII]), and a QSO (bottom). The targets plotted are TARGETIDs 39633118721739723 (LRG), 39633123197060417 (ELG), and 39633123192868556 (QSO) from tile 325 of the Iron (DR1) data production. The data are shown in cyan with a 2.4 Å Gaussian smoothing for visual clarity, with the best-fit template overlaid in black. The inset plots do not smooth the data.
During early Redrock development using simulated DESI data, a significant cause of incorrect redshifts was unphysical negative [O II] fits with the galaxy templates caused by noise fluctuations. This failure case was mitigated by penalizing the for galaxy template fits if the [O II] model flux integrated over rest-frame wavelengths Å is negative. The penalty term is simply the absolute value of the integrated flux in units of . There is no particular mathematical justification for this choice; it pragmatically worked and development moved on. Internal DESI studies indicate that sub-percent improvements to ELG purity could be achieved by making this more rigorous through accounting for the measured noise, also fitting for the continuum, and making the penalty vary with the square of the significance instead of an unweighted linear penalty. These possible changes have not been implemented in Redrock production code, however, and the ad hoc linear penalty for negative [O II] remains.
Default Templates
Accurate spectroscopic redshifts require high-quality spectrophotometric templates which faithfully represent the spectral diversity spanned by galaxies and QSOs over cosmic time. In this section we describe the procedure used to develop the default galaxy, QSO, and stellar templates used by DESI, available at https://github.com/desihub/redrock-templates. Other projects could develop alternate templates for additional target types such as Lyman- Emitter (LAE) galaxies.
Principal Component Analysis Templates
Because Redrock always transforms the templates to match the data (see § 3), the templates should ideally be defined at higher spectral resolution than the data. As outlined in the following subsections, the galaxy and most of the stellar templates satisfy this requirement with a resolution more than twice the maximum resolution of the DESI spectrographs and a rest-frame wavelength grid of 0.1 Å. The quasar templates and the cataclysmic variable template are exceptions. They are empirically derived from SDSS/BOSS data (–2500), and thus include the instrumental broadening of those spectra. Redrock nonetheless convolves them with the DESI resolution matrix like any other template. For the broad emission lines that dominate quasar redshift fits (FWHM of thousands of km s), the additional broadening is negligible, but narrow features in the quasar templates are modeled at somewhat lower resolution than the DESI data. This is discussed further in § 6.
Galaxy templates
To construct the galaxy PCA templates, we start from physically motivated galaxy spectral models. We use these models to generate a large number of synthetic galaxy spectra whose properties are matched to the observed DESI galaxy populations, and then perform PCA on this set to derive a compact set of eigenspectra spanning the range of galaxy spectra observed by DESI.
The synthetic spectra are built from the set of basis templates described in Appendix § 11, which span a wide range of stellar-continuum and emission-line properties. Specifically, we generate 10,000 random realizations of ELGs, 5,000 LRGs, and 5,000 galaxies matching the DESI BGS sample. These were generated for rest-frame wavelengths 1,228–11,000 Å on a linear 0.1 Å grid. Each spectrum was normalized to have median(flux) = 1 before performing PCA so that the eigenvector variation would capture differences between the spectra and not just normalization variations. The mean flux was not subtracted prior to PCA, such that the 0th component represents the approximate mean spectrum as an output of PCA. Due to the large size of the input matrix (20k by 97.7k), the PCA solution was determined iteratively using the EMPCA algorithm2 described in S. Bailey [12].
The final galaxy templates use the top 10 PCA eigenvectors as shown in Figure 4. The number of eigenvector templates was selected to balance code runtime with algorithmic performance on eBOSS and pre-DESI simulated data, but it was not optimized in detail. The code used to generate the galaxy PCA templates is in the bin/rgaltemplate script at https://github.com/desihub/redrock.
Figure 4. Galaxy eigenspectra used by Redrock, scaled for clarity. The [O II] inset illustrates how the different eigenspectra capture variation in emission line profile.
Quasar templates
Quasar spectra exhibit extreme diversity in their emission and absorption properties. As such, Redrock relies on empirically derived templates (unlike with galaxies and stars) to maximize the information content of the spectral models.
The original version of Redrock used the same QSO templates as SDSS. A. S. Bolton et al. [15] documents the details of their construction.3 These include 4 eigenvectors on a logarithmic restframe wavelength grid from Å to Å. The Lyman-series forest is present at in the spectra of high redshift objects, leading to an overall redshift-dependent suppression of flux blueward of this wavelength (e.g., M. McQuinn [65]). The expected flux deficit at the redshift being fit is accounted for by applying a wavelength-dependent correction to the templates at following the model of F. Calura et al. [20].4 This version of the QSO templates was used for the DESI spectroscopic pipeline included in its Early Data Release (EDR; DESI Collaboration et al. [31]).
After the EDR dataset was internally frozen and released to the DESI collaboration, a new set of QSO templates was developed by A. Brodzeller et al. [17]. Their §4.1 describes the improved spectral diversity coverage of these templates relative to the EDR version, particularly for systems with dust-reddened continua or those exhibiting strong absorption. These used a much larger set of input SDSS DR16 quasars (B. W. Lyke et al. [62]), updated the Lyman-series optical depth model (V. Kamble et al. [48]), and split the sample into separate low-redshift (LOZ, ) and high-redshift (HIZ, ) templates, shown in Figure 5. Algorithmically, the LOZ and HIZ template sets are treated as QSO subtypes; every target is fit with both LOZ and HIZ QSO templates over their individual redshift ranges (see Table 1), and the lowest 3 QSO fits across either template set are kept for comparison with other templates. If the true redshift lies within the overlap range of the templates , typically both templates will have a minimum at the same redshift and the one with the lower is selected. QSOs with a true redshift just under the boundary of typically have a good QSO-LOZ minimum fit, but the QSO-HIZ fit may extrapolate beyond its redshift range and result in an unreliable extrapolated minimum. This is flagged as a bad QSO-HIZ fit and discarded and the QSO-LOZ is kept instead. A similar effect occurs in reverse for targets just above the boundary. These cases require no QSO-specific code: an extrapolated minimum outside a template’s redshift range fails the minimum-fit criteria described in § 3 and is discarded by the generic ranking of fits across templates. This also makes it possible for future galaxy templates to be customized for different redshift ranges.
Figure 5. QSO eigenspectra used by Redrock for Data Release 2. The eigenspectra fluxes are scaled for clarity.
Stellar templates
The stellar templates for Redrock were derived from the main-sequence stellar models from C. Allende Prieto et al. [7]. These high-resolution () models span a wide range of stellar effective temperature (), surface gravity (), and iron abundance ([Fe/H]). The basic parameters of the stellar models used are detailed in Table 2.
| Parameter | Value Range |
| K | |
| cm s | |
| [Fe/H] | |
| Wavelength grid | Å |
Table 2. Parameters for theoretical stellar models.
The stellar template training sample consisted of 10,000 random realizations from these models generated on a linear 0.1 Å wavelength grid from 3000 Å to 11000 Å. Due to the significant spectral variation of stars with , a single set of PCA eigenvectors was not sufficient for accurate classification — a small number of PCA eigenvectors were unable to capture the variation found in stars, while a large number of PCA eigenvectors enabled too much flexibility for unphysical fits and was additionally computationally prohibitive to use. To accommodate the underlying stellar diversity, the training sample was split by effective temperature into separate samples to generate PCA eigenvectors roughly corresponding to the physical stellar subtypes listed in Table 3. Input spectra with on the boundary between subtypes were used by both samples, thus the sum of the individual sample sizes exceeds the original 10,000 generated. The top 5 eigenvectors were kept for each stellar subtype.
| Subtype | min | max | sample size |
| B | 10,000 | 30,000 | 2,182 |
| A | 7,000 | 10,000 | 1,466 |
| F | 6,000 | 7,500 | 1,705 |
| G | 5,200 | 6,000 | 955 |
| K | 3,700 | 5,200 | 1,437 |
| M | 3,500 | 3,700 | 3,432 |
Table 3. Effective temperature ranges and sample size used for each Redrock stellar template subtype.
A separate white dwarf PCA template set was generated using 10,000 DA and 10,000 DB subtype models (D. Koester [52]) on the same wavelength grid as the other stellar spectra, also keeping the top 5 eigen-spectra. Finally, a 3-component cataclysmic variable (CV) stellar template was constructed by reformatting the spEigenCVstar-55734.fits model from the SDSS/BOSS idlspec2d code (A. S. Bolton et al. [15]).
Although Redrock splits stellar templates by subtype, this is intended primarily as an algorithmic method to accommodate broad spectral diversity while limiting the phase space of possible template fits. The Redrock stellar subtypes were not designed for a rigorous stellar classification. Compared to the more detailed fits in S. Koposov et al. [53], Redrock’s best fit stellar template matches only of the time, though the neighboring template (higher- or lower-temperature range) is typically the selected one when they don’t match.
Redrock stellar template eigenspectra are shown in Figure 6. The code used to generate the stellar PCA templates is in the bin/rrstartemplate script at https://github.com/desihub/redrock.
Figure 6. Redrock eigenspectra for the eight stellar subtype templates. Flux is in arbitrary units.
Archetypes
Similar to PRIMUS (R. J. Cool et al. [25]), eBOSS used archetype templates both with the redmonster software package (T. A. Hutchinson et al. [46]) and with Redrock. The archetypes in Redrock improved purity by avoiding unphysical solutions (A. J. Ross et al. [80]); these are available in a separate repository https://github.com/desihub/redrock-archetypes tag 0.1. The eBOSS-optimized archetypes did not work well for DESI, which observed a broader diversity of galaxy targets, so new galaxy archetypes were developed for DESI with details described in A. Anand et al. [8]. These are available as tag v1.0.074, though these have not yet been used in an official production run scheduled for public release.
Here, we provide a brief summary of the method. In the archetype-based approach, galaxy spectra are modeled using a set of physically motivated spectral templates, known as archetypes. These archetypes represent realistic galaxy spectral energy distributions (SEDs) and effectively capture physical features such as emission and absorption lines observed in the data. These archetypes are stored separately from the core pipeline, allowing them to be independently developed and updated.
To prevent unphysical solutions, the linear coefficients associated with these archetypes are constrained to be strictly positive using a Bounded-Value Least Squares (BVLS, P. B. Stark & R. L. Parker [84]) method. This constraint eliminates non-physical modeling artifacts, such as inverted emission or negative absorption features. Additionally, in archetype mode, we incorporate Legendre polynomials per camera to flexibly model and absorb spectrophotometric calibration issues (see J. Guy et al. [41]; A. Anand et al. [8], for details). These include additive offsets arising from CCD amplifier bias mismatches at camera boundaries and chromatic distortions due to fiber positioning and focal plane throughput variations. While PCA templates have the flexibility to partially absorb these effects, archetypes do not, since they are constrained to be physically meaningful, thus additional polynomial terms are helpful to absorb the unphysical effects. The Redrock fitting algorithm allows users to define a prior on the contribution from the Legendre polynomial terms. This ensures that the polynomial correction primarily addresses CCD calibration issues and prevents the polynomials from mistakenly modeling intrinsic spectral features, such as the quasar power-law continuum, or calibration issues. For further details, see A. Anand et al. [8].
By combining physical archetypes with per-camera polynomial corrections, this approach produces redshift fits that are more physically realistic, while preserving the speed and robustness of the pipeline on DESI spectra. In the pipeline, the archetype-based method can be invoked by passing the archetypes using the --archetypes option to redrock.external.desi.rrdesi.
Another algorithmic feature that Redrock supports in archetype mode is the ability to combine multiple nearby archetypes (along with Legendre polynomial terms), rather than relying solely on the single best-fit archetype when fitting for the redshift. This approach effectively performs a “sub-grid” interpolation by taking the best-fitting archetype and combining it with its nearest neighbors in space. As detailed in A. Anand et al. [8], this method provides slightly improved values for some spectra due to the increased flexibility from a larger number of fitting coefficients. However, it also introduces significantly higher computational cost—approximately three times slower—because of the expanded template set and greater degrees of freedom. This mode can be enabled by passing the --n-nearest NUMBER option to redrock.external.desi.rrdesi. The archetype mode was extensively tested on a large volume of DESI spectral data, and its performance is described in detail in A. Anand et al. [8]. While Redrock performs slightly better in archetype mode, this improvement comes at the cost of longer runtime.
Algorithmic Performance on DESI Data
Redrock’s performance on the DESI extragalactic data set was validated as a part of DESI’s Survey Validation phase (SV; [32]). T.-W. Lan et al. [59] presents the results of the validation study on the galaxy (BGS, LRG, and ELG) sample, while D. M. Alexander et al. [6] reports analogous results for the QSO sample. As part of this validation process, more than 15,000 DESI spectra were visually inspected (VI) to construct high-fidelity truth catalogs.6 These truth catalogs informed the definitions of the large-scale structure catalogs used for DESI’s key cosmological analyses (A. G. Adame et al. 2025a,b; M. Abdul Karim et al. 2025a). We compare these VI truth catalogs to the Redrock results on data from the Loa production for the upcoming DESI DR2 and repeat a similar validation analysis here. Throughout this section, true redshifts, spectral types, and quality flags are taken from the VI_Z, VI_SPECTYPE, and VI_QUALITY columns of the VI catalogs.
The targets in the VI catalogs each received multiple exposures, up to ten times the nominal depth, which were coadded to create high S/N spectra for robust VI. The nominal depth for objects observed by DESI is 240 seconds for bright-time targets (BGS and most stellar targets) and 1000 seconds for dark-time targets (LRG, ELG, QSO). We exclusively use the Redrock results on spectra coadded to nominal depth to estimate the typical performance expected for the main survey. Classifications with non-zero ZWARN attributes (see § 8) are excluded, excepting the SMALL_DELTA_CHI2 bit triggered by the first and second best solutions having . We further exclude SPECTYPE=GALAXY with redshift estimates . Beyond this, the [O II] emission feature redshifts outside of DESI wavelength coverage, and therefore reliable galaxy classifications are not expected (e.g., [94, 79]). Finally, a high-quality VI classification is required, defined as VI_QUALITY > 2.5.
We first measure redshift recovery rate, sample completeness, and sample purity for each of DESI’s extragalactic target classes. Redshift recovery rate is defined as
where IS_OBJ is either true galaxy type or true quasar type and
For galaxies, it measures the percentage of true galaxies that receive Redrock redshift estimates with (equivalent to ). For quasars, the redshift recovery rate uses (). The relaxed criterion relative to galaxies accommodates redshift uncertainty introduced by broad emission lines (e.g., [44]).
Sample completeness , on the other hand, additionally requires a correct SPECTYPE assignment from Redrock.
The sample completeness is always lower than the redshift recovery rate, due in part to the ambiguity introduced by AGN activity. This is discussed more in § 6.
Finally, sample purity measures the percent of SPECTYPE=GALAXY classifications that are true galaxies with , and similarly for SPECTYPE=QSO with .
The results are summarized in Table 4.
| Target Class | Redshift Recovery Rate | Sample Completeness | Sample Purity | LSS Redshift Purity |
| BGS | 98.2% | 98.0% | 96.9% | > 99.9% |
| LRG | 97.9% | 97.4% | 97.3% | 99.6% |
| ELG | 95.9% | 95.9% | 94.7% | > 99.6% |
| QSO | 92.6% | 86.3% | 98% | 99% |
Table 4. The redshift recovery rate, completeness, and purity achieved by Redrock for the primary extragalactic target classes in DESI. These metrics are measured for classifications with ZWARN = [0, 4]. Restricting to ZWARN = 0 results in slightly lower (∼1-3%) redshift recovery rates and completeness, but can improve purity (notably for ELGs). The values in the LSS Redshift Purity column are those reported by T.-W. Lan et al. [59] and D. M. Alexander et al. [6]. The LSS samples use additional quality cuts to maximize success in the redshift ranges used for cosmological analyses.
Figure 7 illustrates the dependence of purity and completeness on the DELTACHI2 parameter. As illustrated in the figure, is an adequate threshold to generically indicate lower confidence classifications. This parameter, however, can be tuned for specific use cases as is done with the DESI large-scale structure catalogs (LSS; [4]). The LSS catalogs use optimized selection cuts for each target class to meet the scientific requirements for DESI ([1]). For example, the BGS sample uses a and requires ([42]) while the LRG sample is defined by and ([94]). The ELG and QSO target classes were more difficult to optimize owing to the nature of the sources, requiring additional classifiers to construct the

Figure 7. The dependence of sample purity and completeness on , the difference in between the first and second best Redrock solution, for each target class. The vertical dashed line at indicates the threshold to trigger the SMALL_DELTA_CHI2 ZWARN bit.
LSS catalogs (see [79, 22], for complete details on these classifiers). The DESI LSS redshift purity rates are included in Table 4 for comparison to the Redrock baseline.
The random error on Redrock redshift estimates is determined by comparing the results for the same object in multiple exposures. The velocity offset between redshift pairs is calculated as
We then use the normalized median absolute deviation (NMAD) of this distribution as an estimator for random redshift error, defined as:
This statistic is chosen over the standard deviation because it is more robust against catastrophic failures. The velocity offset distribution for each DESI target class is shown in Figure 8, with the corresponding NMAD values annotated. ELG targets are expected to have the lowest random redshift error (8.6 km s) due to their sharp emission lines, while QSOs have the largest random errors (62.7 km s) due to their broad lines. All target classes exhibit non-Gaussian tails in their repeat-observation distributions.

Figure 8. Random redshift error measured from the distribution of redshift-pair offsets for each DESI extragalactic target class.
We next use the redshift pairs to estimate the accuracy of Redrock’s ZERR parameter. If ZERR is an accurate representation of redshift uncertainty, then the distribution of will resemble a Gaussian with . Figure 9 shows these distributions for the four DESI extragalactic target classes. A Gaussian is fit to each of these distributions, and the standard deviation is annotated. The LRG and quasar samples exhibit significant tails, so we additionally fit them with a Lorentzian distribution and report the best-fit half-width at half-maximum, scaled to represent the standard deviation. The Lorentzian tails for the LRGs and QSOs are driven by pairs that both have median SNR less than 1.5, indicating the error model is less reliable in this regime.

Figure 9. Accuracy of the estimated redshift error ZERR from Redrock for DESI’s four primary extragalactic target classes. The solid lines represent the best-fitting Gaussian functions. The dotted lines represent the best-fitting Lorentzian functions, if applicable to the given distribution.
We conclude that ZERR accurately reflects redshift uncertainty for the quasar population; however, it is under-estimated for BGS by ∼70%, and for ELGs by ∼10%. Restricting to pairs with SNR > 1.5, we find ZERR for LRGs is underestimated as well by about 65%. For comparison, BOSS underestimated galaxy errors by 20–30% and QSOs by a factor of 2 ([15]).
Finally, we use the Milky Way Survey (MWS) catalog produced by the RVSpecFit7 (RVS) software ([54] (T. S. Li et al. 2019)) to check performance on stellar spectra. In short, RVS is run on the subset of spectra in the Loa production that are suspected stellar candidates (i.e., objects with MWS targeting bits or SPECTYPE=STAR from Redrock). The output catalog contains maximum likelihood estimates of various stellar parameters, including radial velocity accurate to approximately 1 km s. RVS also provides a boolean SUCCESS flag per object to indicate whether the results are reliable. Complete details on the RVS software with respect to the DESI MWS are provided by S. E. Koposov et al. [55]; A. P. Cooper et al. [26]. S. E. Koposov et al. [55] demonstrated that requiring RVS SUCCESS=True and SPECTYPE=STAR produces a relatively clean stellar sample. We use the RVS radial velocity measurements from this sample to estimate the radial velocity accuracy of the stellar templates. For each object, the offset is computed as
The distribution indicates fair agreement between the two estimators, with a mean of 0.14 km s and a standard deviation of 5.3 km s. We do not validate other stellar parameters since the stellar templates are not intended for robust subtype classifications (§ 4.1.3). In addition, Redrock imposes a limit of km s for SPECTYPE=STAR, limiting its accuracy for high-velocity stellar targets. Owing to the detailed physical modeling employed for the MWS catalog, that catalog is recommended for scientific analyses of the DESI stellar sample.
Known Issues
Physical Constraints
PCA templates provide a way to flexibly describe a spectrum with a small number of eigenvectors that can be fit with fast linear algebra, but they can also be overly flexible and result in unphysical fits. For example, a small flux calibration offset between two spectrograph arms could be fit as an inverse 4000Å break, or a missubtracted sky line could be fit with a negative emission line. Optional archetypes and a penalty on negative [O II] flux are current methods by which Redrock mitigates unphysical fits, but more could be done. Ongoing work includes adding support for Non-Negative Matrix Factorization (NMF) templates ([95]), improving the negative-emission line penalties, and exploring templates as an interpolation of models on a grid of physical parameters similar to the standard star fits in J. Guy et al. [41] §4.8.
Template Degrees of Freedom
As described in § 3, Redrock selects the best classification using total without accounting for the different number of coefficients in each template set. This mildly favors the 10-coefficient galaxy templates for the default DESI template set. To quantify the impact, we re-ranked the Redrock solutions by reduced instead of total for a random 30% of DESI DR1 tiles. An estimated 0.3% of target spectra would receive a different SPECTYPE; however, these changes are dominated by spectra already flagged with SMALL DELTA CHI2. Among spectra with ZWARN=0, less than 0.1% would receive a different SPECTYPE. The overwhelming majority of these changes would be from GALAXY to QSO-LOZ or to a stellar subtype at effectively the same redshift.
Galaxies with AGN
The default Redrock templates do not include Active Galactic Nucleus (AGN) galaxies in their training sample. These galaxies typically have a mix of broad and narrow emission lines and thus could be fit at the same redshift by either galaxy or QSO templates and assigned to either SPECTYPE=QSO or SPECTYPE=GALAXY. Future work could expand the galaxy templates to include AGN-like broad line features, perhaps as a separate galaxy template subtype. The current lack of an AGN subtype does not pose any issues for LSS studies in DESI however since it would simply be an additional subclassification, rather than meaningfully impacting redshifts. AGN-like galaxies are predominantly assigned a correct redshift even if assigned SPECTYPE=QSO. Further, achieving high completeness for the QSO spectral type classification has proven more difficult than with galaxy spectral type [6] so the potential effect of some current SPECTYPE=QSO SUBTYPE=LOZ QSOs being instead classified as SPECTYPE=GALAXY SUBTYPE=AGN would need to be carefully assessed.
Lyman Series Optical Depth
The original default QSO templates used for the DESI Early Data Release (EDR; [31]) and the QSO-HIZ v1.0 templates used for DESI Data Release 1 (DR1; [33]) both had a mismatch with the Redrock code for how the mean Ly absorption should be handled (in the templates vs. in the code). This led to an increasing redshift bias for QSOs at (e.g., Q. Wu & Y. Shen 2023). The average redshift bias ranged from km s at to km s at in EDR ([13]) and km s to km s in DR1 ([17]). This was corrected in the QSO-HIZ v1.1 templates used for the Loa production to be released with DESI Data Release 2. Corrected QSO redshifts using QSO-HIZ v1.1 templates are included in DESI DR1 as a “zlya” value-added catalog8 (constructed for the BAO analysis presented by [3]).
Quasar Diversity
The current QSO templates have 4 basis vectors for each of the HIZ and LOZ subtypes. This is sufficient for the primary DESI QSO sample, but does not capture the full diversity of QSOs with significant Broad Absorption Lines (BALs), highly reddened QSOs, or QSOs whose properties lie well outside of the standard SDSS/BOSS and DESI QSO target selection ([92, 47]). This could be improved by training a new set of QSO templates directly on DESI data, which would also have the added benefit of improving QSO template resolution. However, initial studies have found it surprisingly difficult to improve upon the current templates without inadvertently adding too much flexibility causing a performance degradation through false-positive fits of galaxy data. For DESI, the current Redrock QSO performance is augmented through additional QSO-specific algorithms using a neural net ([18, 36, 40]) and fitting for the Mg II emission line ([22]). These are run separately from Redrock and are used in combination with Redrock when generating the DESI QSO catalogs.
Exceptionally Narrow Emission Lines
The redshift resolution of the current galaxy templates (Table 1) corresponds to a spacing between the redshift grid points of at and at . This resolution was chosen to balance performance with compute time and output file size. However, in rare instances where a spectrum exhibits only one atypically narrow emission line, this resolution is low enough that it can step over this feature. We tested a galaxy redshift grid with half the current step size, finding only a handful of cases where the solution improved while many of the changed solutions now confused sky lines for emission lines. We therefore concluded the default step size is preferred for the current DESI instrumentation and target classes. A finer grid, or one with constant steps in instead of steps uniform in , should be considered if Redrock is used for higher-redshift galaxy classification.
Increased Catastrophic Failure Rate for DESI ELGs
As galaxy redshifts increase, fewer emission lines are available for fitting until eventually only the [O II] emission line remains visible to the DESI spectrographs. At , the [O II] line coincides with regions of strong sky emission and sky-subtraction residuals can persist even in high S/N spectra. These residuals impact Redrock’s ability to obtain secure redshifts for these galaxies, causing the rate of catastrophic redshifts for ELG targets to noticeably rise. §7 of [79] explores the impact of sky residuals on ELG classification in detail.
Computational Performance
Table 5 shows the runtime for processing 5000 DESI spectra (one exposure) using a GPU node on the Perlmutter system at the National Energy Research Scientific Computing Center (NERSC)9; these nodes have a 64-core AMD EPYC CPU and four NVIDIA A100 GPUs. Other GPUs, e.g., those in Apple-silicon laptops, are not currently supported, and Redrock runs in CPU-only mode on such systems. Timing numbers are shown for using just the CPU and for using the CPU and the GPUs together.10 The “Initial redshift scan” step is dramatically faster on GPUs than on CPUs. This comes at a cost of internal data structure complexity and bookkeeping moving data between the GPUs and CPUs which causes “Rescan + fit minima” step to be slower on the GPUs, though the combined results are still faster when using GPUs.
| Step | CPU-only [seconds] | CPU+GPU [seconds] |
| I/O | 24.8 | 31.5 |
| Rebin templates | 2.6 | 1.0 |
| GPU overhead | 0.0 | 1.6 |
| Initial redshift scan | 274.5 | 34.2 |
| Rescan + fit minima | 66.7 | 178.0 |
| Finalize results | 10.6 | 12.2 |
| Total | 379.2 | 258.5 |
Table 5. Timing results for processing 5000 DESI spectra (one exposure) on a NERSC Perlmutter GPU node.
One exposure of processed DESI data has 2.1 GB of input coadded spectra and 1.3 GB of Redrock outputs.11 It takes less than 5 minutes to process all 5000 spectra for a DESI exposure on these GPU nodes. For the final DESI survey of million targets, this corresponds to node-hours on Perlmutter. For reference, this accounts for of the node-hours required by the full pipeline from calibrations through to redshifting.
Output files
Redrock is a Python software package with experiment-agnostic algorithms, along with separate wrapper scripts for experiment-specific input and output formats. This section documents the formats output by the DESI wrapper (redrock.external.desi.rrdesi), while noting that other experiments could use the same underlying algorithms with different input and output formats (as eBOSS did in the redrock.external.rrboss wrapper).
The primary output file is a multi-HDU (header data unit) FITS format file ([77]), redrock-*.fits, summarized in Table 6. The REDSHIFTS HDU contains the Redrock classification and redshift output, while the other HDUs propagate input metadata about the targets and spectra so that the files are usefully self-contained. Further details about the REDSHIFTS HDU are listed in Table 7. Columns ZERR, ZWARN, CHI2, COEFF, NPIXELS, NCOEFF, and DELTACHI2 use more bits than necessary (int64 or float64) and may be stored as int32 or float32 in future DESI data releases.
| HDU Number | Name | Description |
| 0 | (not set) | Empty |
| 1 | REDSHIFTS | Best fit classification and redshift for each input spectrum |
| 2 | FIBERMAP | Input target metadata, e.g. fluxes and targeting bits |
| 3 | EXP_FIBERMAP | Exposure-specific target metadata, e.g. fiber positions on-sky |
| 4 | TSNR2 | Template signal-to-noise ratios squared |
Table 6. Format summary of the DESI-specific redrock*.fits output file. The REDSHIFTS HDU is the only new information added by Redrock; the other HDUs are propagated from the input coadded spectra files. For further details see https://desidatamodel.readthedocs.io/en/latest/DESI_SPECTRO-REDUX/SPECPROD/tiles/GROUPTYPE/TILEID/GROUPID/redrock-SPECTROGRAPH-TILEID-GROUPID.html
| Column | Type | Description |
| TARGETID | int64 | Unique target identifier |
| Z | float64 | Redshift |
| ZERR | float64 | Estimated redshift error |
| ZWARN | int64 | Bitmask of fit warnings; 0=good |
| CHI2 | float64 | of best fit template to data |
| COEFF | float64[10] | PCA coefficients of best fit |
| NPIXELS | int64 | Number of input pixels (wavelengths) included in fit |
| SPECTYPE | byte6 | Spectral classification |
| SUBTYPE | byte20 | Spectral subtype |
| NCOEFF | int64 | Number of PCA coefficients used |
| DELTACHI2 | float64 | difference in to next best fit |
Table 7. Format of the REDSHIFTS binary table HDU for the DESI-specific redrock*.fits output file.
Redrock encodes warnings about the quality of the fit in the ZWARN bitmask column of the REDSHIFTS HDU of the Redrock output FITS file. Table 8 lists the bits defined in Redrock. Bits 0-9 inherit their name and meaning from SDSS (see A. S. Bolton et al. [15]), though bits 4 (MANY_OUTLIERS), 6 (NEGATIVE_EMISSION), and 8 (BAD_TARGET) are currently not implemented in Redrock.
| Bit number | Name | Description |
| 0 | SKY | sky fiber |
| 1 | LITTLE_COVERAGE | too little wavelength coverage |
| 2 | SMALL_DELTA_CHI2 | chi-squared of best fit is too close to that of second best |
| 3 | NEGATIVE_MODEL | archetype fit model is negative |
| 4 | MANY_OUTLIERS | UNUSED; More than 5% of data points are > from best model fit |
| 5 | Z_FITLIMIT | chi-squared minimum at edge of the redshift fitting range |
| 6 | NEGATIVE_EMISSION | UNUSED; a QSO line exhibits negative emission |
| 7 | UNPLUGGED | the fiber was unplugged/broken, so no spectrum obtained |
| 8 | BAD_TARGET | UNUSED; catastrophically bad targeting data |
| 9 | NODATA | No data for this fiber, i.e., all input wavelengths are masked or have ivar=0 |
| 10 | BAD_MINFIT | Bad parabolic fit to the minimum |
| 11 | POORDATA | Poor input data quality but try fitting anyway |
| 12-15 | Reserved | Reserved for future use by Redrock |
| 16-23 | Reserved | Reserved for future use by experiment-specific post-Redrock processing |
| 24-31 | Reserved | Reserved for future use by Redrock |
Table 8. ZWARN bits defined by Redrock.
Bits 16–23 are reserved for experiment-specific post-Redrock processing, that is, Redrock never sets these bits, so that the ZWARN bitmask can be propagated to downstream files while setting those bits for other purposes. DESI uses these for augmenting the Redrock output with quality assurance (QA) warning flags in the “merged target list,” downstream from the Redrock output itself ([82]). Bits 12–15 and 24–31 are currently not used, but may be used for additional Redrock warning flags in the future.
More detailed outputs are available in HDF5 format12 in the rrdetails-*.h5 files, including the best 3 redshift fits per template SPECTYPE for each TARGETID (zfit/TARGETID/zfit table); and the vs. per target per template SPECTYPE (zscan/SPECTYPE::SUBTYPE/zchi2 and redshifts arrays). HDF5 supports a nested hierarchy of datasets as shown in Figure 10. For example, zscan/QSO::HIZ/redshifts contains the array of redshifts scanned for the QSO HIZ template, and zscan/QSO::HIZ/zchi2[i] gives the fit values for target targetids[i] at each of those redshifts.

rrdetails HDF5 file structure:
targetids: int64 array[numtargets] of input unique target identifiers
zscan:
SPECTYPE or SPECTYPE:::SUBTYPE (e.g. "GALAXY" or "QSO:::HIZ"):
redshifts: 1D array[numredshifts] of redshifts fit for this SPECTYPE
zchi2: 2D array[numtargets,numredshifts]
chi2 values for this SPECTYPE and this redshift
zcoeff: 3D array[numtargets,numredshifts,numcoeff]
best-fit PCA coefficients for this SPECTYPE at this redshift
penalty: 2D array[numtargets,numredshifts]
chi2 penalty values
zfit:
TARGETID (str, not int):
zfit: table of top 3 redshift fits per SPECTYPE for this TARGETIDFigure 10. Summary of the nested structure of Redrock details HDF5 files.
The final DESI Redrock output file rrmodel-*.fits contains the pre-rendered best-fit templates for each target. This file mimics the format of the input spectra files such that the ith row of the model data corresponds to the ith input spectrum.
Code
Redrock code is available from https://github.com/desihub/redrock using an open source BSD 3-clause license.13 Templates and Archetypes are kept in separate repositories so that they can be developed, versioned, and tagged independently of the code using them. The templates used by DESI are available at https://github.com/desihub/redrock-templates, and archetypes at https://github.com/desihub/redrock-archetypes. The DESI data processing runs for the Early Data Release used Redrock tag 0.15.4 and tem-
plates tag 0.7.2. Data Release 1 used Redrock tag 0.17.0 and templates tag 0.8. Neither used archetypes, which were still under development at the time of those data processing runs.
Redrock is written in Python, leveraging NumPy14 ([43]) and SciPy15 ([89]) for efficient compiled-code wrappers to matrix and linear algebra operations. It additionally uses Numba16 ([58]) for just-in-time (JIT) compilation of the custom trapezoidal integration used for template rebinning; prior to using Numba this step dominated the runtime. NVIDIA Graphics Processing Units (GPUs) are supported through the use of CuPy which provides a NumPy compatible API to GPU algorithms as well as JIT compilation of custom CUDA kernels. Redrock supports parallelism through Message Passing Interface (MPI) mpi4py ([27]) or with Python multiprocessing. Overall, Redrock is designed to be capable of running on a laptop with no GPU or MPI installed, while leveraging MPI and GPUs on a supercomputer for large-scale data processing.
The primary Redrock code is experiment-agnostic, with anything DESI-specific isolated to redrock.external.desi, e.g. file I/O format wrappers and interpreting what is meant by the “POORDATA” ZWARN bit (see § 8). Keeping the templates separate from the code also facilitates reusing the Redrock code with new templates optimized for different types of galaxies, e.g., DESI has explored custom templates for Lyman- emitter (LAE) galaxies in preparation for future observing programs.
The code structure of experiment-specific wrappers on top of an experiment-agnostic toolkit, plus making the code open-source from the start, enabled Redrock to be used by eBOSS well before DESI began operations. This benefited both collaborations — eBOSS gained a redshift fitter that outperformed their default code, while at the same time they contributed improvements and real data testing that accelerated DESI’s readiness for operations.
Template file format
Redrock uses the environment variable $RR\_TEMPLATE\_DIR to define a directory containing templates to use. This is kept separate from the Redrock code itself to enable future projects to develop templates customized for their needs while still using the same Redrock code. Templates used by DESI include galaxy, QSO, and star templates. By default, Redrock will use the template files listed in templates-default.txt, though it can optionally use other files to define which templates to load, e.g., templates-fuji.txt defines the templates used in the “Fuji” production included in the DESI Early Data Release ([31]), templates-iron.txt defines the set used for DESI Data Release 1 ([33]), and templates-loa.txt defines the set used for future DESI Data Release 2.17
The templates are stored in a FITS-format ([77]) file Header Data Unit (HDU) 0 with EXTNAME=BASIS_VECTORS. The templates are a 2D array of number of templates by number of wavelengths. Header keywords CRVAL1 and CDELT1 define the starting wavelength and wavelength step, in Angstroms. If present, keyword LOGLAM=1 indicates that the wavelength grid is expressed as instead of a linear wavelength grid. Keywords RRTYPE and RRSUBTYPE define the spectral type (classification) and subtype (blank if not applicable). Authors of new templates are strongly encouraged to include a VERSION keyword for traceability. Note that VERSION refers to the version of the individual template, not the tagged version of the Redrock code nor any tags of the redrock-templates repository.
The templates provided with Redrock follow the naming convention rrtemplate-RRTYPE-RRSUBTYPE-VERSION.fits. This allows downstream code to reconstruct the matching template name using the RRTYPE, RRSUBTYPE, and VERSION metadata in the Redrock output files, though this naming scheme is not required by the Redrock code.
Other HDUs are allowable but ignored. For example, the rrtemplate-GALAXY-None-v2.6.fits templates include a second HDU recording the coefficients of the PCA fits to the training data used to generate the 10 PCA templates in HDU 0 BASIS_VECTORS.
Conclusions
Redrock is a PCA-based spectral classifier designed for high-accuracy, automated spectral typing and redshift estimation. It is tailored to the needs of the DESI survey, but remains generic enough to be used by other spectroscopic surveys (e.g., SDSS). One of the key features of Redrock is that it efficiently leverages the full spectrum for classification, rather than relying on a specific subset of emission lines. The Redrock software package includes PCA template sets for several stellar subtypes, galaxies, and quasars. While fitting, Redrock convolves its templates with the per-spectrum resolution matrix, accurately modeling the non-Gaussian, wavelength-dependent instrumental resolution while preserving the uncorrelated error model of the data. The performance of Redrock with this template suite on a high-fidelity truth-labeled catalog of DESI spectra demonstrates its efficacy, achieving excellent redshift recovery rates for all extragalactic target classes and accurate stellar radial velocities. Redrock has proven to be an accurate, robust, and computationally efficient core component of the DESI spectroscopic pipeline, capable of classifying and fitting redshifts for the survey’s diverse target populations. Its open design allows for continuous improvement and application to future spectroscopic endeavors.
DATA AVAILABILITY
The plots in this paper are based upon data released as part of DESI Data Release 1 (DR1), except the performance analysis of § 5 which uses the forthcoming DR2. The code to reproduce the figures is available at https://github.com/desihub/redrockpaper.
ACKNOWLEDGMENTS
SB is the developer and current maintainer of the Redrock software. AB developed the default DESI QSO PCA templates and led the analysis presented in § 5. JM developed the default DESI galaxy PCA templates and conducted various efficiency studies. AA developed the DESI-based archetypes and validated the performance of Redrock’s archetype mode on DESI data. CW ported Redrock to GPUs. TK implemented the MPI parallelization. The authors thank Hélion du Mas des Bourboux for early Redrock development as part of eBOSS. JM gratefully acknowledges funding support for this work from the U.S. Department of Energy, Office of Science, Office of High Energy Physics under Award Number DE-SC0020086.
This material is based upon work supported by the U.S. Department of Energy (DOE), Office of Science, Office of High-Energy Physics, under Contract No. DE–AC02–05CH11231, and by the National Energy Research Scientific Computing Center, a DOE Office of Science User Facility under the same contract. Additional support for DESI was provided by the U.S. National Science Foundation (NSF), Division of Astronomical Sciences under Contract No. AST-0950945 to the NSF’s National Optical-Infrared Astronomy Research Laboratory; the Science and Technology Facilities Council of the United Kingdom; the Gordon and Betty Moore Foundation; the Heising-Simons Foundation; the French Alternative Energies and Atomic Energy Commission (CEA); the Secretariat of Science, Humanities, Technology and Innovation (SECHTI) of Mexico; the Ministry of Science, Innovation and Universities of Spain (MICIU/AEI/10.13039/501100011033), and by the DESI Member Institutions: https://www.desi.lbl.gov/collaborating-institutions. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the U. S. National Science Foundation, the U. S. Department of Energy, or any of the listed funding agencies.
The authors are honored to be permitted to conduct scientific research on I’oligam Du’ag (Kitt Peak), a mountain with particular significance to the Tohono O’odham Nation.
Facility: Mayall (DESI)
Software: iSEDfit (J. Moustakas [67]), NumPy (C. R. Harris et al. [43]), SciPy (P. Virtanen et al. [89]), Numba (S. K. Lam et al. [58]), mpi4py (L. Dalcin et al. [27]), cupy (R. Okuta et al. [75]), astropy (Astropy Collaboration et al. [9, 10, 11]), Matplotlib (J. D. Hunter [45]), seaborn (M. Waskom [90])
Galaxy Basis Templates
DESI observes galaxy targets spanning a broad range of redshifts and intrinsic spectral properties, making it essential that our galaxy templates represent this diversity (J. Moustakas et al. 2026, in preparation). BGS (C. Hahn et al. [42]) targets a magnitude-limited sample at that encompasses the full range of galaxy spectral types, from massive quiescent systems with old stellar populations to actively star-forming galaxies with young stellar populations and strong emission lines. LRG (R. Zhou et al. [94]) targets at are predominantly old, metal-rich galaxies exhibiting a prominent 4000-Å break and little ongoing star formation. And ELG (A. Raichoor et al. [79]) targets at are actively star-forming galaxies characterized by strong, high-equivalent-width nebular emission lines, particularly the [O II] , 29 doublet.
To represent this diversity in galaxy type and astrophysical properties, our strategy is to construct a large parent sample of basis templates grounded in observations of real galaxies. The AGN and Galaxy Evolution Survey (AGES; [51]) provides the BGS training sample at ; the Deep Extragalactic Evolutionary Probe 2 (DEEP2; [74]) provides the ELG training sample at ; and a photometric and spectroscopic compilation of color-selected galaxies from the DESI Legacy Imaging Surveys Data Release 7 (Legacy Surveys DR7; [34]) provides the LRG training sample at .18
We generate the basis templates using a data-driven approach. We start by modeling each object’s available broadband photometry (at its spectroscopic redshift) using stellar population synthesis (SPS) models. SPS models yield a model of the stellar continuum at high spectral resolution (), without the instrumental effects of each original survey, and over a broad range of rest-frame wavelength (–) extending well beyond what survey spectroscopy alone provides. Then, we use empirical correlations between observed nebular line ratios and the 4000-Å break, (the ratio of the mean flux density in the 4000–4100 Å and 3850–3950 Å rest-frame windows), to tie this continuum model to an inferred emission-line spectrum, yielding a semi-empirical description of each galaxy’s full spectral energy distribution. This semi-empirical treatment of the emission lines avoids having to predict line strengths from first-principles photoionization modeling, which remains highly uncertain, particularly for forbidden-line ratios.
In §A.1 we describe this approach in more detail as well as the SPS and emission-line modeling common to all three template sets, and in §§A.2, A.3, and A.4 we describe the specific construction of the BGS, ELG, and LRG basis templates, respectively.
Stellar Continuum and Emission-Line Modeling
The rest-frame UV/optical spectral energy distributions of galaxies consist of two principal components: a stellar continuum arising from the galaxy’s composite stellar population, which encodes its star formation and chemical evolution history, and a series of narrow emission lines produced in H II regions— gas photoionized by hot, young stars ([49, 23, 50]). Galaxies with no ongoing star formation produce pure stellar continua, while actively star-forming galaxies can exhibit emission-line equivalent widths of hundreds to thousands of Angstroms. In addition, dust grains attenuate both components by wavelength-dependent amounts ([23], and references therein).
For all three template sets, we model the stellar continuum of each training galaxy using the iSEDfit Bayesian spectral energy distribution (SED) fitting code ([72, 67]).19 We build simple stellar populations (SSPs) from the theoretical C3K stellar library (CKC14; C. Conroy 2014, private communication; see also [24]), Padova stellar evolution isochrones ([39, 63]), and a P. Kroupa [57] initial mass function (IMF) spanning –. We allow the stellar metallicity to range from to (20%–160% solar). The spectral coverage of these models spans – at a resolution of between and —more than twice the maximum instrumental resolution of the DESI spectrographs ([41, 1])—ensuring that the models can be convolved to match any instrumental line spread function without loss of information. To model the dust attenuation, we use the simple [21] dust law, , where is the wavelength-dependent optical depth and we take .
For the BGS and ELG samples, we parameterize each galaxy’s star formation history (SFH) as an exponentially declining -model, , supplemented by stochastic, constant star formation bursts of varying duration and burst fraction. We generate 30,000 Monte Carlo realizations of the model parameters spanning ages , e-folding times , and assuming a 20% burst probability. For the LRG training sample, which predominantly consists of quiescent galaxies dominated by evolved stellar populations, we adopt a delayed- SFH, , , , and no burst component. The maximum-likelihood SED model for each galaxy yields its rest-frame stellar continuum spectrum at , normalized to at 10 pc.
Figure 11 summarizes the distributions of four physical properties—redshift, , stellar mass, and dust optical depth —across all three basis template sets, illustrating the complementary physical parameter space each class occupies.

Figure 11. Distributions of four physical properties for the BGS (green), ELG (blue), and LRG (orange) basis templates, derived from Bayesian SED modeling of the respective training samples (see §§A.2–A.4). The three classes of objects occupy complementary regions of parameter space: BGS spans the full range of stellar populations and dust content at low redshift; ELGs are young, low-mass, moderately dusty star-forming galaxies at intermediate redshift; and LRGs are massive, evolved, nearly dust-free galaxies at –.
Next, we construct the integrated emission-line spectrum of each object. Generating physically realistic emission-line spectra—across the full rest-frame optical through near-infrared wavelength range—is considerably more challenging to do from first principles alone. The absolute and relative emission-line strengths depend on the complex interplay between ionizing photon production, gas-phase abundance, excitation conditions in the gas, and geometry, which are difficult to infer even for individual H II regions [85, 19]. We therefore use an empirical approach in which we measure the primary emission-line anchor for each template class— for BGS and for ELGs—directly from the observed spectrum of the training galaxy and then build the rest of the emission-line spectrum using relations calibrated on local star-forming galaxies and H II regions.
The strongest forbidden lines in the optical are , , and , whose strengths relative to (and to one another) vary significantly with . Moreover, the doublet is itself sensitive to gas-phase abundance and excitation. To quantify these variations, we assemble a dataset of 619 extragalactic H II regions (J. Moustakas et al. [70]), 188 integrated galaxy spectra (807 objects total; [68, 69]), and ≈ galaxies from the SDSS ([16, 87]), and present the observed line-ratio distributions in Figure 12.

Figure 12. Observed forbidden emission-line ratios relative to Hβ, used to calibrate the six-component GMM. Each panel shows a different line ratio versus : SDSS contours (gray; [16, 87]), extragalactic H II regions (orange squares; [70]), and integrated galaxy spectra of low-redshift star-forming galaxies (green circles; [68, 69]). Only the H II region and integrated spectral atlas data (807 objects total) enter the GMM fit; we show the SDSS contours for context only. The GMM assigns the fluxes of these four forbidden lines to the BGS and ELG basis templates (§§A.2 and A.3).
To model the four-dimensional distribution of , , , and , we use a multi-component Gaussian mixture model (GMM) fitted to just the H II region and integrated galaxy spectra. We use the Bayesian information criterion (BIC) to determine the number of GMM components needed to explain the data without overfitting, eventually settling on components.
With the GMM covariance matrices in hand, we proceed to construct each galaxy’s full emission-line spectrum using the following procedure. First, we set the absolute strength of each galaxy’s “anchor line” by multiplying the spectroscopically measured rest-frame equivalent width by the continuum flux density at the anchor wavelength predicted by that object’s best-fitting SED model. The anchor line for BGS and ELG targets is H and [O II], respectively, both of which we measure for all AGES and DEEP2 spectra used in our analysis (see §§A.2 and A.3). This measured equivalent width also correlates with the 4000-Å spectral break strength , which traces the age of the stellar population (Figure 13); we calibrate this relationship separately for each training sample in §§A.2 and A.3, and use it in §A.5 to generate Monte Carlo realizations of the basis templates.

Figure 13. Rest-frame emission-line equivalent width (EW) versus break strength for the BGS and ELG training samples. (): EW(H) for the BGS training sample from AGES; green circles are H-detected objects and purple triangles are upper limits. (): EW([O II] , 29) for the ELG training sample from DEEP2; blue circles are the full sample and orange squares are the subset satisfying DESI ELG target-selection color cuts (A. Raichoor et al. [79]). In each panel the solid curve shows the best-fit second-order polynomial (Equations (9) and (10)), and dashed curves show the intrinsic scatter.
Next, we use the empirically calibrated GMM to draw a random realization of the four forbidden-to-H line ratios, [O III] , [O II] , [N II] , and [S II] . Because the GMM retains the full covariance of the training data, each realization preserves the physical correlations among the lines.
We then utilize the expected doublet ratio for each of these four lines. Atomic transition probabilities fix the [O III] /[O III] and [N II] /[N II] ratios at 2.8875 and 2.93579, respectively. The [O II] /[O II] and [S II] /[S II] doublets, by contrast, are density-sensitive, but we fix them to a representative value characteristic of the low-density limit—0.73 for [O II] and 1.3 for [S II]—appropriate for the low-density H II-region gas that dominates the nebular emission in our training samples.
The templates also include three additional (albeit weak) forbidden doublets—[O I] , [S III] , and [Ar III] , six lines in all—that lie beyond the four line ratios modeled by the GMM; for simplicity, we instead fix the overall strength of each doublet to a representative ratio relative to H (R. Kotulla et al. [56]). As before, we assume, for simplicity, fixed doublet ratios given by atomic transition probabilities: [O I] /[O I] (3.03502), [S III] /[S III] (2.4686), and [Ar III] /[Ar III] (4.16988).
Finally, we compute the strength of the hydrogen and helium recombination lines (H, H, H, He I, and others; see Table 9, all scaled by the H line-strength, using standard Case B recombination ratios assuming a He/H abundance ratio of 0.0897 ([76, 56]).
| Recombination Line | Vacuum Wavelength (Å) | Relative Flux |
| Ly | 1215.670 | 23.54656 |
| H | 6564.613 | 2.863158 |
| H | 4862.683 | 1.000000 |
| H | 4341.684 | 0.4683401 |
| H | 4102.892 | 0.2589474 |
| H | 3971.195 | 0.1590283 |
| H6 | 3890.151 | 0.1050202 |
| H7 | 3836.472 | 0.07312550 |
| H8 | 3798.976 | 0.05302830 |
| H9 | 3771.701 | 0.03971660 |
| H10 | 3751.217 | 0.03053440 |
| H11 | 3735.430 | 0.02399190 |
| H12 | 3722.997 | 0.01920650 |
| H13 | 3713.027 | 0.01561130 |
| H14 | 3704.906 | 0.01286640 |
| H15 | 3698.204 | 0.01073680 |
| H16 | 3692.605 | 0.009052600 |
| Pa | 18756.13 | 0.3386235 |
| Pa | 12821.59 | 0.1632389 |
| Pa | 10941.09 | 0.09044530 |
| Pa | 10052.13 | 0.05545750 |
| Pa | 9548.591 | 0.03656680 |
| Pa9 | 9231.547 | 0.02543320 |
| Pa10 | 9017.385 | 0.01842910 |
| Pa11 | 8865.217 | 0.01378950 |
| Pa12 | 8752.876 | 0.01059920 |
| Br | 40522.62 | 0.08021050 |
| Br | 26258.67 | 0.04546560 |
| Br | 21661.20 | 0.02781380 |
| Br | 19450.87 | 0.01825910 |
| He I 3188 | 3188.662 | 0.04076080 |
| He I 3889 | 3889.752 | 0.1027011 |
| He I 3965 | 3965.852 | 0.01022650 |
| He I 4026 | 4027.348 | 0.02115760 |
| He I 4471 | 4472.755 | 0.04445050 |
| He I 4922 | 4923.304 | 0.01199870 |
| He I 5016 | 5017.079 | 0.02568980 |
| He I 5876 | 5877.299 | 0.1186800 |
| He I 6678 | 6679.994 | 0.03360660 |
| He I 7065 | 7067.198 | 0.02173860 |
| He I 10830 | 10833.22 | 0.2404832 |
| Recombination Line | Vacuum Wavelength (Å) | Relative Flux |
Table 9. Emission Lines. Table 9 continued.
We model each of these emission lines as a single Gaussian centered on its rest-frame vacuum wavelength, so the lines share the systemic redshift of the stellar continuum, with no relative velocity offsets, asymmetries, or broad components. All the lines in a given spectrum have the same intrinsic velocity width (§A.5).
The following three sections apply this shared SPS and emission-line framework to each target class in turn, describing the training sample, selection cuts, and template-specific calibrations we use to construct the BGS, ELG, and LRG basis templates.
BGS Basis Templates
We construct the BGS basis templates from AGES, which obtained intermediate-resolution optical spectroscopy of an magnitude-limited sample of galaxies at over deg using the Hectospec multi-fiber spectrograph on the MMT. The AGES spectra span approximately 3700–9200 Å at (1.2 Å pixel), providing access to H throughout the full survey redshift range. Each galaxy has aperture-matched broadband photometry, unWISE W1 and W2 forced-photometry at 3.4 and 4.6 m (D. Lang et al. [60])20, and a statistical weight correcting for photometric, targeting, and redshift incompleteness. We measure emission-line fluxes and equivalent widths for the full AGES sample, including H, H, and the principal forbidden lines, using the spectral-fitting methods described in J. Moustakas et al. [70, 71].
From the full AGES catalog, we select the BGS training sample by applying the following cuts:
;
(AB, extinction-corrected); and
photometric detections in at least six broadband filters.
In Figure 13a we show the correlation between EW(H) and for this sample of 7636 galaxies. The filled
green circles show the 4187 objects (55%) where H is detected with S/N and rest-frame EW(H) Å, while the open purple triangles show the remaining 3449 galaxies (45%) where H is an upper limit. For the subset of objects where H is well-detected, we fit the correlation with a second-order polynomial,
where with a scatter of approximately 0.2 dex. In §A.5 we describe how we use this fit to generate Monte Carlo template realizations of BGS-like templates.
Finally, we use the methodology described in §A.1 to construct a complete high-resolution SED of each object, using H (where it is well-detected) as the anchor line we use to generate the emission-line spectrum. The resulting 7636 BGS basis templates span 0.1–6 m at and a pixel size of 50 km s. These templates are publicly released as bgs_templates_v2.3.fits.
ELG Basis Templates
We construct the ELG basis templates from DEEP2/DR4 (J. A. Newman et al. [74]), which obtained high-resolution optical spectroscopy of more than 50,000 galaxies using the DEIMOS multi-object spectrograph on the Keck 2 telescope. The spectra span approximately 6500–9300 Å at (0.33 Å pixel), fully resolving the [O II] doublet for galaxies at –1.4. From the public DR4 catalog, we select 35,682 galaxies with high-quality redshifts (; J. A. Newman et al. [74]) and well-calibrated one-dimensional spectra. We assemble a photometric catalog for each galaxy by matching to the extended photometric catalog of D. J. Matthews et al. [64], which provides photometry and photometry from the CFHTLS surveys (DEEP2 Field 1) or SDSS (Fields 2–4), and add WISE W1 and W2 photometry from unWISE forced-photometry measurements at the positions of DEEP2 sources brighter than (D. Lang et al. [60]).
We model the broadband photometry with iSEDfit (§A.1), fitting Field 1 and Fields 2–4 with appropriate filter transmission curves but otherwise identical
SPS modeling priors. We measure emission-line fluxes and equivalent widths using the spectral-fitting methods of J. Moustakas et al. [70, 71], fixing the [O II] flux ratio to its measured median value of 0.73. We consider an emission line detected if its amplitude exceeds 1.5 times the local continuum rms; otherwise we record a upper limit. However, because the DEEP2 spectra are only approximately flux-calibrated, we derive the integrated [O II] flux for each galaxy following G. Zhu et al. [97], multiplying the rest-frame equivalent width from the spectral fit by the continuum flux density at 3727 Å estimated from the best-fitting iSEDfit SED model.
From the full DEEP2 catalog, we select the ELG training sample by applying the following cuts:
;
(AB, extinction-corrected);
SED-fitting with photometric detections in at least six broadband filters;
[O II] doublet detected with S/N ; and
EW([O II] , 29) Å.
These cuts result in a sample of 7,735 galaxies. In Figure 13b we show the relationship between EW([O II]) and for this sample (filled blue circles) and, for reference, the subset of objects which satisfy the DESI ELG color-cuts (A. Raichoor et al. [79]). As for the BGS training sample, we fit the relationship with a second-order polynomial,
where , with an intrinsic scatter of approximately 0.3 dex. §A.5 describes how we use this fit to generate Monte Carlo template realizations.
Finally, we generate the full integrated stellar continuum and emission-line spectrum for every galaxy using the methodology described in §A.1 with [O II] as our anchor emission line. The resulting 7,735 ELG basis templates share the same wavelength grid as the BGS templates: 0.05–6 m at and 50 km s pixels. These templates are publicly released as elg-templates_v2.2.fits.
LRG Basis Templates
We construct the LRG basis templates from a spectroscopic compilation of galaxies assembled to be statistically representative of the photometric LRG population targeted by DESI (R. Zhou et al. [94]). We begin by selecting 111,114 DESI-like LRGs at using the Legacy Surveys DR7 photometry and the R. Zhou et al. [93] photometric redshift catalog. We cross-match this sample against a wide range of public spectroscopic catalogs from SDSS, (e)BOSS, AGES, DEEP2, GAMA, OzDES, VIPERS, VVDS, and COSMOS to identify 75,315 LRGs satisfying the following requirements:
;
at least three observations in each of the , , and bands ();
measured flux in all five bands.
not flagged as a WISE artifact or lying near a bright star (
wisemask = brightstarinblob = False); and
Because this spectroscopic sample is not uniform across the sky, we assign each object a statistical weight proportional to the number of photometric LRG candidates within its neighborhood in the joint space of redshift, apparent magnitude, and observed color. This weight ensures that the final template set statistically mirrors the photometric parent population of million LRGs with precise photometric redshifts (R. Zhou et al. [93]).
We model the photometry at the spectroscopic redshift with iSEDfit (§A.1), adopting the delayed- star-formation history appropriate for this predominantly quiescent population. We do not include emission lines in this sample, even though a small fraction of LRGs are expected to exhibit weak line-emission typically due to residual star formation (e.g., G. Zhu et al. [96]). From the fitted sample, we select 3,000 basis templates via a probability-weighted random draw, in which each galaxy is selected with probability proportional to its statistical weight; this method preferentially samples galaxies that best represent the photometric LRG population while maintaining diversity across the full parameter space of the spectroscopic training set.
The resulting 3,000 LRG basis templates share the same wavelength grid as the BGS and ELG templates: 0.05–6 m at and 50 km s pixels. These templates are publicly released as lrg-templates_v2.2.fits.
Monte Carlo Template Realizations
The basis templates described in this appendix represent a fixed, discrete set of real training galaxies. To build the larger, continuous ensemble of synthetic spectra needed to derive the final galaxy PCA templates (§ 4.1.1)—10,000 ELG, 5,000 LRG, and 5,000 BGS realizations—we use the BGS, ELG, and LRG classes of the desisim software package,21 each of which subclasses a common GALAXY base class and exposes a make_templates() method for generating any number of Monte Carlo realizations from a single input random seed.
For each realization, make_templates() draws a random redshift and apparent magnitude from class-specific ranges, then randomly selects one of the basis-template continua from §§A.2–A.4. For BGS and ELG targets, it also draws a new synthetic anchor-line equivalent width from the calibrated relation (Figure 13) and its intrinsic scatter, together with a new realization of the four forbidden-to-H line ratios from the GMM described in §A.1. Both draws are independent of the values used for the parent basis template, decoupling the number of Monte Carlo emission-line realizations from the fixed number of underlying continua. For a BGS realization built from an H upper-limit basis template (§A.2), this synthetic equivalent width is instead set to zero, so the realization retains the parent galaxy’s stellar continuum without injected emission lines. LRG templates skip the emission-line draw entirely, since the LRG basis templates contain no emission lines. Each realization also draws a velocity dispersion uniformly from 50–150 km s (ELG), 120–300 km s (BGS), or 150–300 km s (LRG), which sets the width of every emission line and broadens the stellar continuum. make_templates() then assembles the resulting spectrum, optionally applies the target class’s DESI selection color-cuts, and repeats the process until it produces the requested number of passing models. A single input seed fully determines every random draw, making the realizations fully reproducible.
Intrinsic velocity shifts of quasar emission lines
The non-uniform velocity shifts of quasar emission lines relative to their host galaxy are a notorious limitation to redshift accuracy. Owing to the finite number of principal components, a set of PCA quasar templates cannot fully capture the diversity of outflow properties (and thus emission line profiles) present in the DESI spectroscopic sample. Further, because of their empirical nature, the templates will incorporate any redshift biases present in the training sample.
The quasar templates used in this manuscript were derived from the SDSS Data Release 16 quasar catalog (DR16Q; B. W. Lyke et al. [62]). The redshift biases of this sample were mitigated by correcting individual spectra to the measured Mg II restframe (A. Brodzeller et al. [17]), chosen for its relative stability compared with other quasar emission lines (e.g., Y. Shen et al. [83]; P. C. Hewett & V. Wild [44]) and visibility over a wide redshift range. This line, however, is not a perfect indicator of systemic redshift, often exhibiting a velocity shift on the order of tens of km s. This appendix explores the accuracy of quasar redshift estimates obtained with these templates for DESI through a spectral stacking analysis.
We use spectral stacking to enhance the signal-to-noise of weak features associated with quasar host galaxies, such as [O II] and Ca II K. The offset of these features relative to the expectation in the absence of redshift error estimates the average redshift accuracy for the stacked sample. We also measure the offset of the quasar emission lines Mg II and C IV, since at only broad lines are observable, thus these drive the redshift estimates. The offsets for these two features cannot be used directly as estimators of accuracy, however, because they incorporate an intrinsic velocity shift from the systemic redshift. Instead, we use Mg II’s average offset from Ca II K as an estimate for the average outflow velocity for Mg II, and use that to extrapolate the average redshift accuracy at higher redshifts when galaxy features are no longer visible. We include C IV only to illustrate the complex quasar dynamics that challenge template redshift estimation, particularly at high redshifts.
We use the DR2 Ly quasar catalog ([3]), which incorporates information from the quasar afterburner algorithms to reduce catastrophic failures caused by line confusion (see E. Chaussidon et al. [22]). Although additional algorithms are used to construct this catalog, all final redshifts come from Redrock. We exclude known BAL quasars ([37]), since this sub-class introduces additional redshift uncertainties unrelated to the PCA template bias and outflow velocities within the sample (e.g., [38]).
We bin the quasar catalog on over , and compute the error-weighted mean spectrum of each bin after shifting the individual spectra to the Redrock rest-frame solution. We fit the mean spectra in the regions of the Ca II K, [O II], Mg II, and C IV emission lines (absorption line in the case of Ca II K), if visible for the given redshift bin. The fit to each line consists of a power-law to describe the underlying continuum plus a multi-component Gaussian for the line. The fits are visually inspected to confirm quality, and the number of Gaussians is fixed to one for Ca II K and [O II], and two for Mg II and C IV.
We measure the average velocity offset of each line from its expected rest-frame wavelength in the absence of redshift errors — and absence of intrinsic shifts in the case of broad lines — in two ways. First, using the difference between the centroid of the narrow Gaussian and the vacuum wavelength (Table 10), and then using the location of the peak flux of the emission line model described in the previous paragraph. The results are shown in Figure 14. The two methods yield consistent

Figure 14. Average velocity offset of prominent emission lines relative to the Redrock redshift estimates in various redshift bins as measured by the line centroid (markers) and the location of the line’s peak flux (line). The grey-shaded region indicates the overlap between the LOZ and HIZ quasar templates, where either template set can provide the best-fit redshift solution.
| Line | Vacuum Wavelength [Å] |
| Ca II K | 3934.78 |
| [O II] | 3728.48 |
| Mg II | 2798.75 |
| C IV | 1549.06 |
Table 10. The vacuum rest-frame wavelength used for calculating line offsets in Appendix § 12, taken from D. E. Vanden Berk et al. [88].
tent results for the galaxy features and are within ∼15 km s for Mg II.
For the following discussion, we assume Ca II K to be a reliable indicator of true redshift. That is, the velocity offset measured for Ca II K can be entirely attributed to redshift errors — a reasonable assumption given that it originates from stellar absorption. With this in mind, the LOZ quasar templates () display a consistent bias of roughly −75 km s. In other words, redshifts are overestimated by this magnitude on average with the LOZ quasar templates. This is unsurprising, given that Mg II was the preferred rest-frame for the templates’ parent sample. The preferred rest frame is further illustrated by the near-zero velocity offset of Mg II across the full LOZ redshift range. Informed by this study, a new version of the LOZ templates (v1.1) was produced for future DESI data releases, in which a positive velocity shift was applied to the wavelength grid, making Ca II K more consistent with a zero velocity offset.
The transition from LOZ to HIZ is apparent in Figure 14 with a clear shift in bias level. At , prominent emission features of the host galaxy are redshifted beyond the wavelength coverage of the DESI spectrograph. Thus, Redrock must rely on sufficient flexibility in the quasar templates to accommodate emission-line diversity while anchoring to the systemic redshift. If the difference between the velocity offset of Mg II and that of Ca II K is roughly constant for the sample (), this implies excellent average accuracy for HIZ redshifts.
We note that there is still relatively large scatter in redshift error (Figure 8), but the average redshift inaccuracy is expected to be rather small. This is supported by the analysis from A. Bault et al. [13] who reported an average redshift inaccuracy for DESI quasars consistent with zero at at with these HIZ templates through cross-correlation with the Ly forest (their Figure 9).
References
- [1]Abareshi, B., Aguilar, J., Ahlen, S., et al. 2022, AJ, 164, 207. https://arxiv.org/abs/2205.10939
- [3]Abdul Karim, M., Aguilar, J., Ahlen, S., et al. 2025b, PhRvD, 112, 083514, doi: 10.1103/2wwn-xjm5
- [4]Adame, A. G., Aguilar, J., Ahlen, S., et al. 2025a, JCAP, 2025, 017, doi: 10.1088/1475-7516/2025/07/017DOI
- [6]Alexander, D. M., Davis, T. M., Chaussidon, E., et al. 2023, AJ, 165, 124, doi: 10.3847/1538-3881/acacfcDOI
- [7]Allende Prieto, C., Koesterke, L., Hubeny, I., et al. 2018, A&A, 618, A25, doi: 10.1051/0004-6361/201732484DOI
- [8]Anand, A., Guy, J., Bailey, S., et al. 2024, The Astronomical Journal, 168, 124, doi: 10.3847/1538-3881/ad60c2DOI
- [9]Astropy Collaboration, Robitaille, T. P., Tollerud, E. J., et al. 2013, A&A, 558, A33, doi: 10.1051/0004-6361/201322068
- [10]Astropy Collaboration, Price-Whelan, A. M., Sipócz, B. M., et al. 2018, AJ, 156, 123, doi: 10.3847/1538-3881/aabc4f
- [11]Astropy Collaboration, Price-Whelan, A. M., Lim, P. L., et al. 2022, ApJ, 935, 167, doi: 10.3847/1538-4357/ac7c74DOI
- [12]Bailey, S. 2012, PASP, 124, 1015, doi: 10.1086/668105DOI
- [13]Bault, A., Kirkby, D., Guy, J., et al. 2024, arXiv e-prints, arXiv:2402.18009. https://arxiv.org/abs/2402.18009
- [14]Bolton, A. S., & Schlegel, D. J. 2010, PASP, 122, 248, doi: 10.1086/651008DOI
- [15]Bolton, A. S., Schlegel, D. J., Aubourg, É., et al. 2012, AJ, 144, 144, doi: 10.1088/0004-6256/144/5/144DOI
- [16]Brinchmann, J., Charlot, S., White, S. D. M., et al. 2004, MNRAS, 351, 1151
- [17]Brodzeller, A., Dawson, K., Bailey, S., et al. 2023, The Astronomical Journal, 166, 66, doi: 10.3847/1538-3881/ace35dDOI
- [18]Busca, N., & Balland, C. 2018, arXiv e-prints, arXiv:1808.09955. https://arxiv.org/abs/1808.09955
- [19]Byler, N., Dalcanton, J. J., Conroy, C., & Johnson, B. D. 2017, ApJ, 840, 44. https://arxiv.org/abs/1611.08305
- [20]Calura, F., Tescari, E., D’Odorico, V., et al. 2012, MNRAS, 422, 3019, doi: 10.1111/j.1365-2966.2012.20811.xDOI
- [21]Charlot, S., & Fall, S. M. 2000, ApJ, 539, 718
- [22]Chaussidon, E., Yèche, C., Palanque-Delabrouille, N., et al. 2023, ApJ, 944, 107, doi: 10.3847/1538-4357/acb3c2DOI
- [23]Conroy, C. 2013, ARA&A, 51, 393. https://arxiv.org/abs/1301.7095
- [24]Conroy, C., Villaume, A., van Dokkum, P. G., & Lind, K. 2018, ApJ, 854, 139. https://arxiv.org/abs/1801.10185
- [25]Cool, R. J., Moustakas, J., Blanton, M. R., et al. 2013, ApJ, 767, 118, doi: 10.1088/0004-637X/767/2/118DOI
- [26]Cooper, A. P., Koposov, S. E., Allende Prieto, C., et al. 2023, ApJ, 947, 37, doi: 10.3847/1538-4357/acb3c0DOI
- [27]Dalcin, L., Paz, R., & Storti, M. 2005, Journal of Parallel and Distributed Computing, 65(9), 1108, doi: 10.1016/j.jpdc.2005.03.010DOI
- [28]DESI Collaboration, Aghamousa, A., Aguilar, J., et al. 2016a, arXiv e-prints, arXiv:1611.00037. https://arxiv.org/abs/1611.00037
- [30]DESI Collaboration, Abareshi, B., Aguilar, J., et al. 2022, AJ, 164, 207, doi: 10.3847/1538-3881/ac882b
- [31]DESI Collaboration, Adame, A. G., Aguilar, J., et al. 2024a, AJ, 168, 58, doi: 10.3847/1538-3881/ad3217
- [32]DESI Collaboration, Adame, A. G., Aguilar, J., et al. 2024b, AJ, 167, 62, doi: 10.3847/1538-3881/ad0b08
- [33]DESI Collaboration, Abdul Karim, M., Adame, A. G., et al. 2026, AJ, 171, 285, doi: 10.3847/1538-3881/ae4c43
- [34]Dey, A., Schlegel, D. J., Lang, D., et al. 2019, AJ, 157, 168, doi: 10.3847/1538-3881/ab089dDOI
- [35]Drinkwater, M. J., Jurek, R. J., Blake, C., et al. 2010, MNRAS, 401, 1429, doi: 10.1111/j.1365-2966.2009.15754.xDOI
- [36]Farr, J., Font-Ribera, A., & Pontzen, A. 2020, JCAP, 2020, 015. https://arxiv.org/abs/2007.10348
- [37]Filbert, S., Martini, P., Seebaluck, K., et al. 2024, MNRAS, 532, 3669, doi: 10.1093/mnras/stae1610DOI
- [38]García, L. Á., Martini, P., Gonzalez-Morales, A. X., et al. 2023, MNRAS, 526, 4848, doi: 10.1093/mnras/stad2993DOI
- [39]Girardi, L., Bertelli, G., Bressan, A., et al. 2002, A&A, 391, 195. https://arxiv.org/abs/astro-ph/0205080
- [40]Green, D., Kirkby, D., Aguilar, J., et al. 2025, arXiv e-prints, arXiv:2505.01596, doi: 10.48550/arXiv.2505.01596DOI
- [41]Guy, J., Bailey, S., Kremin, A., et al. 2023, AJ, 165, 144. https://arxiv.org/abs/2209.14482
- [42]Hahn, C., Wilson, M. J., Ruiz-Macias, O., et al. 2023, AJ, 165, 253, doi: 10.3847/1538-3881/accf18
- [43]Harris, C. R., Millman, K. J., van der Walt, S. J., et al. 2020, Nature, 585, 357. https://arxiv.org/abs/2006.10256
- [44]Hewett, P. C., & Wild, V. 2010, MNRAS, 405, 2302, doi: 10.1111/j.1365-2966.2010.16648.xDOI
- [45]Hunter, J. D. 2007, Computing in Science and Engineering, 9, 90
- [46]Hutchinson, T. A., Bolton, A. S., Dawson, K. S., et al. 2016, AJ, 152, 205, doi: 10.3847/0004-6256/152/6/205DOI
- [47]Juneau, S., Canning, R., Alexander, D. M., et al. 2024, arXiv e-prints, arXiv:2404.03621, doi: 10.48550/arXiv.2404.03621DOI
- [48]Kamble, V., Dawson, K., du Mas des Bourboux, H., Bautista, J., & Scheinder, D. P. 2020, ApJ, 892, 70, doi: 10.3847/1538-4357/ab76bdDOI
- [49]Kennicutt, Jr., R. C. 1992, ApJ, 388, 310, doi: 10.1086/171154
- [50]Kewley, L. J., Nicholls, D. C., & Sutherland, R. S. 2019, ARA&A, 57, 511. https://arxiv.org/abs/1910.09730
- [51]Kochanek, C. S., Eisenstein, D. J., Cool, R. J., et al. 2012, ApJS, 200, 8, doi: 10.1088/0067-0049/200/1/8DOI
- [52]Koester, D. 2010, Mem. Soc. Astron. Italiana, 81, 921
- [53]Koposov, S., Li, T. S., Allende Prieto, C., et al. 2026, The Open Journal of Astrophysics, 9, 55260, doi: 10.33232/001c.155260
- [54]Koposov, S. E., Gilmore, G., Walker, M. G., et al. 2011, ApJ, 736, 146, doi: 10.1088/0004-637X/736/2/146DOI
- [55]Koposov, S. E., Allende Prieto, C., Cooper, A. P., et al. 2024, MNRAS, 533, 1012, doi: 10.1093/mnras/stae1842DOI
- [56]Kotulla, R., Fritze, U., Weilbacher, P., & Anders, P. 2009, MNRAS, 396, 462, doi: 10.1111/j.1365-2966.2009.14717.xDOI
- [57]Kroupa, P. 2001, MNRAS, 322, 231
- [58]Lam, S. K., Pitrou, A., & Seibert, S. 2015, in Proceedings of the Second Workshop on the LLVM Compiler Infrastructure in HPC, 1–6
- [59]Lan, T.-W., Tojeiro, R., Armengaud, E., et al. 2023, ApJ, 943, 68, doi: 10.3847/1538-4357/aca5faDOI
- [60]Lang, D., Hogg, D. W., & Schlegel, D. J. 2016, AJ, 151, 36, doi: 10.3847/0004-6256/151/2/36DOI
- [62]Lyke, B. W., Higley, A. N., McLane, J. N., et al. 2020, ApJS, 250, 8, doi: 10.3847/1538-4365/aba623DOI
- [63]Marigo, P., Girardi, L., Bressan, A., et al. 2017, ApJ, 835, 77. https://arxiv.org/abs/1701.08510
- [64]Matthews, D. J., Newman, J. A., Coil, A. L., Cooper, M. C., & Gwyn, S. D. J. 2013, ApJS, 204, 21, doi: 10.1088/0067-0049/204/2/21DOI
- [65]McQuinn, M. 2016, ARA&A, 54, 313, doi: 10.1146/annurev-astro-082214-122355DOI
- [66]Miller, T. N., Doel, P., Gutierrez, G., et al. 2024, AJ, 168, 95, doi: 10.3847/1538-3881/ad45feDOI
- [67]Moustakas, J. 2017, iSEDfit: Bayesian spectral energy distribution modeling of galaxies, Astrophysics Source Code Library http://ascl.net/1708.029
- [68]Moustakas, J., & Kennicutt, Jr., R. C. 2006, ApJS, 164, 81
- [69]Moustakas, J., Kennicutt, Jr., R. C., & Tremonti, C. A. 2006, ApJ, 642, 775
- [70]Moustakas, J., Kennicutt, Jr., R. C., Tremonti, C. A., et al. 2010, ApJS, 190, 233. https://arxiv.org/abs/1007.4547
- [71]Moustakas, J., Zaritsky, D., Brown, M., et al. 2011, ArXiv e-prints. https://arxiv.org/abs/1112.3300
- [72]Moustakas, J., Coil, A. L., Aird, J., et al. 2013, ApJ, 767, 50. https://arxiv.org/abs/1301.1688
- [73]Newman, J. A., Cooper, M. C., Davis, M., et al. 2013a, ApJS, 208, 5, doi: 10.1088/0067-0049/208/1/5DOI
- [74]Newman, J. A., Cooper, M. C., Davis, M., et al. 2013b, ApJS, 208, 5. https://arxiv.org/abs/1203.3192
- [75]Okuta, R., Unno, Y., Nishino, D., Hido, S., & Loomis, C. 2017, in Proceedings of Workshop on Machine Learning Systems (LearningSys) in The Thirty-first Annual Conference on Neural Information Processing Systems (NIPS). http://learningsys.org/nips17/assets/papers/paper_16.pdf
- [76]Osterbrock, D. E. 1989, Astrophysics of gaseous nebulae and active galactic nucleiDOI
- [77]Pence, W. D., Chiappetti, L., Page, C. G., Shaw, R. A., & Stobie, E. 2010, A&A, 524, A42, doi: 10.1051/0004-6361/201015362DOI
- [78]Poppett, C., Tyas, L., Aguilar, J., et al. 2024, AJ, 168, 245, doi: 10.3847/1538-3881/ad76a4DOI
- [79]Raichoor, A., Moustakas, J., Newman, J. A., et al. 2023, AJ, 165, 126, doi: 10.3847/1538-3881/acb213DOI
- [80]Ross, A. J., Bautista, J., Tojeiro, R., et al. 2020, MNRAS, 498, 2354, doi: 10.1093/mnras/staa2416DOI
- [81]Ruhlmann-Kleider, V., Yèche, C., Magneville, C., et al. 2024, JCAP, 2024, 059, doi: 10.1088/1475-7516/2024/08/059
- [82]Schlafly, E. F., Kirkby, D., Schlegel, D. J., et al. 2023, AJ, 166, 259, doi: 10.3847/1538-3881/ad0832DOI
- [83]Shen, Y., Brandt, W. N., Richards, G. T., et al. 2016a, ApJ, 831, 7, doi: 10.3847/0004-637X/831/1/7DOI
- [84]Stark, P. B., & Parker, R. L. 1995, Computational Statistics, 10, 129. https://www.stat.berkeley.edu/~stark/Preprints/bvls.pdf
- [85]Stasińska, G., & Izotov, Y. 2003, A&A, 397, 71. https://arxiv.org/abs/astro-ph/0209050
- [86]Tonry, J., & Davis, M. 1979, AJ, 84, 1511, doi: 10.1086/125569
- [87]Tremonti, C. A., Heckman, T. M., Kauffmann, G., et al. 2004, ApJ, 613, 898
- [88]Vanden Berk, D. E., Richards, G. T., Bauer, A., et al. 2001, AJ, 122, 549, doi: 10.1086/321167DOI
- [89]Virtanen, P., Gommers, R., Oliphant, T. E., et al. 2020, Nature Methods, 17, 261. https://arxiv.org/abs/1907.10121
- [90]Waskom, M. 2021, The Journal of Open Source Software, 6, 3021
- [92]Yang, J., Fan, X., Gupta, A., et al. 2023, The Astrophysical Journal Supplement Series, 269, 27, doi: 10.3847/1538-4365/acf99bDOI
- [93]Zhou, R., Newman, J. A., Mao, Y.-Y., et al. 2021, MNRAS, 501, 3309, doi: 10.1093/mnras/staa3764DOI
- [94]Zhou, R., Dey, B., Newman, J. A., et al. 2023, AJ, 165, 58, doi: 10.3847/1538-3881/aca5fbDOI
- [95]Zhu, G. 2016, arXiv e-prints, arXiv:1612.06037, doi: 10.48550/arXiv.1612.06037DOI
- [96]Zhu, G., Blanton, M. R., & Moustakas, J. 2010, ApJ, 722, 491, doi: 10.1088/0004-637X/722/1/491DOI
- [97]Zhu, G., Moustakas, J., & Blanton, M. R. 2009, ApJ, 701, 86. https://arxiv.org/abs/0811.3035




