In two-dimensional spectrographs, the optical distortions in the spatial and dispersion directions produce variations in the sub-pixel sampling of the background spectrum. Using knowledge of the camera distortions and the curvature of the spectral features, one can recover information regarding the background spectrum on wavelength scales much smaller than a pixel. As a result, one can propagate this better-sampled background spectrum through inverses of the distortion and rectification transformations, and accurately model the background spectrum in two-dimensional spectra for which the distortions have not been removed (i.e. the data have not been rebinned/rectified). The procedure, as outlined in this paper, is extremely insensitive to cosmic rays, hot pixels, etc. Because of this insensitivity to discrepant pixels, sky modeling and subtraction need not be performed as one of the later steps in a reduction pipeline. Sky-subtraction can now be performed as one of the earliest tasks, perhaps just after dividing by a flat-field. Because subtraction of the background can be performed without having to clean'' cosmic rays, such bad pixel values can be trivially identified after removal of the two-dimensional sky background.
A large component of astronomy involves the measurement of redshifts using absorption line spectroscopy. Typically such data have non-uniform sources of noise and other systematic defects not easily dealt with when one employs Fourier-based techniques because such methods explicitly weight the data uniformly. Here we develop a method for the measurement of redshifts using the cross-correlation in the Real domain, in which one is free to employ non-uniform weighting. The implementation we describe in this paper allows for the arbitrary exclusion of bad data, and weights each remaining pixel by the inverse of the variance. This prescription for weighting the pixels has the advantage that the units of the cross-correlation are exactly half that of $\chi^2$. Thus, the topology of the peak of the weighted cross-correlation is directly related to the confidence limits on the measured redshifts. The validity of the redshifts and formal errors derived with this method are tested using simulations of galaxy spectra with a broad range of signal-to-noise ratios. These simulations also include tests of the effects of template mismatch. Overall, template mismatch is only significant when the data have high signal-to-noise ratios, and in such cases the systematic error due to mismatch is minimized when one chooses the template that minimizes the error in the redshift. While the weighted cross-correlation is here discussed in the context of extragalactic redshift surveys, this method is also useful for measuring the radial velocity of stars and other astronomical objects.