# How do the results of the CASA hanningsmooth task compare with the online Hanning smoothing done by the ALMA correlator?

Authors list

As described in Correlators chapter of the Technical Handbook, the window function in the ALMA correlator is applied to the time domain (lag domain) data. The Hann window is the default window, but others are available : Uniform, Hamming, Welch, Blackmann and Bartlett. There is a good discussion of these various windows at the wikipedia page.

The Hann window corresponds to weighting by cosine-squared in the lag domain. In the ALMA correlator software, the Hann window is an array of this function of length 512 points. In the frequency domain, this weighting corresponds to averaging by two channels twice, which is what the CASA hanningsmooth task does in the frequency domain, 0.25*d(-1) + 0.5*d(0) + 0.25*d(+1), as indicated in the documentation for that task here.

The figure below summarizes a simple simulation to demonstrate the equivalence of the lag and frequency domain smoothing. A time series of 30000 points was constructed as a sum of sine waves (black line in top panel) in order to generate a simulated spectral line with a Gaussian amplitude profile plus some noise. Then a Hann window was created of equal length (green line) and the product of the two is the red line. This was simpler than constructing a 512-window and breaking up the timestream into multiple pieces and then accumulating the subsequent fast Fourier transforms (FFTs). The single FFT and power spectrum of the black and red lines were computed to generate the black and red spectra in the lower panel. Finally, the equivalent of the hanningsmooth operation was run on the black spectrum to get the blue spectrum (which is nearly invisible underneath the red spectrum).

The red and blue profiles are nearly identical and a bit broader and fainter than the raw profile. The RMS of the residual is computed over the whole profile and it is far less than 1% of the peak.This demonstrates the equivalence of the two approaches. Note that the x-axis was zoomed in quite far to see the details of the spectral line. There is some relevant mathematical discussion at the Wolfram website which may help to shed more light on the issue.  See also Appendix A of Harris 1978: http://web.mit.edu/xiphmont/Public/windows.pdf