ENH: Adding Transit Periodogram to astropy.stats#7391
ENH: Adding Transit Periodogram to astropy.stats#7391bsipocz merged 13 commits intoastropy:masterfrom dfm:transit-periodogram
Conversation
|
Hi there @dfm 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labeled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃. Everything looks good from my point of view! 👍 If there are any issues with this message, please report them here. |
|
Probably need a rebase to get rid of |
|
p.s. Usually tests are in their own |
|
@pllim: thanks for the suggestions! I hear you on the squashing :-) I figured that I would squash after getting feedback, but I'm happy to do it now if you'd prefer. I've moved the tests, added a changelog entry, and (hopefully) fixed the compilation bug with old C compilers. I'm not actually sure how to fix the astropy helpers issue. I tried rebasing and it says that everything is up to date. Any tips? Thanks! |
|
@dfm did you do a |
|
Also saw this error in 32-bit build: |
|
I hadn't done that, but I did previously rebase. When I do a |
|
I suspect whatever you rebased against was also outdated. Try this... If you don't have a remote pointing to Then I did something similar with your branch here and I get something like: Theoretically I could force push to your PR here, but it would mess up the author listing, so I will refrain. |
|
I tried running those commands and still no luck - very strange! There's a doctest failure on the 32bit build that I'm also going to need to track down, but I'm done for the day. I'll check back tomorrow! Thanks again for your help. |
|
Thanks @dfm for the PR! I think it works well with some of the other functionality in the stats package and also would be something useful for the community. I will mention that this is a large and complex PR so it might take awhile to provide a full review of it, but looking forward to working with you on this. |
|
@dfm - This is an awesome addition, and I'm sure a large number of people will appreciate to have this readily available in astropy. However, I would argue that keeping the name BLS is preferable rather than a more generic term. It's a widely known name for it, and makes it unambiguous which algorithm is implemented leaving room for adding other ones later (though probably not to astropy core but a separate package). @crawfordsm - I'm happy to help out in the review on the python side, though that it may indeed take some time. |
|
@crawfordsm @bsipocz Thanks! I'm looking forward to working with y'all to get this into good shape. Re: naming - I've always disliked the name BLS because I think it's a bit misleading, but I'm willing to defer and you're probably right that sticking with the historical name is the right way to go... it's also fewer characters :-) |
|
@bsipocz: thanks! It looks like I fixed the helpers bit. |
|
This looks great in itself, but should it really be in |
|
@mhvk With the support expressed by multiple maintainers, that it is based on highly cited work, and that exoplanets is current a major field of astronomy, I would be inclined to include it. It also seems like it might be applicable to other fields. |
|
Just for consideration: If this has any chance to be taken out and put in another affiliated package in the future, we should think carefully. Does benefit outweigh the risk? Will this stay forever? Should this find a home instead in an exoplanet specific library? Lesson learned from That said, I have no personal objection. |
|
I feel that while somewhat specialized, this belongs to stats more than in an exoplanet library. While my experiences getting rather obsolete (or just the field is moving too fast), BLS was typically run along with LS and other stats, sharing the same technical issues, etc while it shares less with more detailed, individual transit modeling. Currently stats is a bit of a random pile of different algorithms anyway, and we could have already argued for a few of those whether they belong here or not (not to mention cosmology; I know why we keep it in core but one could use the same argument that it's only useful for a subset of astronomers and yet not infrastructure, so it should belong to a separate package). Maybe the future refactoring would be to factor out parts of stats into a stat package once it grows disproportionally big? |
|
@crawfordsm, @bsipocz - there are many major fields in astronomy, and so far astropy has only included things that benefit more than a single field. I'd certainly argue this is the case for cosmology, which really is more like coordinates and time, providing standard tools to map redshift to distance, time, etc. The analogy that could be drawn would be with a cosmology-focussed PR that, e.g., adds statistical analysis tools for CMB fluctuations or growth of structure, etc. That would serve at least as many people as this PR, but would be, in my opinion, similarly too narrow for inclusion in the core. p.s. I do agree that |
|
I think at this stage it might be best to just ask the coordination committee to pipe in where exactly the line should be drawn between sufficiently general and too specialized, so cc @taldcroft, @kelle, @astrofrog, @eteq. p.s. Just to be absolutely sure, this is not in the least a comment on the code/functionality: it looks great. I just happen to think it is an excellent start for an affiliated package for exoplanet transit analysis. |
|
I'm inclined to include this in |
|
Hi @dfm! This PR has been brought up at #pyastro18 as something I could help review. To start – is there a reason you call it ...and if you wanted to name it for the application, calling it |
|
Great to see an efficient implementation of this algorithm in Cython! Just to chime in on the issue of where this sits, the algorithm is widely used outside of exoplanet science. To me that suggests a place in If there was ever a case to move it to an affiliated package, it would probably be to a generalised time-series analysis package such as stingray. But then the LS periodogram was not put there, so presumably this should not be for similar reasons? |
|
Hi all, Sorry for taking so long to weigh in - I've been traveling (of course)! I'm totally down with changing the name. |
|
Still need to get rid of |
|
@pllim not "still"... "again" :-) I'm bad a computers sometimes. Thanks! |
|
@dfm - I'm sorry, I missed it totally today that there were still helpers issues. |
|
@bsipocz - I actually managed to mess this up after my rebase... I forgot to run |
|
@dfm - Ohh, the trick is not to use |
|
I experimented with this tutorial today. Looks good to me, everything worked well with the tutorial. I found a teeny-tiny bit of missing documentation:
|
bsipocz
left a comment
There was a problem hiding this comment.
I'm very much in favour of getting this in now to get as much user feedback as possible rather than leave it to last minute before feature freeze.
|
Looks like it still needs a change log (if there was one before, it is gone now). And is the coverage decrease expected? |
|
@pllim - coveralls is useless with the cython coverage, it's quite unbeliavable all but one file have >90% coverage, but that one is 30%. I'll try to have a look at it (but can't give an ETA, so anyone is more than welcome to have a double check). |
|
Giving it a final review, and everything does look great. It still needs a changelog entry and could use the mention of the license The low coverage tests does seem to be with the cython code though the file that it mainly wraps around (bls.c) reports high coverage. |
|
Hey folks, thanks for the feedback! I've added a changelog entry and the license comments to the headers. I'm also confused about the coverage issues - the file that's bringing down the coverage fraction is auto-generated by Cython. Is there something that I should do to mark that as something that should be skipped? Thanks again! |
|
I'm go ahead and merge this now. Please try to get users testing it, so any fix needed can be done before it goes into the actual release. |
|
Thank you @dfm! |
|
@mirca - Retrospect I've noticed that the rebasing and squashing in this PR meant that your commits has been squashed into other ones and thus your author credit has disappeared from the history. I'm truly, terribly sorry about this. |
Hi all,
This pull request adds a new feature that I've been working on for a while now with contributions from @mirca and @joeldhartman. This feature is another popular astronomy-specific periodogram like Lomb-Scargle, but this one is used to find transiting exoplanets and eclipsing binary systems by using a top-hat basis instead of sines. For historical reasons, this algorithm is often referred to as "box least squares", but I think that the more descriptive "transit periodogram" name is better.
This algorithm was proposed by Kovács et al. (2002) and the method has since become the standard method of detecting transiting planets. In many cases, this is achieved by wrapping the Fortran code released by those authors (many people use f2py bindings that I wrote almost 5 years ago). With K2 data continuing to roll in and the launch of TESS (hopefully today! 🤞) it seems like it would be timely to have an implementation of this algorithm within AstroPy.
With this in mind, my collaborators and I have written an efficient implementation of this algorithm in C with Cython bindings that expose an interface that will be familiar for anyone who uses the LombScargle class in astropy.stats.
A build of the documentation for this pull request can be found here. I have also written up a tutorial that uses this code to detect planets using data from NASA's K2 Mission that can be found here. I expect that something like this would eventually be submitted to astropy-tutorials, but I thought that it might be useful to have it here for now.
I have discussed this pull request with several AstroPy maintainers (e.g. @eteq and @adrn) and they endorsed the idea of submitting this to core, but if the community would prefer to keep this as a separate package, I'm certainly open to that idea. Either way, I would definitely appreciate any feedback.
Thanks!