pyke icon indicating copy to clipboard operation
pyke copied to clipboard

Adding Cotrend Tutorial

Open christinahedges opened this issue 8 years ago • 6 comments

Added a tutorial for CBVs on Tabby's star. It's pretty brief, maybe that's a good thing?

christinahedges avatar Oct 24 '17 19:10 christinahedges

Is it ready for review?

barentsen avatar Oct 24 '17 19:10 barentsen

@barentsen Yes please, it's a bit rough and I'm not sure it's what you wanted...? Early comments are much appreciated! :D Easier to read here.

christinahedges avatar Oct 24 '17 19:10 christinahedges

screen shot 2017-10-26 at 9 42 34 am

import matplotlib.pyplot as plt
from tqdm import tqdm
from pyke import KeplerCBVCorrector

cbv = KeplerCBVCorrector("kplr008462852-2011073133259_llc.fits")

list_of_cbvs = []
for n in range(1, 16):
    list_of_cbvs.append(range(1, n+1))

neg_log_likelihood = []
for cbvs in tqdm(list_of_cbvs):
    cbv.correct(list(cbvs))
    neg_log_likelihood.append(cbv.opt_result.fun)

n_cbvs = [len(list(list_of_cbvs[i])) for i in range(len(list_of_cbvs))]

plt.plot(n_cbvs, neg_log_likelihood, 'o-.')
plt.xlabel('Number of cbvs')
plt.ylabel('Negative Log Likelihood (Laplacian pdf)')
plt.title("CBV correction Tabby's Star Quarter 8")
plt.show()

Maybe this is going to be helpful to include in this tutorial?

cc @barentsen @christinahedges

mirca avatar Oct 26 '17 16:10 mirca

Thanks for working on this! My main comments are:

  1. Let's add a bunch more content and figures to explain what CBVs are. We can literally copy most of this from the "demystifying Kepler data" paper, which did an excellent job. It is fine to use content from that paper and make it more easily accessible by putting it in the sphinx docs.

  2. I don't think Tabby's star is a good example to demo the CBV-based correction. The figures and appendices in the demystiying Kepler paper show much better examples, let's use/adapt/reproduce those!

  3. I see there is both a ipynb and a rst file. Is one generated from the other? I think we should only have one source file or we'll end up editing the wrong one?

barentsen avatar Nov 14 '17 00:11 barentsen

Yep, let's just use the .ipynb file. Sphinx automagically converts it into .rst for the doc page.

Also, perhaps would be more useful to use the recently added KeplerCBVCorrector class instead of the kepcotrend function?

mirca avatar Nov 14 '17 01:11 mirca

  • Oh ok, let's remove the rst file from this PR in that case! (Though it's easier to give feedback on, so perhaps it is not a terrible idea to have the rst file in a PR during review and only remove it before merging!)

  • Mixing command-line tools and Python code is going to be confusing for beginners. My proposal is to use only command-line tools in the tutorials, but end every tutorial with a section that says "If you wanted to do the above in a Python script, here is the code:". Thoughts?

barentsen avatar Nov 14 '17 03:11 barentsen