stingray icon indicating copy to clipboard operation
stingray copied to clipboard

DynamicalPowerspectrum on TESS light curve

Open gjmlunaIAFE opened this issue 2 years ago • 9 comments

Hello, I'm downloading a light curve from a TESS source with lightkurve, then use lc.to_stingray() to have it stingray format. My light curve is a 1 min, 70 days long ligth curve (from two sectors). When I try to build the dynamical power spectrum within Stingray with:

dps = stingray.DynamicalPowerspectrum(lc, segment_size=3)

I get the following error message:

No GTIs are equal to or longer than segment_size

the units of my time column are days, and I should have many 3-days segments. Any help is appreciated!. thanks

gjmlunaIAFE avatar Jan 18 '23 16:01 gjmlunaIAFE

I think this is probably an edge case we didn't find because we haven't really tested Stingray with TESS data, so thank you for reporting!

Two things:

  1. Could you print out lc.gti and tell us what that says (I think it should be None or just empty, but let's make sure)
  2. What happens if you do

dps = stingray.DynamicalPowerspectrum(lc, segment_size=3, gti=[[lc.time[0], lc.time[-1]]])

Does that help?

dhuppenkothen avatar Jan 18 '23 16:01 dhuppenkothen

Hello, thanks for the prompt answer. My bad, I'm dealing with a K2 light curve, not TESS, but they are similarly read in lightkurve.

the output of lc.gti says: array([[2823.30596281, 2897.49293923]]) which are exactly the times that I have in my light curve. Your suggestion about gti=[[lc.time[0], lc.time[-1]]] now gives another error:

ValueError("Length of the segment is too long to create " "any segments of the light curve!")

I have removed some NaN and outliers from the K2 curve, which might make it no evenly sampled, could this be the problem? thanks

gjmlunaIAFE avatar Jan 18 '23 17:01 gjmlunaIAFE

Oooh, exciting! What if you set lc.gti = None?

dhuppenkothen avatar Jan 18 '23 18:01 dhuppenkothen

Also, stingray isn't that well set up to deal with unevenly sampled data (because Fourier methods aren't designed to work with uneven sampling), so that might cause additional issues.

dhuppenkothen avatar Jan 18 '23 18:01 dhuppenkothen

lc.gti didn't solve the problem. I guess the sampling is the problem. It would have been great to be able to do the dynamical Lomb Scargle version, that is ok with unevenly sample data

gjmlunaIAFE avatar Jan 18 '23 18:01 gjmlunaIAFE

I've opened a slightly different issue #689 to suggest a larger project of adding versions of current algorithms to work with unevenly sampled data. I don't think this'll happen in the next month or two, but I think it might make a nice Google Summer of Code project.

For your use case, do you want to share the code you used to generate the light curve? I'm happy to spend an hour debugging to see if it really is the sampling that's the issue (I'm not 100% confident of that, because I'd have expected a different error in this case), or if there's something else going on that's weird?

dhuppenkothen avatar Jan 18 '23 18:01 dhuppenkothen

HI, many thanks!, I'm not very skillful in python coding, so I might have done something wrong. Here is a Jupyter notebook that I was running. gx14_brasil.py.gz

gjmlunaIAFE avatar Jan 18 '23 18:01 gjmlunaIAFE

@gjmlunaIAFE we recently added many algorithms to deal with unevenly sampled data, and made quite a number of changes to DynamicalPowerspectrum as well. Would you like to help us devise a use case that describes your needs?

matteobachetti avatar Jan 05 '24 10:01 matteobachetti

@matteobachetti I think a nice case would be the dynamical power spectrum of the Kepler/K2 data of V2116 Oph, whose power spectrum I published here https://www.aanda.org/articles/aa/pdf/2023/08/aa47177-23.pdf . Please let me know what would yo need from my side to move forward with this. Thanks

gjmlunaIAFE avatar Jan 08 '24 14:01 gjmlunaIAFE