Cross-Correlating a Spectrum in XCSAO

For each object spectrum file from the input list spectra, and/or each aperture specified in the aperture list specnum, the fitting subroutine, XCFIT, is called. Spectrum files are all read from the directory specified by specdir, but full or relative pathnames may be used in spectra, and specdir may be null. The spectrum is loaded--and renormalized, if renormalize is set to yes. If obj_plot is yes, the spectrum is plotted as in Figure xcsao1, and the plot is kept on the screen available for zooming and editing until a q is typed. If fixbad is yes, regions specified in the file named by badlines are replaced by straight lines, and the image is plotted again if obj_plot is yes.


Figure xcsao1. XCSAO spectrum display if obj_plot is yes.

Band tempband of each template spectrum in the list templates and list of multispec apertures, tempnum, is loaded. Template files are all read from the directory specified by tempdir, but full or relative pathnames may be used in templates, and tempdir may be null. If echelle is yes, tempnum is ignored, and the multispec lines used for templates track those used for object spectra. If temp_plot is yes, the template spectrum is plotted as shown in Figure xcsao2.


Figure xcsao2. XCSAO display of absorption and emission templates.

A zero-point redshift is computed by adding the solar system barycentric velocity correction, from a source specified by svel_corr, the redshift of the template from the VELOCITY parameter in the template header, an optional template-dependent velocity shift from the TSHIFT parameter in the header, and an optional constant velocity shift from the tshift parameter, and subtracting the barycentric velocity correction for the template, from a source specified by tvel_corr.

An initial redshift source may be specified by vel_init; if guess, this is from czguess; otherwise, if not zero it can be read from an object spectrum header parameter VELOCITY (combination), CZXC (correlation), or CZEM (emission). If such an initial redshift has been called for, or if this is the second pass or greater (nzpass &> 1), the template log-wavelength limits are shifted by that initial redshift (on the first pass)or the current correlation redshift. The wavelength region over which the template and object spectra overlap is computed. If the wavelength in Angstroms specified by st_lambda, is greater than the blue limit of the overlap region, it becomes the new limit. If the wavelength in Angstroms specified by end_lambda, is less than the red limit of the overlap region, it becomes the new limit. The two spectra are rebinned into log-wavelength with a number of pixels, set by ncols using an interpolation mode specified by interp_mode.

First, the continuum, and, optionally, emission lines, are removed from the rebinned object and template spectra. Parameters for fitting the continuum are in the IRAF pset task named contpars. The IRAF curve fitting subroutines fit a function specified by c_function of order order is used to fit the portion of the spectra specified by sample, averaged in groups of naverage pixels. Points outside of limits s_low_reject and s_high_reject, specified in standard deviations of the fit, are eliminated through niterate iterations, with grow pixels rejected on each side of the rejected point. For templates, the rejection limits are t_low_reject and t_high_reject. The continuum may be fit interactively by setting c_interactive to yes, in which case, a plot such as those in Figure xcsao3 is displayed.


Figure xcsao3. Continuum fit for smoothed spectra, over different wavelength ranges for absorption and emission templates. Pixels omitted from the continuum fit are marked with diamonds.

Emission and/or absorption lines may be removed from either or both of each spectrum-template pair. s_emchop controls whether lines will be removed from the object spectrum. If the template header parameter SUBCONT is present, its value overrides that of s_emchop. s_absrej and s_emrej set the lower and upper acceptable limits for object spectrum pixels to be used in the continuum fit. A graph, as shown in Figure xcsao4, of the continuum-removed data is displayed if the contsub_plot parameter is yes.


Figure xcsao4. Spectra with continuum subtracted and emission lines removed.

The continuum is also subtracted from the template spectra t_absrej and t_emrej set the lower and upper acceptable limits for template pixels to be used in the continuum fit to the template if t_emchop is set to yes.

Both spectra are then apodized, tapered at each end for the fraction bell_window of the entire spectrum. If zeropad is yes, the template and object spectra are padded with an equal length of null (zero) spectrum to reduce noise in the Fourier transform. A graph of the continuum-removed, apodized data is displayed as shown in Figure xcsao5 if the apodize_plot parameter is yes.


Figure xcsao5. Spectra apodized at each end, read for cross-correlation against absorption and emission templates.

The spectra are then Fourier transformed. The Fourier power spectra of the object and template spectra are displayed as in Figures xcsao6 and xcsao7 if fft_plot is set to yes.


Figure xcsao6. The same spectrum fourier-transformed over the wavelength ranges of the absorption and emission templates.


Figure xcsao7. Fourier transforms of absorption and emission templates.

The transformed spectra are then filtered with a cosine-bell filter. The low frequencies are filtered from low_bin to top_low and the high frequencies are filtered from top_nrun to nrun. The template header parameter FI-FLAG controls whether the template transform is filtered and whether the high-frequency filter is turned off for both template and object transforms to leave in emission lines. If tfft_plot is set to yes, the filtered Fourier power spectra of the object and template spectra are displayed as in Figures xmsao8 and xcsao9.


Figure xcsao8. The same spectrum transform filtered for correlation agains absorption and emission templates.


Figure xcsao9. Filtered Fourier transforms of absorption and emission templates.

The filtered transforms are then cross-correlated and normalized. If uxcor_plot is yes, the unfiltered correlation is displayed. If the xcor_plot parameter is yes, this result is displayed as in Figure xcsao10, and a specific peak may be selected using the cursor if curmode is yes. In that case, the maximum value within pksrch pixels of the cursor position is used. Otherwise, the highest correlation peak between the velocities minvel and maxvel is used. The redshift is calculated by fitting a parabola or similar function specified by pkmode to the portion of the peak above pkfrac of the maximum value of that peak. The R-value and error are computed, and control returns to XCFIT to set up the template for the next pass.


Figure xcsao10. Normalized, filtered cross correlations of the Fourier transforms of spectrum against the Fourier transforms of absorption and emission templates.

After all of the template spectra have been correlated against an object spectrum, the template with the highest R-value is selected. The results are displayed as text to the devices specified by logfiles in the format specified by report_mode. Figure xcsao11 shows the default report.

IRAF rvsao.xcsao 2.0b mink@cfa0  21-Oct-1997 16:17

1995.1122.0113.311.062165.ms Object: 311.062165 
RA: 08:13:29.34 Dec: 29:02:12.0 $.1f23-Nov-1995 10:37:37.00 =HJD2450044.9457 BCV:  25.30
3679.9A- 7551.7A 4096x2 points, filter: 5 20 125 250 apodize 0.05 fit 0.5 best 2
Temp:        fabtemp97 vel:   0.00  tsh:   0.00 HCV:   0.00 Peak: 14415.2 h:0.223 R:   2.88 CZ: 14441.7 +/-  71.592 1 +tc
Temp:        femtemp97 vel:   0.00  tsh:   0.00 HCV:   0.00 Peak: 14369.4 h:0.891 R:  16.38 CZ: 14395.9 +/-   7.898 1 +hi -tf +tc
Figure xcsao11. Report of results of cross correlation of a spectrum against absorption and emission templates.

If there is only a cross-correlation velocity for this spectrum, that becomes the final velocity and the final velocity error is based on the correlation error. If there is only an emission line velocity, it becomes the final velocity, and the final velocity error is based on the emission error. If both velocities are present and their difference squared divided by the sum of the squares of their errors is less than 8, the error is the two errors added in quadrature and the final velocity is the error-weighed sum of the velocities. If they differ and the correlation R-value is greater than 10 or it is greater than 4 and there are only one or two emission lines found, that velocity is used. Otherwise, the emission line velocity is used. In all cases, an assumed dispersion error of 15 km/sec added in quadrature to the final error value.

If displot is yes, the spectrum and, optionally, the selected correlation peak, are plotted to device in the format specified by dispmode. Figure xcsao12 shows the summary graph if dispmode is 1. Figure xcsao11 shows the dispmode 2 summary graph, with emission and absorption lines labelled. If hardcopy is yes, the same graph is sent to plotter.


Figure xcsao12. Summary display for emission line cross-correlation.

If nsmooth is yes, the displayed spectrum is smoothed by a 1-2-1 sliding filter nsmooth times. The filtered cross-correlation with the best R-value is displayed centered on the redshift cvel (in km/sec) with a width in km/sec of dvel. If cvel is INDEF, the fit redshift is used; if dvel is INDEF, the width is set to 20 times the peak width. If the correlation is not displayed, absorption lines (ablines=yes) and/or emission lines (emlines=yes) may be labelled from line lists in the directory linedir, as shown in Figure xcsao13.


Figure xcsao13. Summary display with labelled lines for emission line cross-correlation.

If curmode is yes, the user can interact with the display using the terminal cursor to zoom in on portions of the spectrum, rerun the cross-correlation, change the display format, edit the spectrum, or several other functions. For example, figure xcsao14 shows the correlation result for the second best template, selected using the T cursor command.


Figure xcsao14. Summary display for absorption cross-correlation.

If save_vel is yes, cross-correlation redshift results are written into the spectrum image header in a form appropriate to the spectrum format: two entries plus one per template if multispec; otherwise one, value per keyword, as in Figure xcsao15

VELOCITY=     14387.9287199659                                              
CZERR   =     16.4555476849055                                              
VELQUAL = '_       '                                                        
BCV     =                   0.                                              
CZXC    =     14395.9304076156                                              
CZXCERR =      7.8982947339756                                              
CZXCR   =     16.3766072577413                                              
BESTTEMP= 'femtemp97'                                                       
CZPARAMS= '2 4096 2 5 20 125 250 0.05'                                      
XCTEMP1 = 'fabtemp97 14441.680 71.592 2.87811 0.223 367.772 0.000 0.000 0 0'
XCTEMP2 = 'femtemp97 14395.930 7.898 16.3766 0.891 183.427 0.000 0.000 0 3' 
XCSAO   = 'rvsao.xcsao 2.0b  21-Oct-1997 16:33 CZXC = 14395.93 R = 16.38'  
Figure xcsao15. Header parameters added by xcsao.


[Rest of Paper]