Code covered by the BSD License  

Highlights from
lombscargle.m

4.75

4.8 | 12 ratings Rate this file 36 Downloads (last 30 days) File Size: 7.35 KB File ID: #993
image thumbnail

lombscargle.m

by Brett Shoelson

 

29 Oct 2001 (Updated 09 Apr 2003)

Performs a Lomb-Scargle periodogram analysis on unevenly spaced data.

| Watch this File

File Information
Description

LOMBSCARGLE(INPUTDATA, DUPE_ELIM) performs a Lomb-Scargle periodogram (spectral) analysis on an n x 2 matrix of data (inputdata = x(i),y(i)) that are not necessarily evenly spaced. (For evenly spaced data, more traditional Fourier-based spectral methods may be more appropriate.)

DUPE_ELIM (= 0 or 1) is an optional argument that will prompt the program (if dupe_elim == 1) to eliminate duplicated samples from the analysis. The default value is 0.

This program will plot and spectrally analyze the input data, and then plot the power spectrum of the data.

The program is also capable of overlaying a signal of known frequency and amplitude; this may be helpful for spectral calibration. The resulting spectrum plot will also include significance levels. Finally, the program will reconstruct a plot of frequencies determined to be "significant" (at alpha = 0.05); for this reconstruction, frequencies within 5% of the calibration signal (if used) will be discarded. Significant frequencies and powers are written to the MATLAB command window.

(This program is based on a Lomb-Scargle implementation in Press, Teukolsky, et al. Numerical Recipes, "Spectral Analysis of Unevenly Sampled Data." Use of this program requires an understanding of the Press/Teukolsky implementation, inculding the usage of hifac and ofac variables. The user is referred to that source for a thorough discussion of the algorithms. In addition, the references cited in Press/Teukolsky are quite helpful--particularly Scargle 1982, and Horne and Baliunas, 1986.)

Note that there is an over-reliance in this code on global variables, and that no attempts have been made to vectorize for loops or to optimize the implementation. Perhaps in the next version....

The attached file INPUTTOLOMB.M includes code for easily generating test data with known frequencies and amplitudes. This file is helpful for users trying to understand the output generated by lombscargle.

Acknowledgements
This submission has inspired the following:
Lomb normalized periodogram
MATLAB release MATLAB 6.1 (R12.1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (18)
07 Apr 2003 cj p

two functions with the same name ("period") so won't run...

15 Dec 2004 Benjamin Rosenbluth  
15 Dec 2004 Benjamin Lopez  
10 May 2005 Russ Fischer

Well done. The significance levels on the spectral plot are especially useful.

02 Mar 2006 Udo Schwarz  
27 Mar 2006 Martin Trauth  
04 May 2007 Ken Liao

Works exactly like it supposed to. It would be nice to output the raw spectrum data to a matrix.

16 May 2007 samir khan  
24 Jul 2007 Shyam Sundar  
04 Jan 2008 sella lestari

i still learning about this topic.
thanks for help me to understand and use this file.

04 Feb 2008 kondala rao rupa  
02 Jun 2008 Hasan Demirhan

i have 538 data points and i need analyse these data. But when i entering hifac=1548 programme did't work, so i need fast computation for this value.

05 Jun 2008 Pooria Sattari

Hey Guys:

I have problems with the inputdata prcedure. How should I input my n*2 matrix?

Thanks,

23 Mar 2010 Lei

it seems that the significant level strongly depends on the time resolution of the input. How to resolve this problem?

16 Apr 2010 Rahul

Great piece of code!

28 May 2011 NILANJANDC

Hi could not get the use of calibration frequency and calibration amplitude? plz help.

27 Jun 2011 Jan

Excellent program! But how to realise an analyse of a phase shifted data input?

27 Jun 2011 Brett Shoelson

Hi all,
Unfortunately, I am unable to support this piece of code. I wrote it VERY long ago, haven't touched it in a long time. The best I can do is (re-)steer you to the reference cited above. As for the calibration, that's my own implementation, and I don't know exactly how mathematically "rigorous" the idea is. The amplitude of peaks in the spectrum is only relevant relative to the amplitudes of other peaks. My thought was to add to the data a stationary signal of a know amplitude and frequency. The resulting "reference peak" would help to scale, or "calibrate," the spectrum of the data.
Cheers,
Brett

Please login to add a comment or rating.
Updates
31 Oct 2001

Provides a missing subfunction.

09 Apr 2003

Eliminates a duplicated subfunction, and fixes a bug when hifac is selected. Also, now successfully evaluates the real part of imaginary data.

Tag Activity for this File
Tag Applied By Date/Time
spectral analysis Brett Shoelson 22 Oct 2008 06:38:57
lomb scargle periodogram Brett Shoelson 22 Oct 2008 06:38:57
signal processing Brett Shoelson 22 Oct 2008 06:38:57
lomb scargle periodogram NILANJANDC 26 May 2011 17:25:10

Contact us at files@mathworks.com