LombScargle.jl
Introduction
LombScargle.jl
is a package for a fast multi-threaded estimation of the frequency spectrum of a periodic signal with the Lomb–Scargle periodogram. This is written in Julia, a modern high-level, high-performance dynamic programming language designed for technical computing.
Another Julia package that provides tools to perform spectral analysis of signals is DSP.jl, but its methods require that the signal has been sampled at equally spaced times. Instead, the Lomb–Scargle periodogram enables you to analyze unevenly sampled data as well, which is a fairly common case in astronomy, a field where this periodogram is widely used.
The algorithms used in this package are reported in the following papers:
- Press, W. H. and Rybicki, G. B. (1989). Fast Algorithm for Spectral Analysis of Unevenly Sampled Data. The Astrophysical Journal 338, 277.
- Zechmeister, M. and Kürster, M. (2009). The generalised Lomb-Scargle periodogram: A new formalism for the floating-mean and Keplerian periodograms. Astronomy & Astrophysics 496, 577–584, arXiv:0901.2573 [astro-ph.IM].
Other relevant papers are:
- Cumming, A. (2004). Detectability of extrasolar planets in radial velocity surveys. Monthly Notices of the Royal Astronomical Society 354, 1165–1176, arXiv:astro-ph/0408470 [astro-ph].
- Cumming, A.; Marcy, G. W. and Butler, R. P. (1999). The Lick Planet Search: Detectability and Mass Thresholds. The Astrophysical Journal 526, 890–915, arXiv:astro-ph/9906466 [astro-ph].
- Horne, J. and Baliunas, S. (1986). A Prescription for Period Analysis of Unevenly Sampled Time Series. The Astrophysical Journal 302, 757.
- Lomb, N. (1976). Least-Squares Frequency Analysis of Unequally Spaced Data. Astrophysics and Space Science 39, 447–462.
- Murdoch, K. A.; Hearnshaw, J. and Clark, M. (1993). A Search for Substellar Companions to Southern Solar-Type Stars. The Astrophysical Journal 413, 349.
- Scargle, J. (1982). Studies in astronomical time series analysis. II. Statistical aspects of spectral analysis of unevenly spaced data.The Astrophysical Journal 263, 835–853.
- Sturrock, P. A. and Scargle, J. D. (2010). False-alarm Probability in Relation to Oversampled Power Spectra, with Application to Super-Kamiokande Solar Neutrino Data. The Astrophysical Journal 718, 527–529, arXiv:1006.0546 [hep-ph].
The package provides facilities to:
- compute the periodogram using different methods (with different speeds) and different normalizations. This is one of the fastest implementations of these methods available as free software. If Julia is run with more than one thread, computation is automatically multi-threaded, further speeding up calculations;
- access the frequency and period grid of the resulting periodogram, together with the power spectrum;
- find the maximum power in the periodogram and the frequency and period corresponding to the peak. All these queries can be restricted to a specified region, in order to search a local maximum, instead of the global one;
- calculate the probability that a peak arises from noise only (false-alarm probability) using analytic formulas, in order to assess the significance of the peak;
- perform bootstrap resamplings in order to compute the false-alarm probability with a statistical method;
- determine the best-fitting Lomb–Scargle model for the given data set at the given frequency.
Contents
Installation
LombScargle.jl
is available for Julia 1.0 and later versions, and can be installed with Julia's built-in package manager. In a Julia session run the commands
julia> import Pkg
julia> Pkg.add("LombScargle")
Older versions are also available for Julia 0.4-0.6.
For instructions on using the package, please see the Usage page.
Performance
A pre-planned periodogram in LombScargle.jl
computed in single thread mode with the fast method is more than 2 times faster than the implementation of the same algorithm provided by AstroPy, and more than 4 times faster if 4 FFTW threads are used (on machines with at least 4 physical CPUs).
The following plot shows a comparison between the times needed to compute a periodogram for a signal with N datapoints using LombScargle.jl
, with 1 or 4 FFTW threads (with flags = FFTW.MEASURE
for better performance), and the single-threaded Astropy implementation. (Julia version: 1.6.0; LombScargle.jl
version: 1.0.0; Python version: 3.8.6; Astropy version: 4.1. CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz.)
Note that this comparison is unfair, as Astropy doesn’t support pre-planning a periodogram nor multi-threading, and it pads vectors for FFT to a length which is a power of 2, while by default LombScargle.jl
uses length which are multiples of 2, 3, 5, 7. A non-planned periodogram in single thread mode in LombScargle.jl
is still twice as fast as Astropy.
Development
The package is developed at https://github.com/JuliaAstro/LombScargle.jl. There you can submit bug reports, make suggestions, and propose pull requests.
History
The ChangeLog of the package is available in NEWS.md file in top directory.
License
The LombScargle.jl
package is licensed under the BSD 3-clause "New" or "Revised" License. The original author is Mosè Giordano.
Acknowledgements
This package adapts the implementation in Astropy of the the fast Lomb–Scargle method by Press and Rybicki (1989). We claim no endorsement nor promotion by the Astropy Team.
References
- Cumming, A. (2004). Detectability of extrasolar planets in radial velocity surveys. Monthly Notices of the Royal Astronomical Society 354, 1165–1176, arXiv:astro-ph/0408470 [astro-ph].
- Cumming, A.; Marcy, G. W. and Butler, R. P. (1999). The Lick Planet Search: Detectability and Mass Thresholds. The Astrophysical Journal 526, 890–915, arXiv:astro-ph/9906466 [astro-ph].
- Horne, J. and Baliunas, S. (1986). A Prescription for Period Analysis of Unevenly Sampled Time Series. The Astrophysical Journal 302, 757.
- Lomb, N. (1976). Least-Squares Frequency Analysis of Unequally Spaced Data. Astrophysics and Space Science 39, 447–462.
- Murdoch, K. A.; Hearnshaw, J. and Clark, M. (1993). A Search for Substellar Companions to Southern Solar-Type Stars. The Astrophysical Journal 413, 349.
- Press, W. H. and Rybicki, G. B. (1989). Fast Algorithm for Spectral Analysis of Unevenly Sampled Data. The Astrophysical Journal 338, 277.
- Scargle, J. (1982). Studies in astronomical time series analysis. II. Statistical aspects of spectral analysis of unevenly spaced data.The Astrophysical Journal 263, 835–853.
- Sturrock, P. A. and Scargle, J. D. (2010). False-alarm Probability in Relation to Oversampled Power Spectra, with Application to Super-Kamiokande Solar Neutrino Data. The Astrophysical Journal 718, 527–529, arXiv:1006.0546 [hep-ph].
- Zechmeister, M. and Kürster, M. (2009). The generalised Lomb-Scargle periodogram: A new formalism for the floating-mean and Keplerian periodograms. Astronomy & Astrophysics 496, 577–584, arXiv:0901.2573 [astro-ph.IM].