Coder Social home page Coder Social logo

Comments (11)

dfm avatar dfm commented on August 16, 2024 1

This functionality has not been carefully tested -- that's also why it's not documented :) -- so use at your own risk!

That being said, the bug here is that the transit_times or ttvs arguments must be lists of arrays (or list of tensors, or list of lists), one for each body. You could change it to transit_times=[[1, 2, 3]] and it should work.

from exoplanet.

jiayindong avatar jiayindong commented on August 16, 2024

Cool, thanks!

from exoplanet.

gjgilbert avatar gjgilbert commented on August 16, 2024

@jiayindong @dfm Just a heads up that even using the list-of-arrays workaround, I've been running into issues with TTVOrbit. For some reason, not all the transits are being generated, or are perhaps offset by an unusually large TTV amplitude (see top figure below). The reference planet here is Kepler-18c (P=7.6 days), and should have more or less evenly spaced transits, with a TTV amplitude of ~10 min. As you can see, many transits are missing.

Of course, it's possible I've made a mistake in my implementation somewhere, although everything seems to work fine when I use KeplerianOrbit (bottom figure).

import numpy as np
import matplotlib.pyplot as plt
import exoplanet as exo

def calculate_model_flux(pshape, Rstar, tts, time_stamps, cadences):
    '''
    pshape: array of transit parameters -- [T0, P, rp, zeta, b^2, esinw, ecosw, u1, u2]
    Rstar: stellar radius [solar radii]
    tts: list of transit times
    time_stamps: list of time stamps (one per transit)
    cadences: cadence of each transit
    '''
    # check that vector lengths are consistent
    if len(time_stamps) != len(tts):
        raise ValueError('inconsistent input lengths')
    if len(cadences) != len(tts):
        raise ValueError('inconsistent input lengths')

    # convert pshape parameters to a form more easily used by starry
    T0, P, rp, a, inc, ecc, w, u1, u2 = pshape_to_pstarry(pshape, Rstar)
    b = np.sqrt(pshape[4])

    # setup exo.StarryLightCurve() object
    exoSLC = exo.StarryLightCurve([u1,u2])

    orbit = exo.orbits.TTVOrbit(transit_times=[tts], , a=a, r_star=Rstar)    

    model = exoSLC.get_light_curve(orbit=orbit, r=rp, t=np.hstack(time_stamps)).eval()

    return model

# 'planets' is a list of objects which hold relevant planet parameters, ttv info, etc    
p = planets[0]

tts = p.tts[p.quality]                      # a list of transit times
time_stamps = p.grab_stamps('time')         # a list of 'stamps' cut for 3 transit durations around each tt
flux_stamps = p.grab_stamps('flux')         # a list of correspnding flux values
cadences = p.stamp_cadence[p.quality]       # Kepler cadence of each stamp ('short' or 'long')

model = wings.calculate_model_flux(p.pshape, RSTAR, tts, time_stamps, cadences)

plt.figure(figsize=(18,6))
plt.plot(np.hstack(time_stamps), np.hstack(flux_stamps), 'k.')
plt.plot(np.hstack(time_stamps), model+1, 'orange')
plt.show()

Screen Shot 2019-07-18 at 3 48 47 PM

Screen Shot 2019-07-18 at 3 56 09 PM

from exoplanet.

dfm avatar dfm commented on August 16, 2024

from exoplanet.

gjgilbert avatar gjgilbert commented on August 16, 2024

I've uploaded my code here: https://github.com/gjgilbert/pterodactyl. Everything should be executable from the jupyter notebook. You'll need to specify a few paths in the first two cells but everything else should run without issue. The behavior in question is in the last few cells under the section "do a model fit" and the relevant function in pterodactyl_wings is "calculate_model_flux"

The lightcurve detrending takes a few minutes, so if you'd prefer me to put together a slimmed-down version of this code let me know and I'll be happy to do it.

from exoplanet.

dfm avatar dfm commented on August 16, 2024

Thanks! Yeah - it would be best if you could put together a simple standalone version that isolates the problem. I have a few ideas, but like I said this definitely hasn't been well tested so it'll take some poking!

from exoplanet.

gjgilbert avatar gjgilbert commented on August 16, 2024

Okay, a notebook 'dfm_exoplanet_testing' is uploaded here: https://github.com/gjgilbert/pterodactyl, plus three .fits files containing relevant data for the three planets in the Kepler-18 system. All you need to do is specify which file you want to read in (keyword "FITSFILE" in the second cell). FYI, the naming convention I've used sorts the planets by orbital period, which is not necessarily their actual KOI or Kepler ID.

from exoplanet.

dfm avatar dfm commented on August 16, 2024

Hi Greg, sorry for the slow response over here! Can you make a little toy example that has the same behavior without all the surrounding infrastructure. Like one single standalone function with no dependencies or files. Then we'll be able to see more clearly where the issue is coming from. Thanks!

from exoplanet.

gjgilbert avatar gjgilbert commented on August 16, 2024

No worries about the response time, Dan!

Here's a completely stripped-down notebook that reproduces the issue: https://github.com/gjgilbert/pterodactyl/blob/master/dfm_exoplanet_testing.ipynb

from exoplanet.

dfm avatar dfm commented on August 16, 2024

@gjgilbert: I got a chance to look at this and I worked out what was going on. I'd developed the model in the limit where the ttvs were less than the period, but here you have some transits that come more than a period late so that was messing up all the bookkeeping. I just pushed a change that looks a bit better, but there's still an issue when the transit comes >2 "periods" late. In the example you sent, one of your transits is 10 days after the previous one - are you sure that there shouldn't be another transit in there that you're missing? The way the code is set up, you need to provide a transit time for every transit (even the ones that aren't observed). I'll work on making this clearer, but let me know if it's reasonable to expect that some systems will have TTVs larger than the reference period....

from exoplanet.

dfm avatar dfm commented on August 16, 2024

Edit: change all occurrences of period to period/2 in the above comment - sorry!

from exoplanet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.