pythonastronomy

Check if a function has a certain shape in python


I'm writing a python GUI to help visualise lightcurves of stars and check for exoplanet transits.

This is what a folded light curve looks like when an actual planet is orbiting the star in our line of sight:

enter image description here

I'm looking for a way to automatically detect whether a transit happened (so a function that looks like the graph above of flux over time), so that a bunch of calculations about the planet can happen next.

This is what a folded light curve might look like if it's somewhat periodic but not a real transit: enter image description here

And sometimes they can be just nonsense:

enter image description here

How do I distinguish between a transit and something else? I tried making up some logic expression using maxs and mins of this array, but I feel like I'm missing something very obvious and I'm probably making a fool of myself.

I have the array for flux over time of the folded lightcurve (but also the normal light curve and the period of the function, if it's periodical), and I've also tried just checking if the function is periodic, but that won't work because sometimes light curves are just periodic for other reasons (variable stars...).

Any ideas?


Solution

  • One possible solution might be to use a moving average of your datapoints with a period similar to that of the width of the dip in flux. The plot of the moving average for an actual transit should look something like this. From the moving average datapoints, you can isolate possible transmissions by selecting all point with a flux within some range of standard deviations from the mean (exact thresholds are up to you, but since the mean will be slightly below the horizontal portion of the plot, I'd reccomend a small positive deviation and a larger negative deviation as your bounds). if all (or almost all) those selected points occur within an acceptable time window (not to small or large), you have a transmission, and can continue. If multiple transits are possible within the time window, you can validate them by checking if each group of consecutive (in terms of time) points fits within the time window. If transmission/s are found, you can then verify that the graph is otherwise horizontal by taking the points in the moving average that weren't selected as transmissions and checking if the standard deviation is below some acceptable threshold. You can play around with different thresholds for each step to find the ones that best work with your data.