next up previous 78
Next: Summary of Figaro FFT routines
Up: FFT
Previous: Complex filters and data smoothing


Cross correlation, and a sequence something like `scross'

As an additional example, consider the following sequence, which attempts to duplicate the functions performed by `scross'. It is not an exact duplication, since the internals of `scross' are rather different to those of these FFT routines, and the filters used by `scross' also differ from those generated by `cmplxfilt'.

   ICL> sfit spect1 4 cont1 log
   ICL> isub spect1 cont1 sub1
   ICL> sfit spect2 4 cont2 log
   ICL> isub spect2 cont2 sub2
   ICL> cosbell spect1 10 bell
   ICL> imult sub1 bell sub1
   ICL> imult sub2 bell sub2
   ICL> r2cmplx sub1 cspect1
   ICL> r2cmplx sub2 cspect2
   ICL> fft cspect1 cspect1
   ICL> fft cspect2 cspect2
   ICL> cmplxconj cspect2 cspect2
   ICL> cmplxmult cspect1 cspect2 cspect1
   ICL> cmplxfilt cspect1 0.1 0.3 cfilt
   ICL> cmplxmult cspect1 cfilt cspect1
   ICL> bfft cspect1 cspect1
   ICL> cmplx2r cspect1 result
   ICL> peak result

`result' now contains the cross-correlation of the two spectra, `spect1' and `spect2'. `peak' is a utility produced especially for this sort of sequence, listing the position of the highest peak in the spectrum it is given in terms of a shift from the centre of the first element. This is in fact the relative shift of the two spectra `spect1' and `spect2'.

Note that the cross-correlation peak will in fact not be central in `result', but will be at one end or the other. It is often easier to handle data like this if the data is rotated so that the peak is roughly central, and this can be done by the function `rotx'.

   ICL> rotx result 765 result

where 765 is half the number of pixels in the data (here assumed to be 1530). This has the effect of turning `result' into the cross-correlation spectrum that might have been produced by `scross'.

Some of the other strange numbers in the sequence may need explanation. The `4's in the `sfit' indicate that the sequence fits a 4th order polynomial to the spectra, and then subtracts away the polynomial fit. This is in fact what `scross' does, unless the fitting is disabled. The 0.1,0.3 parameters in `cmplxfilt' are quite arbitrary, and the optimum values to use are in fact best determined either by looking at the power spectrum of the data to be filtered, or by consideration of the types of features one wants to emphasise in the determination of the correlation (Hunstead, 1980).



next up previous 78
Next: Summary of Figaro FFT routines
Up: FFT
Previous: Complex filters and data smoothing

FIGARO A general data reduction system
Starlink User Note 86
Keith Shortridge, Horst Meyerdierks,
Malcolm Currie, Martin Clayton, Jon Lockley,
Anne Charles, Clive Davenhall,
Mark Taylor, Tim Ash, Tim Wilkins, Dave Axon,
John Palmer, Anthony Holloway and
Vito Graffagnino
2004 February 17
E-mail:ussc@star.rl.ac.uk

Copyright © 2008 Science and Technology Facilities Council