# FFT of sine signal with phase discontinuities

I am detecting sine signals within a specific bandwidth [0,B] Hz,

The received sine have multiple phase discontinuities, as shown below

I want to measure the frequency of the sine signal but I get a distorted spectrum as expected

What's the best practice to get rid of the high leakage? I have tried windowing but did not really work, I also tried FIR low-pass filter with f_c = B Hz, but also did not work.

• If this signal happens to be the result of bi-phase shift keying, you can simply square the signal to recover the carrier (the result will have a strong and dominant tone at exactly twice the carrier frequency which can be easily detected. There are many alternate carrier recovery approaches for phase shift keying that could also be considered. This would allow you to use much longer time windows in your detection resulting in better frequency resolution. – Dan Boschen Aug 4 '18 at 4:16

## 3 Answers

Since the time series appears to have a very high SNR and you have a good idea of the frequency, know the sample rate, and can detect the discontinuities,

$$\min_{A,f,\theta} \left\lVert y_i - A \sin(2\pi\frac{f}{f_s} i + \theta)\right\rVert^2_2 \quad \{i\in \text{outside discontiuties}\}$$

will be locally convex if the minimization is near the true values. The DFT is good at pulling tones out of noise. You don't seem to have a lot of noise so, the DFT isn't always the best tool.

not enough room in comments

If you really want to use a DFT based technique on segments, try Macleod's frequency interpolator:

M. D. Macleod, "Fast nearly ML estimation of the parameters of real or complex single tones or resolved multiple tones," in IEEE Transactions on Signal Processing, vol. 46, no. 1, pp. 141-148, Jan 1998. doi: 10.1109/78.651200 Abstract: This paper presents new computationally efficient algorithms for estimating the parameters (frequency, amplitude, and phase) of one or more real tones (sinusoids) or complex tones (cisoids) in noise from a block of N uniformly spaced samples. The first algorithm is an interpolator that uses the peak sample in the discrete Fourier spectrum (DFS) of the data and its two neighbors. We derive Cramer-Rao bounds (CRBs) for such interpolators and show that they are very close to the CRB's for the maximum likelihood (ML) estimator. The new algorithm almost reaches these bounds. A second algorithm uses the five DFS samples centered on the peak to produce estimates even closer to ML. Enhancements are presented that maintain nearly ML performance for small values of N. For multiple complex tones with frequency separations of at least 4π/N rad/sample, unbiased estimates are obtained by incorporating the new single-tone estimators into an iterative “cyclic descent” algorithm, which is a computationally cheap nonlinear optimization. Single or multiple real tones are handled in the same way. The new algorithms are immune to nonzero mean signals and (provided N is large) remain near-optimal in colored and non-Gaussian noise keywords: {Fourier analysis;Gaussian noise;amplitude estimation;frequency estimation;harmonic analysis;interpolation;iterative methods;maximum likelihood estimation;optimisation;phase estimation;signal sampling;spectral analysis;white noise;AWGN;Cramer-Rao bounds;FFT;amplitude;cisoids;colored noise;complex single tones;discrete Fourier spectrum;fast nearly ML estimation;frequency;frequency separations;interpolator;iterative cyclic descent algorithm;noise;nonGaussian noise;nonlinear optimization;nonzero mean signals;parameter estimation;peak sample;phase;real single tones;resolved multiple tones;sinusoids;unbiased estimates;uniformly spaced samples;Amplitude estimation;Computational efficiency;Frequency estimation;Iterative algorithms;Maximum likelihood estimation;Noise level;Parameter estimation;Phase estimation;Phase noise;Signal processing algorithms}, URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=651200&isnumber=14197

• @Standley Thank you for your answer, but I might need to add that I know where the discontinuities will always be, and since this is a radar problem, I am interested in getting good frequency resolution, I can solve this problem by applying Bartlett's method, where segmentation is held at the discontinuities, but this will degrade the frequency resolution. – Amro Aug 3 '17 at 19:23
• @Amir, I would think that knowing where the discontinuities were would make least squares over continuous segments more attractive, not less. I amended my answer to include Macleod's DFT based estimator. – user28715 Aug 3 '17 at 19:40

It's not leakage. The discontinuities can actually change the spectrum of the entire signal away from that of the sinusoid, by increasing or reducing the number of periods.

If you want the frequency of the sinusoidal signal alone, your best bet might be to window each continuous segment, then average the multiple frequency estimations. Zero-padding each FFT to the full length of the signal to help increase the apparent naive "resolution" will be a good frequency estimation interpolation for each segment.

This answer may be late, but I hope it is still useful for others who may be in a similar situation.

Your best bet is to select your DFT frames so that they don't include your discontinuities. Since it appears you have a high SNR, you should expect very good results. Most frequency estimation formulas based on interpolation do better with a larger number of samples. I have derived formulas that work very well with low sample counts. In addition you only need to calculate two or three DFT bins. With a clean signal, they don't even have to be the peak bins, but you will get best results at the peak bin.

If your frequency is near the center of two bins, use the two bin formula, "Two Bin Exact Frequency Formulas for a Pure Real Tone in a DFT":

dsprelated.com/showarticle/1095.php

If your frequency is near integer, in cycles per frame, use the three bin formula centered at the peak, "Improved Three Bin Exact Frequency Formula for a Pure Real Tone in a DFT":

dsprelated.com/showarticle/1108.php

No windowing, no zero padding, exact answer in the case of a noiseless single pure tone. I also have a blog article on finding the phase and amplitude of the tone which is likewise exact under ideal conditions, and a very good estimator otherwise.

Ced