[SciPy-User] Does Lomb-Scargle reduce to FFT for uniform data?

Milind R killermilind at gmail.com
Tue Jun 30 13:27:45 EDT 2020


Hi All,

I am trying to use the Lomb-Scargle periodogram for a timeseries
dataset of energy consumption with some missing values. In order to
understand it better, I am trying to compare it to an FFT with
linearly interpolated data. However, the values are not even in the
same order of magnitude. According to [1] (see section 5), the
Lomb-Scargle method reduces to a Discrete Fourier Transform when there
are no missing values in the data.

I have double-checked regarding normalisation which are not present in
my invocations of `fft` and `lombscargle`. I have also tried running
`lombscargle` with the interpolated dataset (i.e. invoking both `fft`
and `lombscargle` for the exact same dataset), but still the values
are at completely different scales (1e8 vs 7e3).

Stripped down code with both methods running on the SAME dataset to
illustrate the issue (the field "num" in tmdata dataframe is just a
numeric index):

    import scipy.fftpack as spf
    import scipy.signal as sps

    mean_tmdata = tmdata['ActiveEnergy(kWh)'].mean()

    atmdata = tmdata['ActiveEnergy(kWh)'] - mean_tmdata

    frq = spf.fftfreq(17520, 0.5)

    psd_lomsca = sps.lombscargle((tmdata['num'])/2,atmdata,frq[1:])

    coef_fft = spf.fft(atmdata)
    psd_fft = np.abs(coef_fft[1:])**2

I don't feel comfortable using this function until I get some
understanding of how it relates to the FFT which I am obviously much
more familiar with. Any help on this is greatly appreciated!

Thanks
Milind

[1]  Jacob T. VanderPlas, 2018, "Understanding the Lomb–Scargle
Periodogram",  https://doi.org/10.3847/1538-4365/aab766


More information about the SciPy-User mailing list