christinahedges / TESS-SIP

Long term rotation period finding tool for NASA's TESS mission
MIT License
16 stars 5 forks source link

Periodogram does not seem to converge #7

Open icweaver opened 3 years ago

icweaver commented 3 years ago

Hi @christinahedges, thanks again for the quick fix in #6! I am running into an issue now where the periodograms do not seem to be converging for me:

from tess_sip import SIP
import lightkurve as lk
import matplotlib.pyplot as plt

%config InlineBackend.print_figure_kwargs={"facecolor" : "w"}

srs_tpfs = lk.search_targetpixelfile("WASP-50", author="TESS-SPOC", sector=4)
tpfs = srs_tpfs.download_all()

display(srs_tpfs)

r = SIP(tpfs, min_period=1, max_period=30)
plt.plot(r["periods"], r["power"])
SearchResult containing 1 data products.

 #     mission     year   author  exptime target_name distance
                                     s                 arcsec 
--- -------------- ---- --------- ------- ----------- --------
  0 TESS Sector 04 2018 TESS-SPOC    1800   382391899      0.0
/home/mango/miniconda3/envs/tess_sip/lib/python3.9/site-packages/lightkurve/lightcurve.py:1031: LightkurveWarning: The light curve appears to be zero-centered (median=1.91e+04 electron / s +/- 1.05e+05 electron / s); `normalize()` will divide the light curve by a value close to zero, which is probably not what you want.
  warnings.warn(
Running pixels in aperture: 100%|█████████████████████████████████████████████████████████████████████████████████████| 80/80 [00:00<00:00, 490.13it/s]

download

For comparison, the periodogram created from the light curve file returns the following:

srs_lcs = lk.search_lightcurve("WASP-50", author="TESS-SPOC", sector=4)
lcs = srs_lcs.download_all()

display(srs_lcs)

lc = lcs[0].remove_nans().normalize()
pg = lc.to_periodogram(minimum_period=1, maximum_period=30)
plt.plot(pg.period, pg.power) # pg.plot()
SearchResult containing 1 data products.

 #     mission     year   author  exptime target_name distance
                                     s                 arcsec 
--- -------------- ---- --------- ------- ----------- --------
  0 TESS Sector 04 2018 TESS-SPOC    1800   382391899      0.0

download 2

I was wondering if there is anything that I need to tune/transform beforehand or if there are any other sort of diagnostics I should check first?

christinahedges commented 3 years ago

Hi @icweaver, this is definitely expected behavior here, as we go to longer periods it's easy to over fit (because we're fitting systematics at the same time as doing the periodogram). The power_bkg array is the periodogram of the background pixels, and if you compare to that you should be able to identify true signal compared to overfitting, e.g.

image

In the example here there is lots of power in the background pixels at long periods so we can discount it.

Hope this helps?

icweaver commented 3 years ago

Oh perfect, dividing them certainly does the trick!

plt.plot(r["periods"], r["power"]/r["power_bkg"])

download

I see now that you even introduced background pixel correction in an earlier release for dealing with exactly this, sorry for the noise (no pun intended)