## Welcome to XRV V1.0

Fxcor performs a Fourier cross-correlation on the input list of object and template spectra. The XRV package is a GUI layer to the IRAF task of the same name and performs all of the same functions but with an easier-to-use interface where possible. There is no new scientific functionality available in this version of the task, but users who are familiar with the existing task should find it easier to interact with the data and navigate the many commands available.

This program is still under development and is being released on a testing basis. As such, you may find things which do not work or are not consistent. Please report problems or send comments to iraf@noao.edu.

### Table of Contents

- Tutorial

- Introduction
- On-Line Help
- The On-Line Help Panel
- Correlation Window
  - Menubar Interaction
  - Command Summary
- Spectrum Mode Window
  - Menubar Interaction
  - Command Summary
- Fourier Mode Window
  - Menubar Interaction
  - Command Summary
- Continuum Mode Window
  - Menubar Interaction
  - Command Summary
- Parameter Editor Operations
- Output Options
- Interpolation
- Deblending
- Peak Fitting/Finding Algorithms
- Velocity Computation Algorithm

### Introduction

Fxcor performs a Fourier cross-correlation on the input list of object and template spectra. Object spectra may be either one or two dimensional (in `echelle' or `multispec' format), and may be correlated against a one or two dimensional template. If the template spectrum is only one dimensional but the object is two dimensional, the template is used to correlate each of the apertures specified by the apertures parameter in the object spectrum. Two dimensional templates will correlate corresponding apertures.

If the input spectra are not dispersion corrected (DC-FLAG parameter missing or less than zero), or the pixcorr parameter is turned on, then only a pixel space correlation is done. This is appropriate for a simple cross-correlation of images whether spectra or not. If the spectra are dispersion corrected, a log binned correlation is performed and various radial velocity measurements are made. At a minimum, a relative velocity between the object and template spectra is produced. If the image headers contain sufficient information for heliocentric velocity corrections (see help for the keywpars pset), the corrections are computed and possibly recorded in the image header (see below for an explanation of the velocity computations). If the value of the heliocentric velocity is returned as INDEF, the user may use the 'v' keystroke to see the full results of the correlation, including errors which occurred causing the corrections to not be done.

### On-Line Help

On-line help for all the XRV tasks is available via the usual builtin IRAF help facilities as shown below. These help pages contain information not available in the on-line GUI documentation. To obtain a one line description of each XRV task type help followed by the package name as shown below.

    xr> help xrv

To view the help page for a particular task on the terminal type phelp followed by the task name as shown below.

    xr> phelp fxcor

The on-line GUI documentation can be found in the HTML document xrv$fxcor.html. This document can be viewed and printed with any standard web browser.

### The On-Line Help Panel

The help panel permits the user to view the on-line help document while FXCOR is running. The help panel can be activated by pressing the help command button in any panel, by selecting the "Help ..." item from the main File menu, or by typing the ? keystroke command in the image display window. The help panel consists of the the help command button bar and the help display window which are described below.

The Help Command Button Bar
  The command button bar contains the following command buttons.

  The Back Command Button
    Pressing the Back command button moves backwards through the previously visited links.

  The Forward Button
    Pressing the Forward command button moves forward through the list of visited links.

  The Home Button
    Pressing the Home command button sets the help display window to the top of the help document.

  The Dismiss Button
    Pressing the Dismiss command button deactivates the help panel.

  The bottom of the help panel contains a text search entry widget allowing for text searches of the documentation along with options for searching in a forward or backward direction, and case sensitivity. When a search phrase is entered the help document will be repositioned to the next occcurrance of the search string if found, otherwise a dialog box will appear to say the string was not found. Searches will wrap around the document automatically.

  ### Data Preparation

  A number of operations may be performed to prepare the data for correlation. If a linear wavelength dispersion is defined, the spectra are rebinned to a log-linear dispersion using the interpolant set by the package parameter interp (See the section on interpolation for details). At this time only linear input dispersions are supported for rebinning. The starting and ending wavelength for both spectra will remain the same, but the dispersion in log space will be determined from the rebin parameter if the input dispersions aren't equal, or from the spectrum's endpoints and number of pixels if they are equal. For example, assuming rebin is set to "smallest", if the first object and the template have the same input log dispersion of 0.5e-4 A/pix the data will not be rebinned. The second object, with a wpc of 0.4e-4 A/pix, will force the template to be rebinned to a common wpc of 0.4e-4 A/pix. If the third object on the list then has a dispersion of 0.3e-4 A/pix, the template will again be rebinned from the original 0.5e-4 A/pix dispersion to a new 0.3e-4 A/pix dispersion. If object three and the template are the same star, the template spectrum will suffer from interpolation errors that should be considered when analyzing the results. The output .txt file will update every time the common dispersion is changed. The suggested course of action is to bin all spectra to the same dispersion, preferably a log-linear one, prior to executing this task.

  If the continuum flag is set to something other than "none", the object and/or template data will be continuum subtracted using the fitting parameters found in the continpars pset on input. The data are zeroed outside the sample region specified by the osample and rsample parameters, the ends of each region are apodized, and the bias is then subtracted. If the filter flag is set to something other than "none", the data are Fourier filtered according to the parameters in the filtpars pset prior to the correlation computation.

  ### Correlation Window

  Once the correlation is computed, the maximum peak within the window specified by the wincenter and window parameters is found and fit according to the width or height and peak parameters. A small, unlabelled plot of the entire cross correlation function (hereafter CCF) is drawn above a larger, expanded plot centered on the peak in a window of size specified by the window parameter. The dashed lines in the small plot show the limits of the expanded plot. The bottom axis of the expanded plot is labelled with pixel lag and, if dispersion information is present, the top axis is labelled with relative velocity. To choose a different peak to fit, move the cursor to the top plot of the whole ccf and hit the 'z' keystroke at the desired peak. The plot will be redrawn with the new peak now centered in the window and a fit automatically done. The status line will contain a summary of the pixel shift from the fit and optional velocity information. The 'v' keystroke may be used to suspend graphics and get a more detailed description of the correlation and fit, and the '+' keystroke will toggle the status line output. To view the antisymmetric noise component of the correlation function, simply hit the 'a' keystroke followed by any keystroke to return to the correlation plot. Similarly, the 'e' keystroke may be used to preview the summary plot of the correlation, again hitting any key to return to the correlation. An overplot of the subtracted fit (residuals) may be seen with the 'j' keystroke.

  If the user is dissatisfied with the fit to the peak, he can mark the left and right side of the peak with the 'g' keystroke to redo the fit, or else set the cursor to mark a cutoff with the 'y' keystroke, and all points from the peak maximum to the cursor will be fit. To fix the background of a Gaussian fit (i.e. change the background parameter graphically), type the 'b' keystroke at the desired level, and a new fit will be done. The 'r' keystroke may be used at any time to redraw the plot, and the 'x' keystroke can be used to compute a new correlation if any of the parameters relating to the correlation are changed (e.g. the apodize percentage). New correlations are automatically computed when new images are read in, the data are continuum subtracted, a different region is selected for correlation, or Fourier filtering is done. Certain colon commands from within the Fourier or Spectrum mode will also cause a new correlation to be computed when these modes are exited.

  The 'c' keystroke may be used to get a printout of the cursor position in both lag and relative velocity. The cursor may be positioned in either the unlabelled CCF plot on the top, or in the zoomed plot on the bottom. This is useful for judging the FWHM calculation, or estimating the velocity of a peak without using the 'z' keystroke to zoom and fit. Note that because of the plotting implementation, the normal cursor mode keystroke shift-C should not be used as it may return erroneous results depending upon cursor position. Note also that velocities printed are only approximate relative velocities, and the user should properly fit a peak or use the ":correction" command to get a true heliocentric velocity.

  For binary star work, the user may type the 'd' and/or '-' keystrokes to fit and then subtract up to four Gaussians to the peaks. See the discussion on deblending below for more details on the use of this feature. If multiple peaks were fit, a separate entry will be made in the log file for each peak with a comment that it was part of a blended peak. The metacode file will contain only one summary plot with each peak marked with it's heliocentric velocity or pixel shift.

  To move to the next spectrum in a list (of images or apertures), simply hit the 'n' keystroke. Similarly, the 'p' keystroke will move to the previous spectrum. These commands have a hitch, though. By default, the next/previous commands will move first to the next template in the template image list. Once the end of the template image list is reached, the next spectrum will be the next aperture in the list specified by apertures, resetting the template image list automatically and possibly updating the aperture in the template image as well. Finally, after correlating all of the templates against all of the apertures, the next/previous command will move to the next object image, again resetting the template image and/or aperture list. To override this sequence, the user may use the ":next" or ":previous" commands and specify one of "aperture", "object", or "template". If autowrite is set, the results of the last fit will be written to the log automatically. To write any one of the fits explicity, use the 'w' keystroke.

  The fxcor task also contains three submodes discussed in detail below. Briefly, the 'f' keystroke will put the user in the "fourier mode", where he can examine the Fourier transform of the spectra in various ways and change/examine the filtering parameters. The 'o' and 't' keystrokes let the user examine and fit the continuum for the object and template spectra, respectively, using the icfit commands. Upon exiting the continuum fitting the spectra are continuum subtracted and a new correlation is computed. Finally the 's' keystroke will put the user in "spectrum mode", in which he may graphically select the region to be correlated, compute an approximate shift using the cursor, or simply examine the two spectra in a variety of ways. All of these submodes are exited with the 'q' keystroke, after which the correlation will be redone, if necessary, and the CCF plot redrawn.

  Colon commands may also be used to examine or change parameter values in any of the filtpars, continpars, or keywpars psets. Simply type a ':' followed by the parameter name and an optional new value. The observatory parameters may only be changed outside the task.

  To exit the task, type 'q'. Results will be saved to the logfile automatically if one was specified, otherwise the user will be asked if he wants to save the results, and if so, queried for a file name before exiting if no output file was defined.

  ### Menubar Interaction

  The following Menu and Command buttons are defined at the menubar located at the top of the graphics window:

  File - Options relating to loading new object/template images, displaying results, and setting output filenames.
  Edit - Options which call up various parameter editor panels.
  Mode - Change the current task mode. A mode change brings up a new graphics window with it's own menubar. The current mode is made inactive until that mode is re-entered.
  Parameters - Menu interface to easily set various parameters such a fitting function, output type, etc.
  Plots - Select addition plot options such as marking fit residuals, ccf points, or bring up a new temporary graph window to display the antisymmetric noise ('a' keystroke) plot or a summary plot ('e' keystroke).

  Left Arrow - Move to previous spectrum in the list.
  Right Arrow - Move to next spectrum in the list.
  Save - Save current correlation results.
  Redraw - Redraw the screen.
  Help - Bring up the help window.
  Quit - Exit the task.

  ### Correlation Mode Commands

        ?  Help                -  Subtract blend       +  Toggle status line
        a  Antisymmetric plot  b  Fix the background   c  Cursor read
        d  Deblend             e  Summary plot         f  Fourier mode
        g  Mark limits of fit  I  Interrupt            j  Plot residuals
        l  Page results        m  Mark ccf points      n  Next
        o  Fit obj continuum   p  Previous             q  Quit
        r  Redraw              s  Spectrum mode        t  Fit temp continuum
        v  Verbose output      w  Write                x  Do correlation
        y  Set fit lower limit z  Zoom on CCF

      :apertures [range]               Set/Show list of apertures to process
      :apnum  [aperture]               Set/Show specific aperture to process
      :apodize  [fraction]             Set/Show fraction of endpts to apodize
      :autowrite [y|n]                 Set/Show autowrite param
      :autodraw  [y|n]                 Set/Show autodraw param
      :background  [background|INDEF]  Set/Show background fitting level
      :ccftype  [image|text]           Set/Show type of CCF output
      :comment  [string]               Add a comment to the output logs
      :continuum  [both|obj|temp|none] Set/Show which spectra to normalize
      :correction shift                Convert a pixel shift to a velocity
      :deltav                          Print the velocity per pixel dispersion
      :disp                            Print dispersion info
      :filter  [both|obj|temp|none]    Set/Show which spectra to filter
      :function [gaussian|lorentzian|  Set/Show CCF peak fitting function
                    center1d|parabola]
      :height  [height]                Set/SHow CCF peak fit height
      :imupdate  [y|n]                 Set/Show image update flag
      :maxwidth  [width]               Set/Show min fitting width
      :minwidth  [width]               Set/Show max fitting width
      :n!                              Next command without a write
      :next [temp|aperture|object]     Go to next correlation pair
      :objects  [list]                 Set/Show object list
      :osample  [range]                Set/Show object regions to correlate
      :output  [fname]                 Set/Show output logfile
      :<parameter> [value]             Set/Show pset parameter value
      :peak  [y|n]                     Set/Show peak height flag
      :p!                              Previous command without a write
      :previous [temp|aperture|object] Go to previous correlation pair
      :printz [y|n]                    Toggle output of redshift z values
      :rebin [small|large|obj|temp]    Set/Show the rebin parameter
      :results [file]                  Page results
      :rsample  [range]                Set/Show template regions to correlate
      :show                            List current parameters
      :templates  [list]               Set/Show template list
      :tempvel  [velocity]             Set/Show template velocity
      :tnum  [temp_code]               Move to a specific temp. in the list
      :unlearn                         Unlearn task parameters
      :update                          Update task parameters
      :version                         Show task version number
      :verbose  [y|n]                  Set/Show verbose output flag
      :wccf                            Write out the CCF to an image|file
      :weights  [weight]               Set/Show fitting weights
      :width  [width]                  Set/Show fitting width about peak
      :wincenter  [center]             Set/Show peak window center
      :window  [size]                  Set/Show size of window
      :ymin  [correlation height]      Set/Show lower ccf plot scaling
      :ymax  [correlation height]      Set/Show upper ccf plot scaling

  ### Fourier Mode Description

  Fourier mode is entered from the main task or spectrum modes via the 'f' keystroke or thru the Mode menubar button. By default, the user is presented with a split plot of the power spectra of the object and template spectra (object on top) and the requested filter overlayed. The X-axis is double-labelled with wavenumbers on the bottom of the screen and frequency on top. The ":log_scale" command can be used to toggle the log scaling of the Y-axis of the plot, and the ":overlay" command will toggle whether or not the filter function (if specified) is overlayed on the plot. By default the entire power spectrum is displayed, but the ":zoom" command may be used to specify a blowup factor for the display (e.g. ":zoom 2" will display only the first half of the power spectrum). Plot scaling and content parameters are learned for the next invocation of this mode.

  The plot contents may also be changed through various keystroke commands or the Plots menubar button. The 'p' keystroke will display the power spectrum (the default) and the 'f' keystroke will display the two FFT's. The 'b' and 'g' keystrokes may be used to examine the power spectra and FFT's respectively before filtering. The user can determine the period trend in the data by placing the cursor at a particular wavenumber/frequency and hitting the 'i' keystroke (this command will not work on a plot of the filtered spectra). The 'r' key will redraw whichever plot is currently selected and a 'q' will return the user to the mode which called the Fourier mode.

  Colon commands are also used to specify or examine the filtering parameters by simply typing a ':' followed by the parameter name found in the filtpars pset. Plot options (e.g. plot before or after filtering) and filtering parameters may also be edited using the Plot Opts or Filter Opts menubar buttons respectively.

  ### Menubar Interaction

  The following Menu and Command buttons are defined at the menubar located at the top of the graphics window:

  Mode - Change the current task mode. A mode change brings up a new graphics window with it's own menubar. The current mode is made inactive until that mode is re-entered.
  Plots - Select various Fourier Mode plot options. Each selection has a corresponding keystroke command listed on the left side of the menu item.
  Plot Opts - Call up a plot options editor panel.
  Filter Opts - Call up a filter options editor panel, i.e. the FILTPARS pset editor panel.

  Redraw - Redraw the screen.
  Help - Bring up the help window.
  Back - Exit the mode and return to the previous mode.

  ### Fourier Mode Commands

        ?  Help                  b  PS before filter    f  FFT after filter
        g  FFT before filter     i  Period trend        I  Interrupt
        o  Obj B4/after filter   p  PS after filter     q  Quit
        r  Redraw                s  Spectrum mode       t  Temp B4/after filter
        x  Correlation mode

      :log_scale [y|n]              Plot on a Log scale?
      :one_image [object|template]  What plot on screen
      :overlay [y|n]                Overlay filt function?
      :plot [object|template]       What type of plot to draw on single plot?
      :split_plot [y|n]             Make a split-plot?
      :when [before|after]          Plot before/after filter?
      :zoom [factor]                FFT zoom parameter

  ### Continuum Mode Description

  Automatic continuum subtraction is controlled by the continpars pset. These may be reset from the main correlation function mode. To interactively fit and modify the continuum fitting parameters the 'o' and 't' keys are used. This enters the ICFIT package which is described elsewhere (see icfit). Exiting the fitting, with 'q', causes a recomputation of the correlation function and peak fit. To view the flattened spectra use the spectrum review mode entered with the 's' key. Fitting parameters changed while doing the interactive continuum fitting are learned.

  ### Menubar Interaction

  The following Menu and Command buttons are defined at the menubar located at the top of the graphics window:

  Plots - Select the plot to be drawn.
  Function - Select the fitting function.
  Order - Select the fit order.
  Misc - Miscellaneous ICFIT options.
  Mark Rej - Toggle whether or not to mark rejected points.
  Edit Fit Pars - Call up the CONTINPARS pset editor panel.
  Refit - Refit using the (possibly changed) parameters.

  Redraw - Redraw the screen.
  Help - Bring up the help window.
  Back - Exit the mode and return to the previous mode.

  ### Continuum Mode Commands

        ?    Print options
        a    Add point to constrain fit
        c    Print the coordinates and fit of point nearest the cursor
        d    Delete data point nearest the cursor
        f    Fit the data and redraw or overplot
        g    Redefine graph keys.  Any of the following data types may be along
             either axis.
                  x  Independent variable     y  Dependent variable
                  f  Fitted value             r  Residual (y - f)
                  d  Ratio (y / f)            n  Nonlinear part of y
        h-l  Graph keys.  Defaults are h=(x,y), i=(y,x), j=(x,r), k=(x,d), l=(x,n)
        o    Overplot the next graph
        q    Exit the interactive curve fitting.  Carriage return will also exit.
        r    Redraw graph
        s    Set sample range with the cursor
        t    Initialize the sample range to all points
        v    Change the weight of the point nearest the cursor
        u    Undelete the deleted point nearest the cursor
        w    Set the graph window.  For help type 'w' followed by '?'.
        x    Change the x value of the point nearest the cursor
        y    Change the y value of the point nearest the cursor
        z    Delete sample region nearest cursor
        I    Interrupt task immediately

      :show [file]            Show the values of all the parameters
      :vshow [file]           Show the values of all the parameters verbosely
      :xyshow [file]          Show the x, y, y fit, and weight data values
      :evaluate <value>       Print the fit at the specified value
      :errors [file]          Print the errors of the fit (default STDOUT)
      :function [value]       Fitting function (chebyshev, legendre, spline3,
      spline1)
      :grow [value]           Rejection growing radius
      :naverage [value]       Sample averaging or medianing window
      :order [value]          Fitting function order
      :low_reject [value]     Low rejection threshold
      :high_reject [value]    High rejection threshold
      :niterate [value]       Number of rejection iterations
      :sample [value]         Sample ranges
      :markrej [value]        Mark rejected points?

  Additional commands are available for setting graph formats and manipulating the graphics. Use the following commands for help.

      :/help                  Print help for graph formatting option
      :.help                  Print help for general graphics options

  The graph keys are h, i, j, k, and l. The graph keys may be redefined to put any combination of axes types along either graph axis with the 'g' key. To define a graph key select the desired key to redefine and then specify the axes types for the horizontal and vertical axes by a pair of comma separated types from the following:

        d  Ratio (y / f)
        f  Fitted values
        r  Residuals of fit (y - f)
        n  Nonlinear part of data (linear component of fit subtracted)
        x  Indenpedent variable
        y  Dependent variable (data being fit)

  ### Spectrum Mode Description

  Spectrum mode is entered from the main or fourier mode via the 's' keystroke or the Mode menubar button. The user may select plots of the original input spectra with the 'i' keystroke, or the continuum subtracted spectra with the 'n' keystroke, or thru the Plots menubar button. If the data have been rebinned to a log scale, they will still be be plotted on a linear wavelength scale for clarity. Pixel data are plotted identically to how they were read. (NOTE: For rebinned spectra, a slight slope may be noticed in the 'original' data because of rebinning effects.) In addition, a sample regions (if selected) for the correlation are marked on the bottom of both plots. To select a new sample region, use the 's' keystroke to select the endpoints of the region. An 's' keystroke on the top plot will select a sample region for the object spectrum, and an 's' on the bottom plot will select a template sample, using the 'b' keystroke will select both samples simultaneously. The regions may be selected explicitly by using the ":osample" and ":rsample" commands, and selected sample regions may be cleared entirely using the (e.g.) ":osample *" command. Sample regions may also be set using the Task Parameters editor panel available from the correlation mode Edit menubar button. Individual regions may be unselected by putting the cursor within the region and typing 'u'. See the parameter description for syntax of the sample ranges. Regions will be checked and possibly truncated to see if they lie within the range of the spectrum. The 'd' keystroke may be used to print the difference in pixels (and/or velocity) between two points on the spectrum. This is useful for getting an approximate shift. Fourier mode may be entered via the 'f' keystroke. To return to the correlation simply type 'q' or 'x'.

  In addition to the above commands, the user may examine or change the parameters in the continpars pset by simply typing a ':' followed by the parameter name. Changing these values will not cause a new correlation until an explicit command is given to redo the continuum subtraction.

  ### Menubar Interaction

  The following Menu and Command buttons are defined at the menubar located at the top of the graphics window:

  Mode - Change the current task mode. A mode change brings up a new graphics window with it's own menubar. The current mode is made inactive until that mode is re-entered.
  Plots - Select various Spectrum Mode plot options. Each selection has a corresponding keystroke command listed on the left side of the menu item.

  Redraw - Redraw the screen.
  Help - Bring up the help window.
  Back - Exit the mode and return to the previous mode.

  ### Spectrum Mode Commands

        ?  Help                          b  Select obj/temp sample region
        d  Print velocity diff           e  Do summary plot
        f  Fourier mode                  i  Original spectra
        I  Interrupt                     n  Disp. cont. spectra
        p  Display prepared spectra      q  Quit
        r  Redraw                        s  Select sample regions
        u  Unselect a sample region      x  Return to correlation mode

      :osample [list]         List of object sample regions
      :rsample [list]         List of template sample regions
      :show                   List current parameters

  ### Parameter Editor Operations

  There is a different parameter editor window for each of the task psets or the main task parameters. All input fields, whether text input, toggles or command buttons will have their background changed to a highlight color if modified, the panel Apply button will also be changed to remind the user that Apply must be hit for the change to take effect.

  Each panel has a standard command bar at the bottom of the form, the meaning of each of the buttons is as follows:

  Apply - Apply the parameters. The effect of this is to apply the new settings to the task currently being run, but doesn't necessarily imply update to disk for later invocations of the task. No changes are made to the task operation until Apply is selected.
  Unlearn - Unlearn the parameters. All settings are changed to the task defaults and applied for operations.
  Update - Update the parameters to disk. New settings are applied and updated so they may used for the task once the current session shuts down.
  Cancel - Cancel the current changes. Any changes made to the form are erased and the values currently used by the task are redisplayed.
  Help - Display help on parameter editor operation.
  Dismiss - Close the parameter window.

  ### Output Options

  If the output parameter is set, several files will be created depending on the value of the verbose parameter (see the parameter description for details). These include a file with a ".gki" suffix containing metacode output of a summary plot, a ".txt" suffix file containing text output in the standard IRAF 'list' format containing either verbose or non-verbose output, and a third file having a ".log" suffix containing a verbose description of the correlation and fit, as well as any warning messages. This contents of the ".log" file is identical to what is seen with the 'v' keystroke. If the computed relative velocity exceeds the package parameter z_threshold, the ".txt" file will contain redshift Z values rather than the default velocities. Text file output may be have selected columns extracted using the iraf fields task (where string valued fields will have blank spaces replaced with an underscore), and specific metacode plots may be extracted or displayed with the iraf gkiextract and/or stdgraph/gkimosaic tasks.

  ### Interpolation

  Prior to the correlation, the input spectra may need to be rebinned so they lie on a common wavelength scale, this rebinning is done by interpolating the data. The interpolation type is set by the package parameter interp. The available interpolation types are:

      	nearest - nearest neighbor
      	 linear - linear
      	  poly3 - 3rd order polynomial
      	  poly5 - 5th order polynomial
      	spline3 - cubic spline
      	   sinc - sinc function

  The default interpolation type is a 5th order polynomial (poly5).

  The choice of interpolation type depends on the type of data, smooth verses strong, sharp, undersampled features, and the requirements of the user. The "nearest" and "linear" interpolation are somewhat crude and simple but they avoid "ringing" near sharp features. The polynomial interpolations are smoother but have noticeable ringing near sharp features. They are, unlike the sinc function described below, localized.

  A "sinc" interpolation option is available. This function has advantages and disadvantages. It is important to realize that there are disadvantages! Sinc interpolation approximates applying a phase shift to the fourier transform of the spectrum. Thus, repeated interpolations do not accumulate errors (or nearly so) and, in particular, a forward and reverse interpolation will recover the original spectrum much more closely than other interpolation types. However, for undersampled, strong features, such as cosmic rays or narrow emission or absorption lines, the ringing can be more severe than the polynomial interpolations. The ringing is especially a concern because it extends a long way from the feature causing the ringing; 30 pixels with the truncated algorithm used. Note that it is not the truncation of the interpolation function which is at fault!

  Because of the problems seen with sinc interpolation it should be used with care. Specifically, if there are no undersampled, narrow features it is a good choice but when there are such features the contamination of the spectrum by ringing is much more severe than with other interpolation types.

  ### Deblending

  When entering the deblending function (via the 'd' keystroke in the correlation window), two cursor settings define the local background, which may be sloping, and the region to be fit. Note that both the x and y of the cursor position are used. The lines to be fit are then entered either with the cursor ('m'), or by typing the shifts ('t'). The latter is useful if the shifts of the lines are known accurately and if fits restricting the absolute or relative positions of the lines will be used (i.e. 'a', 'b', 'd', 'e'). A maximum of four lines may be fit. If fewer lines are desired, exit the marking step with 'q'.

  There are six types of fits which may be selected. This covers all combinations of fixing the absolute positions, the relative positions, the sigmas to be the same, and letting all parameters be determined. In all cases the peak intensities are also determined for each line. The options are given below with the appropriate key and mnemonic.

          a=0p1s	Fit intensities and one sigma with positions fixed
          b=1p1s	Fit intensities, one position, and one sigma with
      			separations fixed
          c=np1s	Fit intensities, positions, and one sigma
          d=0pns	Fit intensities and sigmas with positions fixed
          e=1pns	Fit intensities, one position, and sigmas with
      			separations fixed
          f=npns	Fit intensities, positions, and sigmas

  This list may also be printed with the '?' key when in the deblending function.

  As noted above, sometimes the absolute or relative shifts of the lines are known a priori and this information may be entered by typing the shifts explicitly using the 't' option during marking. In this case, one should not use the 'c' or 'f' fitting options since they will adjust the line positions to improve the fit. Options 'a' and 'd' will not change the lines positions and fit for one or more sigmas. Options 'b' and 'e' will maintain the relative positions of the lines but allow an other than expected shift.

  After the fit, the modeled lines are overplotted. The line center, flux, equivalent width, and full width half maximum are printed on the status line for the first line. The values for the other lines and the RMS of the fit may be examined by scrolling the status line using the '+', '-', and 'r' keys. Velocity information is obtained by typing the 'v' keystroke. To continue enter 'q'.

  The fitting may be repeated with different options until exiting with 'q'.

  The fitted model may be subtracted from the data (after exiting the deblending function) using the '-' (minus) keystroke to delimit the region for which the subtraction is to be performed. This allows you to fit a portion of a peak which may be contaminated by a blend and then subtract away the entire peak to examine the remaining components.

  The fitting uses an interactive algorithm based on the Levenberg-Marquardt method. The iterations attempt to improve the fit by varying the parameters along the gradient of improvement in the chi square. This method requires that the initial values for the parameters be close enough that the gradient leads to the correct solution rather than an incorrect local minimum in the chi square. The initial values are determined as follows:

          1.  The initial line centers are those specified by the user
      	either by marking with the cursor or entering the shifts.
          2.  The initial peak intensities are the data values at the
      	given line centers with the marked continuum subtracted.
          3.  The initial sigmas are obtained by dividing the width of
      	the marked fitting region by the number of lines and then
      	dividing this width by 4.

  Note that each time a new fitting options is specified the initial parameters are reset. Thus the results do not depend on the history of previous fits. However, within each option an iteration of parameters is performed as described next.

  The iteration is more likely to fail if one initially attempts to fit too many parameters simultaneously. A constrained approach to the solution is obtained by iterating starting with a few parameters and then adding more parameters as the solution approaches the true chi square minimum. This is done by using the solutions from the more constrained options as the starting point for the less constrained options. In particular, the following iterative constraints are used during each option:

      	a: 0p1s
      	b: 0p1s, 1p1s
      	c: 0p1s, 1p1s, np1s
      	d: 0p1s, 0pns
      	e: 0p1s, 1p1s, 1pns
      	f: 0p1s, 1p1s, np1s, npns

  For example, the most general fit, 'f', first fits for only a single sigma and the peak intensities, then allows the lines to shift but keeping the relative separations fixed. Next, the positions are allowed to vary independently but still using a single sigma, and then allows all parameters to vary.

  To conclude, here are some general comments. The most restrictive 'a' key will give odd results if the initial positions are not close to the true centers. The most general 'f' can also lead to incorrect results by using unphysically different sigmas to make one line very narrow and another very broad in an attempt to fit very blended lines. The algorithm works well when the lines are not severely blended and the shapes of the lines are close to Gaussian.

  ### Peak Fitting/Finding Algorithms

  Determining the center of the cross correlation peak is the key step in measuring a relative shift or velocity between the object and template. The width of the correlation peak is also of interest for measuring a line broadening between the two samples. Since people have different preferences and prejudices about these important measurements, a variety of methods with a range of parameters is provided.

  In all cases, one must specify the fitting function and a sample width; i.e. the range of points about the correlation peak to be used in the measurement. Note that the width defines where the fitting weights vanish and should be something like the full width. For the CENTER1D algorithm the maximum weights are at the half width points while for the other methods (with the exception of "sinc") greater weight is given to data nearer the center.

  The width may be specified in three ways. The first is as an actual width in pixels. This is the most straightforward and is independent of quirks in the actual shape of the peak. The second way is to find where the correlation function crosses a specified height or level. The height may be specified in normalized correlation units or as a fraction of the peak height. The former is equivalent to the interactive 'y' key setting while the latter may be used to select some "flux" point. A value of 0.5 in the latter would be approximately the full width at half intensity point except that the true zero or base of the peak is somewhat uncertain and one needs to keep in mind that the weights go to zero at this point. Note that a level may be negative. In this method the actual width may go to zero or include the entire data range if the level fall above the peak or below the minimum of the correlation. The minimum and maximum width parameters are applied to constrain the fitting region. The last method is to interactively mark the fitting region with the 'g' key.

  There are five methods for determining the correlation peak position. The CENTER1D algorithm has been heavily used in IRAF and is quite stable and reliable. It is independent of a particular model for the shape of the peak or the background determination and is based on bisecting the integral. It uses antisymmetric weights with maxima at points half way between the estimated center and the fitting region endpoint. A parabola fit and sinc interpolation is also independent of background determinations. The parabola is included because it is a common method of peak centering.

  The sinc option uses a sinc interpolator together with a maximization (actually a minimization algorithm) function to determine the peak height and center. A width will be computed only if a background level has been set and is determined empirically based on the peak height and background. Point weighting is not used in this option.

  The gaussian and lorentzian function fits are model dependent and determine a center, width, and peak value. The background may also be determined simultaneously but this extra degree of freedom for a function which is not strictly gaussian or lorentzian may produce results which are sensitive to details of the shape of the correlation function. The widths reported are the full width at half maximum from the fits.

  The parabola, gaussian, and lorentzian methods use weights which vary continuously from 1 at the estimated center to zero at the endpoints of the fitting region. The functional form of the weights is a power law with specified exponent. A value of zero for the exponent produces uniform weights. However, this is discontinuous at the endpoints and so is very sensitive to the data window. A value of one (the default) produces linearly decreasing weights.

  All these methods produce centers which depend on the actual data points and weights used. Thus, it is important to iterate using the last determined center as the center of the data window with continuous weights in order to find a self-consistent center. The methods are iterated until the center does not change by more than 0.01 pixels or a maximum of 100 iterations is reached.

  Errors in the pixel shift are computed from the center parameter of the fitting function. Velocity errors are computed based on the fitted peak height and the antisymmetric noise as described in the Tonry & Davis paper (1979, Astron. J. 84, 1511). Dispersion/pixel-width errors are not computed in this release but are planned for a future release.

  The initial peak fit will be the maximum of the CCF. This will be the only peak fit in non-interactive mode but a confidence level will be entered in the logfile. In interactive mode, the user may select a different peak with the 'z' keystroke, and the maximum peak within the specified window (centered on the cursor) will be fit. The user has full control in interactive mode over the points used in the fit. Once the endpoints of the peak have been selected, the actual data points are shown with '+' signs on the CCF, the fitted curve drawn, and a horizontal bar showing the location of the FWHM calculation is displayed. The status line will show a summary of the fit, and the user may type the 'v' keystroke for a more detailed description of the fit and correlation.

  ### Velocity Computation Algorithm

  Up to three velocities are computed by the task depending on the completeness of the images headers and the presence of dispersion information. If only dispersion information is present, a relative velocity, VREL, and an error will be computed. If a full header is present (see the keywpars help page), an observed and heliocentric velocity (VOBS and VHELIO respectively) will be computed.

  In short form, here are the equations:

         ref_rvobs = catalogue_vel_of_template - H(temp)  # obs. vel. of temp.
         VREL = C * (10 ** (wpc * shift) - 1.)	    # relative vel.
         VOBS = ((1+ref_rvobs/C)*(10**(wpc*shift)-1) * C  # observed vel.
         VHELIO = VOBS + H(object)			    # heliocentric vel.

  where H() is the heliocentric correction for that observation. The equation used for the relative velocity is derived from the standard (1+z), and the VOBS equation reflects that the observed velocity is the product of (1+z) values for the object and template (this allows for high redshift templates to be used). The date, time, and position of each spectrum is found from the image header via the keywords defined in keywpars. In the case of the time the task first looks for a keyword defining the UT mid-point of the observation (keywpars.utmiddle). If that is not found then the mid-point UT is computed from the exposure time (keywpars.exptime) and UT of observation (keywpars.ut) keywords.

  The keyword added to the template header (as defined by the "vhelio" parameter in the keywpars pset) should be the catalogue velocity of the template. Since the observation of the template has a slightly different heliocentric correction, this is subtracted from the template heliocentric velocity so that the observed velocity of the template is used when correcting the relative velocity computed from the shift. This gives the observed velocity of the object wrt the template. Adding the heliocentric correction of the object star then yields the true heliocentric velocity of the object.

  ### Tutorial

  Anyone familiar with the FXCOR task should feel comfortable with the GUI fairly quickly. For the true novice we'll use an example in which we want to process a 1-dimensional object against a 1-dimensional template interactively, examining the FFT and input spectra to define a sample region for the correlation.

  To begin, once the GUIDEMOS and XRV packages are loaded, use the commands:

          xr> cd xrvdata
          xr> fxcor obj temp inter+ continuum="both" autowrite- output=""

  At this point the screen is cleared and CCF peak with the fit is displayed in the main correlation window. The status line contains the results of the fit and the computed velocity. Additionally the task may be started without arguments, in this case a file browser is opened and the user can change directories to select files to be loaded as the object or template spectrum. This panel can be accessed at any time using the "New Object" or "New Template" menu items under the main menubar File menu.

  The user can then interact with the task in a variety of ways:

  1. to refit peak by selecting the left and right edges of the points to be fit, move cursor to left side of peak and type 'g', then move cursor to right side of peak and hit any key. A new fit is drawn and results are displayed to the status line.
  2. type the 'v' key for a detailed description of the correlation. Graphics are suspended and a dialog popup appears which shows various parameters of the correlation and fit.
  3. To examine the FFT's of the spectra, type the 'f' keystroke in the graphics window or select the Fourier Mode from the menubar Mode button. The correlation window is made inactive and a new window appears containing a split plot of the two power spectra (after filtering if this was used) is drawn. The user is now in Fourier Mode and the correlation window is inactive until this mode is exited.
  4. To examine the absolute value of the two FFT's use the 'f' keystroke or select this option from the Plots menubar button.
  5. The Plot Opts button brings up a new panel which allows the user to choose which spectrum to plot, scaling/zoom, and whether or not to overlay the filter. The Filter Opts button calls up the FILTPARS pset editor to let the user choose filtering options.
  6. To exit this mode, type 'q' to return to correlation mode or 's' to start Spectrum mode, this mode change may also be accomplished using the menubar Mode button. If you choose to quit, the Fourier Mode window is closed and control is once again restored to the Correlation mode. If you select Spectrum Mode, the Fourier Mode window is made inactive and a new window appears showing the spectra used in the correlation.
  7. Within Spectrum Mode, move the cursor to some point in either plot and type 's' to mark the endpoints of sample regions for correlation. The user can mark either the top or bottom plot to set sample regions for the object and template respectively, or you can use the 'b' keystroke to select a region that will apply to both spectra. Sample regions are used to either exclude or include features (such as emmission lines, telluric features) that may contaminate the correlation.
  8. Then type 'q' to quit this mode or use the menubar Back button. The Spectrum Mode window then closes and you are returned to the previous mode and that window is made active. By choosing correlation mode from the Mode menubar button you are put immediately in that window and both the Fourier and Spectrum mode windows will be closed if open.
  9. At this point, after editing parameters or selecting sample regions, a new correlation is computed and the peak is refit automatically.
  10. If you are satisfied with the results, type 'q' to quit the task or use the menubar Quit button. If no output file was specified and you wish to save the results, a filename popup will appear to allow you to enter a root filename, otherwise the task will just exit.