mzechmeister / GLS

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

Save periodogram and statistical result #19

Closed zhexingli closed 2 years ago

zhexingli commented 2 years ago

Hello,

May I ask if there's a way to save the result of the periodogram? i.e. 1) the periodogram itself (power at each frequency) along with the FAP level used so we could re-plot it using our preferred plotting tool, 2) a separate save file that saves all the statistical result of the periodogram and peaks. Currently the statistical result only gets printed out to the command line.

Thanks.

mzechmeister commented 2 years ago

Frequency and power are available as attributes (gls.f, gls.power), which can be used to pass them to other python skripts and plotting routines or to write them customised to a file.

But there is also a gls.toFile() method https://github.com/mzechmeister/GLS/blob/8439405dc741740ebcc473e0cfee84a08872257d/python/gls.py#L802 which even works from shell command line (option -ofile): https://github.com/mzechmeister/GLS/blob/8439405dc741740ebcc473e0cfee84a08872257d/python/gls.py#L854

On shell command line, the statistical output could be redirected to a file with the "output redirect operator" > (https://www.gnu.org/software/bash/manual/html_node/Redirections.html) FAPs and FAP levels are not written and there is no shell command line to handle it.

zhexingli commented 2 years ago

Thank you so much! Could the FAP levels be a possible attributes in future implementation since this is something already included in the code?

mzechmeister commented 2 years ago

@zhexingli Please check the just committed version and let me know if it is ok. Otherwise you may reopen this issue.

zhexingli commented 2 years ago

Thank you! The FAP of the strongest signal is in the output now (Just realized it was in the output at the very bottom, but it's more obvious now). Sorry for keep coming back at this, but could we also add in the output the corresponding power of the test level, i.e., the horizontal line representing the level of the test with FAP at 0.1% or 1% level? Or is there a quick way I could compute it?

mzechmeister commented 1 year ago

That the power level is outputted for the input FAPs, was implemented in the previous closing commit (https://github.com/mzechmeister/GLS/commit/d71260d52d2886c0d8ab8f4156caacb4c38654fb). E.g.

gls ... -fap 0.01 1e-3
...
p(FAP=0.01): 0.07102438085832652
p(FAP=0.001): 0.08755424759335073

The corresponding power of the test level are given. Thus I don't understand the new request. Or, do I misunderstand something?

zhexingli commented 1 year ago

Ohhh I see. Sorry! Forgot to add the keyword argument in my call to Gls. All good now. Thank you!!