# Binning a Phase Folded Lightcurve

How do I bin a messy phase folded lightcurve? This is one of the phase folded generated plots for a variable star. I plotted the phase using the period extracted by Lomb-Scargle Periodogram algorithm. I need to bin them say by ~100 or so. Kindly help me out.

This is the periodigram obtained using Lomb-Scargle method.

• I would have expected a much smoother curve. IMO, either it has not been folded properly or the curve is dominated by statistical errors (i.e. no detection) Aug 17, 2021 at 12:00
• Another reason could it be noise destruction. Aug 17, 2021 at 13:51
• I plotted the periodogram and got the frequency as I expected. When I plotted the phase folded curve, I got this. Aug 17, 2021 at 18:16
• If you'd like, you can post more information, like a few lines of the code you used to obtain it, the plot of the peridogram and a plot of the original data (possibly dot-plots, not line-plots, for visual clarity). I'm not an expert, but I'd be happy to help you pinpoint the problem Aug 17, 2021 at 19:03
• Yes, I've edited the question. I have added the periodogram. Aug 18, 2021 at 4:27

tl;dr: try a finer frequency grid to obtain the correct period, bin it with the function astropy.timeseries.aggregate_downsample

Before addressing the binning, you have to obtain a correct phase folded plot. You rightly call it "messy", the most likely reason is that the period you chose is wrong (assuming the data actually contains a periodic signal with good S/N).

I understand you might not want to share your code. I will then make some assumptions:

• you are using python, matplotlib and astropy
• you have computed the peridogram using astropy.timeseries.LombScargle
• you have used the default normalization='standard'
• you have taken the frequency of the highest peak on the plot you posted and used it to phase-fold the data

In general, blindly taking the highest peak of the peridogram that comes out of the Lomb-Scargle is often not the best approach. In particular in this case the highest peak has a value of about $$\approx 0.020$$, which is definitely low. The correct period usually comes with peridogram values higher than $$0.4$$ (the maximum is $$1$$). But don't take this as a rule. You may use the method false_alarm_probability to better quantify the probability that the peak is significant and not random.

I believe that you have not found the correct period because you have used a too coarse frequency grid. The period lies between the points and you have missed it. Use a much finer frequency grid and you might be able to see a new peak appearing, very high and narrow. Alternatively, if you don't want to choose the spacing yourself, you may use the autopower method, that should find the best frequency grid for you.

After you have found the correct period and your folded curve makes sense, binning is the easiest part, there is a function that does just that: astropy.timeseries.aggregate_downsample.

Everything that I just said (and much more) is explained in the documentation of astropy, which is really complete and easy to understand. I cannot stress it enough, read the documentation and you will find that most of the problems you may encounter are already addressed there:

astropy: Lomb-Scargle

astropy: Time Series

And a more technical paper that explains the capabilities and limitations of the Lomb-Scargle, I suggest you keep it as a reference:

Understanding the Lomb-Scargle Periodogram

• The Vanderplas paper is excellent. Aug 18, 2021 at 7:24
• @ProfRob I just discovered it this morning, I am really impressed Aug 18, 2021 at 7:24
• There are some interesting things here: vanderplas.com Though not about Astronomy per se I linked to their github in this SO answer. Also, there are some other Lomb-Scargle questions and periodogram questions that may also be in need of additional attention.
– uhoh
Aug 19, 2021 at 0:58