Lomb-Scargle periodograms

Fast algorithm for spectral analysis of unevenly sampled data

The Lomb-Scargle method performs spectral analysis on unevenly sampled data and is known to be a powerful way to find, and test the significance of, weak periodic signals. The method has previously been thought to be ‘slow’, requiring of order 10(2)N(2) operations to analyze N data points. We show that Fast Fourier Transforms (FFTs) can be used in a novel way to make the computation of order 10(2)N log N. Despite its use of the FFT, the algorithm is in no way equivalent to conventional FFT periodogram analysis.



>>> import numpy
>>> import lombscargle
>>> x = numpy.arange(10)
>>> y = numpy.sin(x)
>>> fx,fy, nout, jmax, prob = lombscargle.fasper(x,y, 6., 6.)
Press, W. H. & Rybicki, G. B. 1989 ApJ vol. 338, p. 277-280. Fast algorithm for spectral analysis of unevenly sampled data bib code: 1989ApJ...338..277P
YSOVAR.lombscargle.fasper(x, y, ofac, hifac, MACC=4)

function fasper

Given abscissas x (which need not be equally spaced) and ordinates y, and given a desired oversampling factor ofac (a typical value being 4 or larger). This routine creates an array wk1 with a sequence of nout increasing frequencies (not angular frequencies) up to hifac times the “average” Nyquist frequency, and creates an array wk2 with the values of the Lomb normalized periodogram at those frequencies. The arrays x and y are not altered. This routine also returns jmax such that wk2[jmax] is the maximum element in wk2, and prob, an estimate of the significance of that maximum against the hypothesis of random noise. A small value of prob indicates that a significant periodic signal is present.

Press, W. H. & Rybicki, G. B. 1989 ApJ vol. 338, p. 277-280. Fast algorithm for spectral analysis of unevenly sampled data (1989ApJ...338..277P)
02/23/2009, v1.0, MF
Translation of IDL code (orig. Numerical recipies)

X : array

Abscissas (e.g. an array of times).

Y : array

Ordinates (e.g. corresponding counts).

Ofac : integer

Oversampling factor.

Hifac : float

Hifac * “average” Nyquist frequency = highest frequency for which values of the Lomb normalized periodogram will be calculated.


Wk1 : array

Lomb periodogram frequencies.

Wk2 : array

corresponding values of the Lomb periodogram.

Nout : tuple

Wk1 & Wk2 dimensions (number of calculated frequencies)

Jmax : integer

The array index corresponding to the MAX( Wk2 ).

Prob : float

False Alarm Probability of the largest Periodogram value

MACC : integer

Number of interpolation points per 1/4 cycle of highest frequency

YSOVAR.lombscargle.getSignificance(wk1, wk2, nout, ofac)

returns the peak false alarm probabilities

Hence the lower is the probability and the more significant is the peak

YSOVAR.lombscargle.lombscargle(time, mag, maxper=15.0, oversamp=4, maxfreq=1.0)

calculate Lomb-Scargle periodograms for all sources

A new column is added to the datatable that contains the result. (If the column exists before, it is overwritten).


time : np.ndarray

times of observation

mag : np.ndarray

Observed magnitudes

maxper : float

periods above this value will be ignored

oversamp : integer

oversampling factor

maxfreq : float

max freq of LS periodogram is maxfreq * “average” Nyquist frequency For very inhomogenously sampled data, values > 1 can be useful


period1: float :

Period with highest probability in the allowed range

sig1: float :

Value of the Lomb-Scargle-Periodogram at that position

fap: float :

corresponding false-alarm probability