mzechmeister / GLS

Generalised Lomb-Scargle periodogram
MIT License
35 stars 5 forks source link

FAP level #9

Closed zhexingli closed 5 years ago

zhexingli commented 5 years ago

Hello,

Is there any way to show a FAP = 1%, 10.% etc or similar overplotted on the periodogram? Thank you.

Best,

Zhexing

mzechmeister commented 5 years ago

Thanks for this excellent question and sorry for the late reply. Since the feature could be frequently requested, I have enhanced the code. plot returns now the figure object, which can be modified.

So after creating the gls object (here the standard example):

>>> from gls import *
>>> time = np.random.uniform(54000., 56000., 1000)
>>> flux = 0.15 * np.sin(2. * np.pi * time / 10.)
Add some noise
>>> error = 0.5 * np.ones(time.size)
>>> flux += np.random.normal(0, error)
>>> gls = Gls((time, flux, error))

one can do now:

>>> fig = gls.plot()
>>> fig.get_axes()[0].axhline(gls.powerLevel(0.01), linewidth=0.5, color='r', dashes=(16, 16))
>>> fig.get_axes()[0].axhline(gls.powerLevel(0.001), linewidth=0.5, color='r', dashes=(16, 8))

This produces demo_fap_issue_9

It might be convenient to have a FAP argument in the plot function. However, I guess people want to change at least styles, so that more arguments are required.

zhexingli commented 5 years ago

Thank you so much!!!

mzechmeister commented 4 years ago

Finally, I implemented in 73af7bc a fap plot option. You can do now:

>>> gls.plot(fap=0.01)
zhexingli commented 4 years ago

This is awesome, thank you!

zhexingli commented 3 years ago

Hello, apologize for bringing this topic back up again. I recently moved to a new device and redownloaded GLS and found errors are returning after running the periodogram. It seems the 'fap' variable within gls.plot(fap=0.01) is no longer working? plot funciton doesn't include fap anymore?

I tried to plot fap with another way: fig = gls.plot(block=True,period=True) fig.get_axes()[0].axhline(gls.powerLevel(0.01), linewidth=0.5, color='r', dashes=(16, 16))

But it returns this error:

AttributeError: module 'matplotlib.pyplot' has no attribute 'get_axes'

which is extremely odd to me. Any workarounds? Thanks.

mzechmeister commented 3 years ago

The FAP level argument is still there: https://github.com/mzechmeister/GLS/blob/281a964b3f13b0fba1e6f6946ddf8d88e69d9d6c/python/gls.py#L465

Did you follow the install instruction on https://github.com/mzechmeister/GLS/tree/master/python?

Or did you got https://github.com/mzechmeister/python/blob/master/gls.py, which is not synchronised and outdated?

zhexingli commented 3 years ago

Oh sorry about that! Yes I got it directly from the github master directory. I'll follow the install instruction. Thanks.