Comments (11)
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.
Cool, thanks!
from exoplanet.
@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()
from exoplanet.
from exoplanet.
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.
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.
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.
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.
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.
@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.
Edit: change all occurrences of period to period/2 in the above comment - sorry!
from exoplanet.
Related Issues (20)
- Python 3.10 support HOT 2
- Can Exoplanet/Pymc3 interact with TTVFaster? HOT 3
- xarray serialization error when using observed custom distribution HOT 11
- Issue installing on M1 Mac HOT 4
- celerite2.backprop.LinAlgError: failed to factorize or solve matrix HOT 2
- AttributeError: module 'exoplanet.distributions' has no attribute 'Angle' HOT 1
- TTV fit sampling behaves strangely for long light curves HOT 2
- AttributeError: module 'exoplanet' has no attribute 'get_dense_nuts_step' HOT 1
- Using a number of cores larger than the number of chains HOT 3
- `ImportError` (I think due to numpy dependency) HOT 3
- Tutorial Error for Trace Function
- `ImportError` On clean installation in virtual enviroment HOT 2
- Optimized MAP solution is wrong after clipping residuals
- Change a to a_over_Rsun in KeplerianOrbit HOT 2
- Support numpy >= 1.22 HOT 2
- Looking for library directory when running TESS transit fitting example
- Conflicts with current version of arviz/xarray HOT 4
- Can't seem to verify installation properly on Windows 11 HOT 4
- Installation Error: Failed to build pytensor
- Installation Issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exoplanet.